Ejemplo n.º 1
0
class Post(db.Document):
    subject = db.StringField()
    author = db.StringField(required=True, max_length=50)
    description = db.StringField()
    created_at = db.DateTimeField(required=True, default=datetime.utcnow)
    comments = db.ListField(db.ReferenceField('Comment'))
    # Post will have a list of comments
    meta = {'collection': 'posts'}
Ejemplo n.º 2
0
class User(db.DynamicDocument):
    # We can make the title field optional. because only teachers have a title
    # student table we should keep some additional field dl_docs_array and login_counter and login_array
    # All this field will be set dynamically
    dl_docs_array = db.ListField(db.ReferenceField('File'))
    login_counter = db.IntField()
    login_array = db.ListField(db.DateField())
    title = db.StringField()
    approved = db.BooleanField()

    name = db.StringField(required=True, max_length=50)
    surname = db.StringField(required=True)
    email = db.EmailField(required=True)
    password = db.BinaryField(required=True)
    user_type = db.StringField(required=True)
    school = db.ReferenceField(School)  # Here will store id of the school
    # Here will be list of post collection
    posts = db.ListField(db.ReferenceField('Post'))

    meta = {'collection': 'users'}
Ejemplo n.º 3
0
class Assignment(db.Document):
    title = db.StringField(required=True, max_length=200)
    description = db.StringField()
    # who is created this assignment. that means the reference of the user
    created_by = db.ReferenceField('User')
    # which school belongs to this assignment.
    school = db.ReferenceField('School')
    # Assignment will have a submission date
    submission_date = db.DateTimeField(required=True)
    # Assignment will have a status open or close. true means open false means close
    status = db.BooleanField(required=True, default=True)
    # An assignment will have a list of document which we can call documents
    documents = db.ListField(db.ReferenceField('Document'))
    meta = {'collection': 'assignments'}
Ejemplo n.º 4
0
class School(db.Document):
    name = db.StringField(required=True, max_length=100)
    # Below method will not work anymore
    # Since Now Module will have both files and chats reference
    # So we should create separate model for module1, module2, module3
    # module1 = db.ListField(db.ReferenceField('File'))
    # module2 = db.ListField(db.ReferenceField('File'))
    # module3 = db.ListField(db.ReferenceField('File'))
    # chats = db.ListField(db.ReferenceField('Chat'))

    module1 = db.ReferenceField('Module1')
    module2 = db.ReferenceField('Module2')
    module3 = db.ReferenceField('Module3')
    # A school will have a list of assignment
    assignments = db.ListField(db.ReferenceField('Assignment'))
    meta = {'collection': 'schools'}
Ejemplo n.º 5
0
class Module3(db.Document):
    files = db.ListField(db.ReferenceField('File'))
    chats = db.ListField(db.ReferenceField('Chat'))
    meta = {'collection': 'module3'}
Ejemplo n.º 6
0
class File(db.Document):
    user = db.ReferenceField('User')
    filename = db.StringField()
    tags = db.ListField(db.StringField(), default=list)
    created_at = db.DateTimeField(required=True, default=datetime.utcnow)
    meta = {'collection': 'files'}