Exemple #1
0
class Student(User):
    meta = {
        'allow_inheritance' : False,
        'collection'        : 'student',
    }

    name = f.StringField(required = True)

    education  = f.EmbeddedDocumentListField(Education)
    experience = f.EmbeddedDocumentListField(Experience)

    # i.e. Python, Flask, React, etc.
    skills = f.ListField(f.StringField())

    def get_education(self):
        return map(lambda ed: ed.to_dict(), self.education)

    def get_experience(self):
        return map(lambda ex: ex.to_dict(), reversed(self.experience))

    def to_dict(self):
        return {
            'id': str(self.id),
            'name': self.name,
            'education': self.get_education(),
            'experience': self.get_experience()
        }
Exemple #2
0
class Employee(Document):
    employeeID = fields.StringField(max_length=10, required=True, null=False)
    employeeName = fields.StringField(max_length=100, required=True)
    workLocation = fields.StringField(max_length=255, required=True)
    # orders = fields.EmbeddedDocumentListField(Order)
    skills = fields.EmbeddedDocumentListField(Skills)
    projects = fields.EmbeddedDocumentListField(Projects)
Exemple #3
0
class BasicStructure(EmbeddedDocument):
    main_tag = fields.EmbeddedDocumentListField(ATag)
    color = fields.EmbeddedDocumentListField(ColorModel)
    people = fields.EmbeddedDocumentField(PeopleTag, default=PeopleTag())
    location = fields.ListField()
    emotion_tag = fields.StringField(default="")
    deduction = fields.ListField()
Exemple #4
0
class Employee(Document):
    empId = fields.StringField(max_length=5, required=True, null=False)
    empName = fields.StringField(max_length=20, required=True, null=False)
    workLocation = fields.StringField(max_length=20, required=True, null=False)

    projects = fields.EmbeddedDocumentListField(Projects)
    skills = fields.EmbeddedDocumentListField(Skills)
Exemple #5
0
class ProductTerms(DynamicEmbeddedDocument):
    biological_process = fields.EmbeddedDocumentListField(
        GOTerm, required=False, db_field="biologicalProcess")
    cellular_component = fields.EmbeddedDocumentListField(
        GOTerm, required=False, db_field="cellularComponent")
    molecular_function = fields.EmbeddedDocumentListField(
        GOTerm, required=False, db_field="molecularFunction")
    meta = {'abstract': True}
Exemple #6
0
class Cart(Document):
    slug = fields.StringField(required=True, max_length=128)
    user = fields.EmailField(max_length=128)
    products = fields.EmbeddedDocumentListField(Product)
    vouchers = fields.EmbeddedDocumentListField(Voucher)
    coupons = fields.EmbeddedDocumentListField(Coupon)

    date_updated = fields.DateTimeField(default=datetime.datetime.utcnow)

    meta = {'allow_inheritance': False}
Exemple #7
0
class DashboardDataInstance(Document):
    totalImages = fields.EmbeddedDocumentField(HostActivityInstance)
    mostClicks = fields.EmbeddedDocumentField(HostActivityInstance)
    mostPackets = fields.EmbeddedDocumentField(HostActivityInstance)
    machineCount = fields.EmbeddedDocumentField(HostActivityInstance)
    dataPackets = fields.EmbeddedDocumentField(HostActivityInstance)
    interestingDiscoveries = fields.EmbeddedDocumentListField(
        PacketDataInstance)
    wordCloudData = fields.EmbeddedDocumentField(TagCountInstance)
    hostActivity = fields.EmbeddedDocumentListField(HostActivityInstance)
    imageCarousel = fields.EmbeddedDocumentListField(ImageInstance)
Exemple #8
0
class Customer(Document):
    """
        This models contains the customer data.
    """
    full_name = fields.StringField(max_length=200, required=True)
    cpf = fields.StringField(max_length=11, required=True, unique=True)
    birth_date = fields.DateTimeField(required=True)
    incomes = fields.EmbeddedDocumentListField(Income)
    patrimonies = fields.EmbeddedDocumentListField(Patrimony)

    def __str__(self):
        return "{} - {}".format(self.full_name, self.cpf)
