cli impl
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
import datetime
|
||||
from enum import IntEnum
|
||||
from tortoise import fields, Model
|
||||
|
||||
|
||||
class ProductType(IntEnum):
|
||||
article = 1
|
||||
page = 2
|
||||
|
||||
|
||||
class PermissionAction(IntEnum):
|
||||
create = 1
|
||||
delete = 2
|
||||
update = 3
|
||||
read = 4
|
||||
|
||||
|
||||
class Status(IntEnum):
|
||||
on = 1
|
||||
off = 0
|
||||
|
||||
|
||||
class User(Model):
|
||||
username = fields.CharField(max_length=20, unique=True)
|
||||
password = fields.CharField(max_length=200)
|
||||
last_login = fields.DatetimeField(description='Last Login', default=datetime.datetime.now)
|
||||
is_active = fields.BooleanField(default=True, description='Is Active')
|
||||
is_superuser = fields.BooleanField(default=False, description='Is SuperUser')
|
||||
avatar = fields.CharField(max_length=200, default='')
|
||||
intro = fields.TextField(default='')
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.pk}#{self.username}'
|
||||
|
||||
|
||||
class Category(Model):
|
||||
slug = fields.CharField(max_length=200)
|
||||
name = fields.CharField(max_length=200)
|
||||
user = fields.ForeignKeyField('new_models.User', description='User')
|
||||
created_at = fields.DatetimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.pk}#{self.name}'
|
||||
|
||||
|
||||
class Product(Model):
|
||||
categories = fields.ManyToManyField('new_models.Category')
|
||||
name = fields.CharField(max_length=50)
|
||||
view_num = fields.IntField(description='View Num')
|
||||
sort = fields.IntField()
|
||||
is_reviewed = fields.BooleanField(description='Is Reviewed')
|
||||
type = fields.IntEnumField(ProductType, description='Product Type')
|
||||
image = fields.CharField(max_length=200)
|
||||
body = fields.TextField()
|
||||
created_at = fields.DatetimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.pk}#{self.name}'
|
||||
|
||||
|
||||
class Config(Model):
|
||||
label = fields.CharField(max_length=200)
|
||||
key = fields.CharField(max_length=20)
|
||||
value = fields.JSONField()
|
||||
status: Status = fields.IntEnumField(Status, default=Status.on)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.pk}#{self.label}'
|
||||
9
tests/test_utils.py
Normal file
9
tests/test_utils.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from alice.utils import cp_models
|
||||
|
||||
|
||||
class TestUtils(TestCase):
|
||||
def test_cp_models(self):
|
||||
ret = cp_models('models.py', 'new_models.py', 'new_models')
|
||||
print(ret)
|
||||
Reference in New Issue
Block a user