Пример #1
0
class Project(db.Document):
    title = db.StringField(required=True, unique=True)
    status = db.StringField(required=True, default='active', choices={'active', 'archived'})
    created_by = db.ReferenceField('User')
    created_date = db.DateTimeField(required=True, default=datetime.now)
    cards = db.ListField(db.ReferenceField('Card'), reverse_delete_rule=db.PULL)

    class Meta:
        collection_name = "project"
        strict = False

    def find_all(self):
        items = self._repo.find_all()
        return items
Пример #2
0
class User(db.Document):
    email = db.EmailField(required=True, unique=True)
    password = db.StringField(required=True, min_length=6)
    projects = db.ListField(db.ReferenceField('Project'), reverse_delete_rule=db.PULL)
    cards = db.ListField(db.ReferenceField('Card'), reverse_delete_rule=db.PULL)
    assignments = db.ListField(db.ReferenceField('Card'), reverse_delete_rule=db.PULL)

    class Meta:
        collection_name = "user"

    def hash_password(self):
        self.password = generate_password_hash(self.password).decode('utf8')

    def check_password(self, password):
        return check_password_hash(self.password, password)
Пример #3
0
class Card(db.Document):
    title = db.StringField(required=True)
    content = db.StringField()
    start_date = db.DateTimeField()
    end_date = db.DateTimeField()
    status = db.StringField(required=True, default='received', choices={'received', 'started', 'checked', 'completed'})
    assigned_to = db.ListField(db.ReferenceField('User'))
    created_by = db.ReferenceField('User')
    project = db.ReferenceField('Project')
    created_date = db.DateTimeField(required=True, default=datetime.now)
    completion_date = db.DateTimeField()
    comments = db.ListField(db.EmbeddedDocumentField('Comment'))

    class Meta:
        collection_name = "card"
Пример #4
0
class Comment(db.EmbeddedDocument):
    content = db.StringField(required=True)
    sender = db.ReferenceField('User')
    created_date = db.DateTimeField(required=True, default=datetime.now)

    class Meta:
        collection_name = "comment"
Пример #5
0
class User(db.Document):
    email = db.EmailField(required=True, unique=True)
    password = db.StringField(required=True, min_lenght=6)
    wishlist = db.ListField(db.ReferenceField('Wish', reverse_delete_rule=db.PULL))

    def hash_password(self):
        self.password = generate_password_hash(self.password).decode('utf8')

    def check_password(self, password):
        return check_password_hash(self.password, password)
class User(db.Document):
    email = db.EmailField(max_length=254, required=True, unique=True)
    password = db.StringField(min_length=6, required=True)
    movies = db.ListField(db.ReferenceField(
        'Movie', reverse_delete_rule=db.PULL))

    def hash_password(self):
        self.password = generate_password_hash(self.password).decode('utf8')

    def check_password(self, password):
        return check_password_hash(self.password, password)
Пример #7
0
class Wish(db.Document):
    title = db.StringField(required=True)
    description = db.StringField()
    url = db.StringField()
    image = db.StringField()
    added_by = db.ReferenceField('User')
Пример #8
0
class Movie(db.Document):
    name = db.StringField(required=True, unique=True)
    casts = db.ListField(db.StringField(), required=True)
    genres = db.ListField(db.StringField(), required=True)
    added_by = db.ReferenceField('User')