Exemple #9
0
class Terminators(DynamicDocument, Base):
    citations = fields.EmbeddedDocumentListField(Citations,
                                                 db_field="citations")
    external_cross_references = fields.EmbeddedDocumentListField(
        ExternalCrossReferences, db_field="externalCrossReferences")
    class_ = fields.StringField(required=False, db_field="class")
    transcriptionTerminationSite = fields.EmbeddedDocumentField(
        TranscriptionTerminationSite, required=True)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    meta = {'collection': 'terminators'}
class Genes(DynamicDocument, BiologicalBase):
    bnumber = fields.StringField(required=False, db_field="bnumber")
    centisome_position = fields.FloatField(required=False,
                                           db_field="centisomePosition")
    fragments = fields.EmbeddedDocumentListField(Fragments, required=False)
    gc_content = fields.FloatField(required=False, db_field="gcContent")
    interrupted = fields.BooleanField(required=False)
    terms = fields.EmbeddedDocumentListField(Terms, required=False)
    type = fields.StringField(required=False)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    meta = {'collection': 'genes'}
Exemple #11
0
class Album(Document):

    # albumId = fields.StringField()
    _id = fields.ObjectIdField()
    coverPhotoId = fields.StringField()
    albumName = fields.StringField()
    userId = fields.StringField()
    albumPhoto = fields.EmbeddedDocumentListField(AlbumPhoto)
    albumTag = fields.EmbeddedDocumentListField(AlbumTag)
    createTime = fields.DateTimeField(default=datetime.utcnow())  # 建相簿的時間
    updateTime = fields.DateTimeField(default=datetime.utcnow())
    isDeleted = fields.BooleanField(default=False)

    @classmethod
    def pre_save(cls, sender, document):
        document.lastUpdateTime = datetime.utcnow()
class Location(Document):
    """
    A location object
    """
    name = fields.StringField()
    description = fields.StringField()
    address = fields.StringField()
    lat = fields.StringField()
    lng = fields.StringField()
    submitted_by = fields.StringField()
    certified = fields.BooleanField()
    feature_set = fields.EmbeddedDocumentField(FeatureSet,
                                               default=FeatureSet())
    comments = fields.EmbeddedDocumentListField(Comment)

    def __repr__(self):  # pragma: no cover
        return "Location(name=%r)" % self.name

    def toJSType(self):
        """
        => dict of Location
        """
        return dict(name=self.name,
                    description=self.description,
                    address=self.address,
                    lat=self.lat,
                    lng=self.lng,
                    submitted_by=self.submitted_by,
                    certified=self.certified,
                    id=str(self.id),
                    comments=[c.toJSType() for c in self.comments],
                    feature_set=self.feature_set.toJSType())
Exemple #13
0
class NrFollowers(Document):
    instagram_username = fields.StringField(required=True, unique=True)
    data = fields.EmbeddedDocumentListField(WeFollowNrFollowers)

    def __str__(self):
        return 'instagram_username: ' + self.instagram_username

    def add(self, nr_foll):
        ts = datetime.datetime.utcnow()
        nr_foll_obj = WeFollowNrFollowers(nr_followers=nr_foll, timestamp=ts)
        self.update(add_to_set__data=[nr_foll_obj])

    # if it is already more than 23:45h ago
    def is_time_to_add(self):
        now = datetime.datetime.utcnow()
        if len(self.data) == 0:
            return True

        latest = max([obj.timestamp for obj in self.data])

        if latest >= datetime.datetime.utcnow() - datetime.timedelta(
                hours=23, minutes=45):
            return False
        else:
            return True

    # returns the list of tuples (date, nr_followers)
    # list is sorted from the oldest to the newest
    def get_data(self):
        res = [(obj.timestamp, obj.nr_followers) for obj in self.data]
        return sorted(res, key=lambda tup: tup[0])
Exemple #14
0
class Measurements(fields.Document):
    owner = fields.IntField()  # User.pk
    units = fields.StringField()
    height = fields.FloatField()
    body_mass = fields.FloatField()
    last_date = fields.DateTimeField()
    everyday_list = fields.EmbeddedDocumentListField(EveryDayMeasurements)
class Receta(Document):
    contenido = fields.StringField()
    imagen = fields.URLField()
    me_gusta = fields.ListField(fields.DynamicField())
    nombre = fields.StringField()
    autor = fields.ReferenceField(Autor, reverse_delete_rule=2)
    ingredientes = fields.EmbeddedDocumentListField(Ingrediente)
