コード例 #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
コード例 #2
0
 class MLModel(Base):
     id = AutoField()
     name = CharField(unique=True)
     type = CharField()
     resource = CharField()
     extra_params = BinaryJSONField(null=True)  # used for additional metadata specific to a given type of model
     model_params = BinaryJSONField(null=False)  # used for model parameters and weights serializable to JSON
     extra_data = BlobField(null=True)  # for model parameters/weights serializable to specific file format (e.g. h5)
コード例 #3
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"
コード例 #4
0
ファイル: models.py プロジェクト: mickorivera/irithm-cards
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"
コード例 #5
0
ファイル: models.py プロジェクト: mickorivera/irithm-cards
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"
コード例 #6
0
ファイル: models.py プロジェクト: mickorivera/irithm-cards
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"
コード例 #7
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"
コード例 #8
0
class MatchModel(BaseSQLModel):
    id = AutoField()
    item_a = ForeignKeyField(ItemModel, index=True, related_name="matches_a")
    item_b = ForeignKeyField(ItemModel, index=True, related_name="matches_b")
    date_created = DateTimeField(null=True)
    date_updated = DateTimeField(null=True)
    is_deleted = BooleanField(default=False)

    class Meta(BaseSQLModel):
        table_name = "matches"

    def __str__(self):
        return f"{self.item_a} - {self.item_b}"
コード例 #9
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
コード例 #10
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)
コード例 #11
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)
コード例 #12
0
 class Dataset(Base):
     id = AutoField()
     datetime = DateTimeField(null=False)
     longitude = DoubleField(null=False)
     latitude = DoubleField(null=False)
     data = BinaryJSONField(default={})