Beispiel #1
0
class ItemModel(BaseSQLModel):
    id = AutoField()
    title = CharField(max_length=64)
    user = ForeignKeyField(UserModel, backref="items", on_delete="CASCADE")
    category = ForeignKeyField(CategoryModel,
                               backref="items",
                               on_delete="CASCADE")
    brand = ForeignKeyField(BrandModel, backref="items", on_delete="CASCADE")
    tags = ManyToManyField(TagModel, backref="items")

    condition = CharField(choices=ItemCondition)
    value = DecimalField(decimal_places=2, auto_round=True)
    currency = CharField(choices=Currency)
    description = CharField(max_length=128)
    status = CharField(choices=ItemStatus, default=ItemStatus.AVAILABLE)
    preference_score_rate = DecimalField(decimal_places=2,
                                         auto_round=True,
                                         default=0)
    popularity_rate = DecimalField(decimal_places=2,
                                   auto_round=True,
                                   default=0)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "items"

    def __str__(self):
        return self.name
Beispiel #2
0
class Workout(BaseModel):
    id = PrimaryKeyField()
    name = CharField(null=False)
    category = CharField()
    start_time = DateTimeField(default=datetime.now())
    end_time = DateTimeField(null=True)
    creator = CharField(null=False)
    exercises = JSONField(default=[])
Beispiel #3
0
class Post(BaseModel):
    id = PrimaryKeyField()
    comments = JSONField(default=[])
    photo = CharField(null=True)
    caption = CharField(null=True)
    date = DateTimeField(default=datetime.now())
    original_workout = ForeignKeyField(Workout)

    class Meta:
        index = ('post', 'original_workout')
Beispiel #4
0
class CardModel(BaseSQLModel):
    id = AutoField()
    author = ForeignKeyField(UserModel, backref="cards", on_delete="CASCADE")
    list = ForeignKeyField(ListModel, backref="cards", on_delete="CASCADE")
    title = CharField(max_length=256)
    description = CharField(max_length=1024)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "cards"
Beispiel #5
0
class UserModel(BaseSQLModel, UserMixin):
    id = AutoField()
    username = CharField(unique=True, index=True, max_length=16)
    email_address = CharField(unique=True, max_length=256)
    salt = BlobField()
    key = BlobField()
    role = CharField(default=UserRole.MEMBER)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "users"
Beispiel #6
0
class Article(BaseModel):
    title = CharField(unique=True, verbose_name="title")
    content = TextField(verbose_name="content")
    tag = ForeignKeyField(Tag, related_name="articles", verbose_name="tag")
    create_time = DateTimeField(default=datetime.now,
                                verbose_name="create time")
    up_time = DateTimeField(default=datetime.now, verbose_name="create time")
Beispiel #7
0
class Machine(Model):
    name = CharField(index=True, unique=True)
    metadata = BinaryJSONField()
    train_start_date = DateTimeTZField()
    train_end_date = DateTimeTZField()

    class Meta:
        database = db

    @classmethod
    def from_endpoint(cls, ep):
        """
        Returns a Machine object constructed from a valid endpoint.

        Parameters
        ----------
        ep: Dict
            Endpoint from watchman

        Returns
        -------
        Machine

        """
        return cls(**endpoint_to_machine_data(ep))

    def __repr__(self):
        return f"Machine {self.__data__} "
Beispiel #8
0
class Game(BaseModel):
    """Game model."""

    title = CharField(
        max_length=100,
        unique=True,
    )
    config = JSONField()
class WordEmbedding(BaseModel):
    word = CharField(null=False)
    embedding = BinaryJSONField(null=False)
    version = IntegerField(null=False)
    inserted_at = DateTimeField(null=False, default=datetime.now)

    class Meta:
        db_table = 'word_embeddings'
Beispiel #10
0
class ListModel(BaseSQLModel):
    id = AutoField()
    # TODO: Restrict author must be role ADMIN
    author = ForeignKeyField(UserModel, backref="lists", on_delete="CASCADE")
    title = CharField(max_length=256)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "lists"