Exemple #16
0
class Buses(Document):
    matricula = fields.StringField(max_length=100, blank=False, required=True)
    choferes = fields.ReferenceField(Choferes,
                                     blank=False,
                                     required=True,
                                     dbref=True)
    asientoAsignado = fields.EmbeddedDocumentListField(AsientoAsignado)
Exemple #17
0
class Prep(Document):
    name=fields.StringField(primary_key=True)
    campaign = fields.StringField()
    priority = fields.LongField(default=0)
    updated = fields.DateTimeField()

    workflows=fields.EmbeddedDocumentListField(Workflow)
Exemple #18
0
class Contributions(Document):
    __project_regex__ = '^[a-zA-Z0-9_]+$'
    project = fields.StringField(
        min_length=3,
        max_length=30,
        required=True,
        regex=__project_regex__,
        help_text="project name/slug (valid format: `{}`)".format(
            __project_regex__))
    identifier = fields.StringField(
        required=True, help_text="material/composition identifier")
    collaborators = fields.EmbeddedDocumentListField(
        Collaborator,
        required=True,
        help_text='list of collaborators (emails stripped)')
    content = fields.EmbeddedDocumentField(
        Contents,
        required=True,
        help_text='free-form content of the contribution')
    meta = {
        'collection': 'contributions',
        'indexes':
        ['identifier', 'project', {
            'fields': ['project', 'identifier']
        }]
    }
Exemple #19
0
class Notebooks(Document):
    nbformat = fields.IntField(required=True, help_text="nbformat version")
    nbformat_minor = fields.IntField(required=True,
                                     help_text="nbformat minor version")
    metadata = fields.EmbeddedDocumentField(Metadata,
                                            required=True,
                                            help_text='notebook metadata',
                                            default=Metadata)
    cells = fields.EmbeddedDocumentListField(Cell,
                                             required=True,
                                             help_text='cells')
    meta = {'collection': 'notebooks'}

    problem_key = 'application/vnd.plotly.v1+json'
    escaped_key = problem_key.replace('.', '~dot~')

    def transform(self, incoming=True):
        if incoming:
            old_key = self.problem_key
            new_key = self.escaped_key
        else:
            old_key = self.escaped_key
            new_key = self.problem_key

        for cell in self.cells:
            for output in cell.outputs:
                if old_key in output.get('data', {}):
                    output['data'][new_key] = output['data'].pop(old_key)

    def clean(self):
        self.transform()

    def restore(self):
        self.transform(incoming=False)
class Customer(Document):
    customerId = fields.StringField(max_length=10, required=True, null=False)
    customerName = fields.StringField(max_length=100, required=True)
    credit = fields.IntField()
    status = fields.BooleanField()
    remarks = fields.StringField(max_length=255, required=False)
    orders = fields.EmbeddedDocumentListField(Order)
Exemple #21
0
 class Schema1EmbDoc1(EmbeddedDocument):
     embdoc1_int = fields.IntField()
     embdoc1_str = fields.StringField()
     embdoc1_str_empty = fields.StringField()
     embdoc1_str_ten = fields.StringField(choices=[str(x) for x in range(11)])
     embdoc1_float = fields.FloatField()
     embdoc1_int_empty = fields.IntField()
     embdoc1_long = fields.LongField()
     embdoc1_decimal = fields.DecimalField()
     embdoc1_complex_datetime = fields.ComplexDateTimeField()
     embdoc1_list = fields.ListField()
     embdoc1_ref_doc1 = fields.ReferenceField('Schema1Doc1')
     embdoc1_emb_embdoc1 = fields.EmbeddedDocumentField('self')
     embdoc1_emblist_embdoc1 = fields.EmbeddedDocumentListField('self')
     embdoc1_emb_embdoc2 = fields.EmbeddedDocumentField('Schema1EmbDoc2')
     embdoc1_emblist_embdoc2 = fields.EmbeddedDocumentListField('Schema1EmbDoc2')
class BiologicalBase(Base):
    citations = fields.EmbeddedDocumentListField(Citations,
                                                 db_field="citations")
    external_cross_references = fields.EmbeddedDocumentListField(
        ExternalCrossReferences, db_field="externalCrossReferences")
    left_end_position = fields.IntField(required=False,
                                        db_field="leftEndPosition")
    note = fields.StringField(required=False, db_field="note")
    organisms_id = fields.StringField(required=False)
    right_end_position = fields.IntField(required=False,
                                         db_field="rightEndPosition")
    sequence = fields.StringField(required=False)
    strand = fields.StringField(required=False)
    synonyms = fields.ListField(required=False)

    def __init__(self, **kwargs):
        super().__init__()
