Example #1
0
class Song(db.Document):
    name = db.StringField(max_length=255, required=True)
    lyrics = db.StringField(required=True)
    difficulty = db.IntField(required=True)
    path = db.StringField()
    author = db.StringField()
    language = db.StringField(choices=(('eng', 'en-US'), ('ru', 'ru-RU')), required=True)
class Shop(db.Document):
    name = db.StringField()
    cost = db.IntField()
    use = db.StringField()
    css_code = db.StringField()

    def __str__(self):
        return self.name
class Achievement(db.Document):
    name = db.StringField()
    way_get = db.StringField()
    rarity = db.IntField()
    points = db.IntField()
    amount_get = db.IntField()

    def __str__(self):
        return self.name
Example #4
0
class User(db.Document, UserMixin):
    username = db.StringField(max_length=40)
    email = db.StringField(max_length=255)
    password = db.StringField(max_length=255)
    active = db.BooleanField(default=True)
    roles = db.ListField(db.ReferenceField(Role), default=[])
    points = db.IntField(default=0)
    sung_songs = db.EmbeddedDocumentListField(SungSong)
    avatar_filename = db.StringField()

    achievements = db.ListField(db.ReferenceField(Achievement), default=[])

    bought_styles = db.ListField(db.ReferenceField(Shop), default=[])

    def save(self, *args, **kwargs):
        if not self.username:
            self.username = self.email.split("@")[0]
        return super(User, self).save(*args, **kwargs)
class User(db.Document, UserMixin):
    username = db.StringField(max_length=40)
    email = db.StringField(max_length=255)
    password = db.StringField(max_length=255)
    active = db.BooleanField(default=True)
    roles = db.ListField(db.ReferenceField(Role), default=[])
    points = db.IntField(default=0)
    sung_songs = db.EmbeddedDocumentListField(SungSong)
    avatar_filename = db.StringField()
    rank = db.IntField(default=None)
    friendlist = db.ListField(db.StringField(), default=[])
    friendrequests = db.ListField(db.StringField(), default=[])

    achievements = db.ListField(db.ReferenceField(Achievement), default=[])

    bought_styles = db.ListField(db.ReferenceField(Shop), default=[])

    energy = db.IntField(default=10)
    energy_date = db.DateTimeField(default=datetime(
        year=2018, month=7, day=12, hour=7, minute=9, second=33))
    daily_gift_date = db.DateTimeField(default=datetime(
        year=2018, month=7, day=12, hour=7, minute=9, second=33))

    def save(self, *args, **kwargs):
        if not self.username:
            self.username = self.email.split("@")[0]
        return super(User, self).save(*args, **kwargs)
class Role(db.Document, RoleMixin):
    name = db.StringField(max_length=80, unique=True)
    description = db.StringField(max_length=255)

    def __str__(self):
        return self.name