Beispiel #11
0
class CommentReplyModel(BaseSQLModel):
    id = AutoField()
    author = ForeignKeyField(UserModel, backref="replies", on_delete="CASCADE")
    comment = ForeignKeyField(CommentModel,
                              backref="replies",
                              on_delete="CASCADE")
    content = CharField(max_length=256)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)

    class Meta(BaseSQLModel):
        table_name = "comment_replies"
Beispiel #12
0
class ImageModel(BaseSQLModel):
    id = AutoField()
    url = CharField(max_length=256)
    item = ForeignKeyField(ItemModel, backref="images", on_delete="CASCADE")
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "images"

    def __str__(self):
        return self.url
Beispiel #13
0
class Machine(Model):
    name = CharField(index=True, unique=True)
    dataset = BinaryJSONField()
    model = BinaryJSONField()
    metadata = BinaryJSONField()

    class Meta:
        primary_key = False
        database = db
        table_name = "machine"

    def __repr__(self):
        return f"Machine {self.__data__} "
Beispiel #14
0
class CommentModel(BaseSQLModel):
    id = AutoField()
    author = ForeignKeyField(UserModel,
                             backref="comments",
                             on_delete="CASCADE")
    card = ForeignKeyField(CardModel, backref="comments", on_delete="CASCADE")
    content = CharField(max_length=256)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "comments"
Beispiel #15
0
class User(BaseModel):
    login = CharField(unique=True)
    email = CharField(unique=True)
    pw_hash = TextField()
    authenticated = BooleanField(default=False)
    active = BooleanField(default=False)

    def is_authenticated(self):
        return self.authenticated

    def is_active(self):
        return self.active

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.login

    def set_password(self, password):
        self.pw_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.pw_hash, password)
Beispiel #16
0
class CategoryModel(BaseSQLModel):
    id = AutoField()
    name = CharField(unique=True, max_length=64)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "categories"

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        self.name = self.name.lower()
        return super().save(*args, **kwargs)
Beispiel #17
0
class TagModel(BaseSQLModel):
    id = AutoField()
    value = CharField(unique=True, max_length=64)
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "tags"

    def __str__(self):
        return self.value

    def get(self, **kwargs):
        kwargs["value"] = kwargs["value"].lower()
        return super().get(**kwargs)

    def save(self, *args, **kwargs):
        self.value = self.value.lower()
        return super().save(*args, **kwargs)
Beispiel #18
0
class Sale(BaseModel):

    id = IntegerField(primary_key=True)
    city = CharField(null=True)
    district = CharField(null=True)
    address = CharField(null=True)
    latitude = FloatField(null=True)
    longitude = FloatField(null=True)
    floor = IntegerField(null=True)
    number_of_floors = IntegerField(null=True)
    number_of_rooms = IntegerField(null=True)
    kitchen_area = FloatField(null=True)
    living_area = FloatField(null=True)
    total_area = FloatField(null=True)
    walling = CharField(null=True)
    price_amount = FloatField(null=True)
    price_currency = CharField(null=True)
    seller = CharField(null=True)
    resale = BooleanField(null=True)
    image = CharField(null=True)
    url = CharField(null=True)
    created_at = DateTimeField(default=datetime.utcnow)
    updated_at = DateTimeField(default=datetime.utcnow)
Beispiel #19
0
class Team(BaseModel):
    name = CharField(null=False, unique=True, primary_key=True)
Beispiel #20
0
class Chat(BaseModel):
    id = PrimaryKeyField()
    events = JSONField(default=[])
    name = CharField()
    date_created = DateTimeField(default=datetime.now)
    background = CharField(default="default")
Beispiel #21
0
class AuthId(BaseModel):
    auth_id = CharField(unique=True, null=False)
    user = ForeignKeyField(User)
    date_created = DateTimeField(default=datetime.now)
Beispiel #22
0
class MigrationHistory(BaseModel):

    migration = CharField()
    applied_at = DateTimeField(default=datetime.utcnow)
Beispiel #23
0
class User(BaseModel):
    name = CharField(unique=True, primary_key=True)
    photo = CharField(null=True)
Beispiel #24
0
class Tag(BaseModel):
    name = CharField(unique=True, verbose_name="name")
    desc = CharField(verbose_name="description")