Exemple #23
0
class Article(Document):
    # id = fields.StringField(primary_key=True)
    url = fields.StringField(required=True)
    headline = fields.StringField(required=True)
    date_of_publication = fields.StringField()
    # is of type either date-exact or date-range
    main_text = fields.StringField()
    reports = fields.EmbeddedDocumentListField(Report)
class CustomerDocument(documents.BaseDocument):
    """
        Model that represent the customer registered in app
    """
    class Meta:
        object_name = 'Customer'

    cpf = fields.StringField(required=True,
                             max_length=11,
                             min_length=11,
                             unique=True)
    date_birth = fields.DateTimeField(required=True, )
    name = fields.StringField(required=True, max_length=100)
    address = fields.StringField(required=True, max_length=150)
    patrimonies = fields.EmbeddedDocumentListField(documents.PatrimonyDocument)
    sources_income = fields.EmbeddedDocumentListField(
        documents.SourceIncomeDocument)
        class BaseDoc(db.Document):
            inner = db.EmbeddedDocumentField(EmbeddedDoc)
            inner_list = db.EmbeddedDocumentListField(EmbeddedDoc)

            req_field = db.StringField(required=True)
            string = db.StringField()
            bool = db.BooleanField()
            integer_field = db.IntField()
            dict_f = db.DictField()
class PatchingDumbDocument(Document):
    name = fields.StringField()
    int_fld = fields.IntField()
    lst_fld = fields.ListField()
    dct_fld = fields.DictField()
    intlst_fld = fields.ListField(fields.IntField())
    intdct_fld = fields.MapField(fields.IntField())
    emb = fields.EmbeddedDocumentField(DumbEmbedded)
    emb_lst = fields.EmbeddedDocumentListField(DumbEmbedded)
class TranscriptionFactors(DynamicDocument, BiologicalBase):
    active_conformations = fields.EmbeddedDocumentListField(
        Conformations, required=True, db_field="activeConformations")
    connectivity_class = fields.StringField(required=False,
                                            db_field="connectivityClass")
    global_function = fields.StringField(required=True,
                                         db_field="globalFunction")
    inactive_conformations = fields.EmbeddedDocumentListField(
        Conformations, required=False, db_field="inactiveConformations")
    products_ids = fields.ListField(fields.StringField(),
                                    db_field="products_ids")
    sensing_class = fields.StringField(required=False, db_field="sensingClass")
    site_length = fields.ListField(fields.StringField(), db_field="siteLength")

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    meta = {'collection': 'transcriptionFactors'}
Exemple #28
0
class Task(Document):
    name = fields.StringField(max_length=2000, primary_key=True)
    job_type = fields.StringField(max_length=100)
    updated = fields.DateTimeField()
    failures_count = fields.IntField()

    prep = fields.EmbeddedDocumentField(Prep)
    workflow = fields.EmbeddedDocumentField(Workflow)
    statuses = fields.EmbeddedDocumentListField(TaskSiteStatus)
Exemple #29
0
class Publicacion(Document):
    titulo = fields.StringField(max_length=100, required=True, null=False)
    descripcion = fields.StringField(max_length=500)
    localizacion = fields.StringField(max_length=50, required=True)
    tematica = fields.ListField(fields.StringField(max_length=30))
    autor = fields.StringField(max_length=50)
    listaComentarios = fields.EmbeddedDocumentListField(
        Comentario)  # Se borra a mano
    meGusta = fields.ListField(
        fields.ReferenceField(Usuario, reverse_delete_rule=PULL)
    )  # Si se borra usuario de like -> se quita
    creador = fields.ReferenceField(
        Usuario, reverse_delete_rule=CASCADE,
        required=True)  # Si se borra creador -> se borran sus publicaciones
    listaGraffitis = fields.EmbeddedDocumentListField(
        Graffiti, required=True)  # Se borra a mano

    def getDetailURL(self):
        return reverse('publicacion-detail', args={str(self.id)})
        class Model(db.Document):

            base = db.ReferenceField(Base)
            f1 = db.StringField()
            f2 = db.BooleanField()
            f3 = db.StringField()

            embedded = db.EmbeddedDocumentField(ED)
            listf = db.EmbeddedDocumentListField(ED)

            dictf = db.DictField()