Пример #1
0
class CcUserCookies(Document):
    user_auth_id = fields.IntField(required=True, unique=True)
    cc_src_type_id = fields.ObjectIdField(null=True, required=False)
    cc_project_id = fields.ObjectIdField(required=True)
    cc_user_type_id = fields.ObjectIdField(null=True, required=False)
    cc_user_cookie_name = fields.StringField(required=True)
    cc_user_cookie_type = fields.IntField(required=True)
    cc_user_cookie_shared = fields.IntField(required=True)
    cc_user_cookie_key = fields.IntField(required=True)
    cc_user_cookie_details = fields.DynamicField(required=True)
    cc_user_cookie_creation_time = fields.DateTimeField()
    cc_user_cookie_expires_at = fields.DateTimeField()
    cc_user_is_cookie_active = fields.BooleanField(default=False,
                                                   required=False)
    cc_user_cookie_storage_engine = fields.IntField(required=True)
    is_active = fields.BooleanField(default=False, required=False)
    created_by = fields.IntField(required=True)
    created_at = fields.DateTimeField()
    updated_by = fields.IntField(required=True)
    updated_at = fields.DateTimeField(default=datetime.utcnow)

    def save(self, *args, **kwargs):
        if not self.created_at:
            self.created_at = datetime.utcnow()

        return super(CcUserCookies, self).save(*args, **kwargs)
Пример #2
0
class AnnoQuery(Document):
    query_image_id = fields.ObjectIdField()
    target_image_ids = fields.ListField(fields.ObjectIdField())
    meta = {'indexes': [{'fields': ['query_image_id'], 'unique': True}]}

    def __str__(self):
        return str(self.id)
Пример #3
0
class CcUserOtp(Document):

    user_auth_id = fields.IntField(required=True)
    user_profile_id = fields.ObjectIdField(null=True, required=False)
    user_account_id = fields.ObjectIdField(null=True, required=False)
    user_mobile_number = fields.StringField(required=True)
    user_mobile_otp = fields.IntField(required=True)
    # otp_generated_for = fields.IntField(required=False)  # need to be changed
    cc_project_id = fields.IntField(required=True)
    cc_is_otp_used = fields.BooleanField(required=False)
    cc_user_type_id = fields.IntField(required=False)
    otp_creation_time = fields.DateTimeField(default=datetime.now(india))
    otp_expiration_time = fields.DateTimeField(default=datetime.now(india) +
                                               timedelta(seconds=60))
    is_active = fields.BooleanField(default=False, required=False)
    created_by = fields.ObjectIdField(required=False)
    created_at = fields.DateTimeField()
    updated_by = fields.ObjectIdField(required=False)
    updated_at = fields.DateTimeField(default=datetime.utcnow)

    def save(self, *args, **kwargs):
        # if not self.created_at:
        # 	self.created_at = datetime.utcnow()
        # if not self.otp_creation_time: 9923891761
        # 	self.otp_creation_time = datetime.utcnow()

        return super(CcUserOtp, self).save(*args, **kwargs)
class History(Document):
    identity = fields.ObjectIdField()
    document_id = fields.ObjectIdField()
    document_type = fields.StringField()
    action = fields.StringField()
    path = fields.StringField()
    data = fields.DictField()
    created_at = fields.DateTimeField()
Пример #5
0
class Task(Document):
    title = fields.StringField(required=True)
    content = fields.StringField(required=True)
    user_id = fields.ObjectIdField(required=True)
    intent_id = fields.ObjectIdField(required=True)
    at_time = fields.DateTimeField(required=False)
    done = fields.BooleanField(default=False)

    class Meta():
        app_label = 'no_sql'
Пример #6
0
class Certification(Document):
    _id = fields.ObjectIdField(require=True)
    user_id = fields.ObjectIdField(require=True)
    org = fields.StringField(required=True)
    name = fields.StringField(required=True)
    tags = fields.ListField(required=True)
    apply_time = fields.LongField(required=True)
    deal_time = fields.LongField(required=True)
    state = fields.StringField(require=True)   # 通过的状态
    _class = fields.StringField()
    meta = {'collection' : 'Certification'}
Пример #7
0
class Recipe(Document):

    meta = {"collection": "recipes"}

    id = fields.ObjectIdField(primary_key=True, default=ObjectId)

    description = fields.StringField()
Пример #8
0
class Structures(Document):
    __project_regex__ = '^[a-zA-Z0-9_]+$'
    project = fields.StringField(
        min_length=3,
        max_length=30,
        required=True,
        regex=__project_regex__,
        help_text=f"project name/slug (valid format: `{__project_regex__}`)")
    identifier = fields.StringField(
        required=True, help_text="material/composition identifier")
    name = fields.StringField(required=True,
                              unique_with='cid',
                              help_text="table name")
    cid = fields.ObjectIdField(required=True, help_text="Contribution ID")
    lattice = fields.DictField(required=True, help_text="lattice")
    sites = fields.ListField(fields.DictField(),
                             required=True,
                             help_text="sites")
    meta = {
        'collection':
        'structures',
        'indexes': [
            'identifier', 'project', 'cid', 'name', {
                'fields': ['cid', 'name'],
                'unique': True
            }
        ]
    }
Пример #9
0
class DBImage(Document):
    server = fields.ObjectIdField(required=True)
    path = fields.StringField(required=True)
    mime_type = fields.StringField(required=True)
    width = fields.IntField(required=True)
    height = fields.IntField(required=True)
    source = fields.StringField()
    meta = {'indexes': [{'fields': ['path'], 'unique': True}, '#source']}

    def get_thumbnail(self):
        try:
            my_thumbnail = DBImageThumbnail.objects.get(DBImage=self.pk)
            return my_thumbnail
        except DBImageThumbnail.DoesNotExist:
            im = Image.open(self.path)
            thumbnail_height = 200
            thumbnail_width = thumbnail_height * im.width / im.height
            im.thumbnail((thumbnail_width, thumbnail_height), Image.ANTIALIAS)
            io = StringIO()
            im.save(io, im.format)
            io.seek(0)

            my_thumbnail = DBImageThumbnail(DBImage=self.pk,
                                            file=io,
                                            width=thumbnail_width,
                                            height=thumbnail_height,
                                            mime_type=self.mime_type)
            my_thumbnail.save()
            return my_thumbnail

    def __str__(self):
        return "[%s](%s)" % (self.server, self.path)
Пример #10
0
class InvoiceItem(EmbeddedDocument):

    """
    An :class:`~invoicing.models.InvoiceItem` is an :class:`~invoicing.models.Item` embedded
    in the :class:`~invoicing.models.InvoiceRevision` items list.

    It corresponds to the line of an invoice.
    """
    reference = fields.StringField(required=True, max_length=32)
    description = fields.StringField(required=True, max_length=512)
    quantity = fields.DecimalField(required=True, default=lambda: Decimal("1"))
    unit_price = fields.DecimalField(required=True)
    tax = fields.ReferenceField("Tax", required=True)
    item_id = fields.ObjectIdField()
    #footnote = fields.StringField(max_length=512)

    def __unicode__(self):
        if isinstance(self.reference, basestring):
            return self.reference
        return unicode(self.reference)

    @property
    def total_price(self):
        """Return the total price for this item, considering the quantity."""
        return self.quantity * self.unit_price
Пример #11
0
class Joke(mongo.Document):

    _id = fields.ObjectIdField()
    content = fields.StringField()
    from_url = fields.StringField()

    common_fields = ('_id', 'content')
Пример #12
0
class ExerciseCondition(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    student = fields.ReferenceField(Student)
    degree = fields.IntField()
    result = fields.StringField()
    times = fields.IntField()
Пример #13
0
class RegularModel(Document):
    """
    A model class for testing regular flat fields.
    """
    str_field = fields.StringField()
    str_regex_field = fields.StringField(regex="^valid_regex")
    url_field = fields.URLField()
    email_field = fields.EmailField()
    int_field = fields.IntField()
    long_field = fields.LongField()
    float_field = fields.FloatField()
    boolean_field = fields.BooleanField()
    nullboolean_field = fields.BooleanField(null=True)
    date_field = fields.DateTimeField()
    complexdate_field = fields.ComplexDateTimeField()
    uuid_field = fields.UUIDField()
    id_field = fields.ObjectIdField()
    decimal_field = fields.DecimalField()

    custom_field = CustomField()

    # TODO
    # dynamic_field = fields.DynamicField()
    # bin_field = fields.BinaryField()
    # file_field = fields.FileField()
    # image_field = fields.ImageField()

    def method(self):
        return 'method'
Пример #14
0
class Graffiti(EmbeddedDocument):
    _id = fields.ObjectIdField(required=True,
                               default=lambda: fields.ObjectId())
    imagen = fields.URLField(required=True)
    estado = fields.StringField(required=True)  #poner enumerado
    fechaCaptura = fields.DateField(required=True)
    autor = fields.ReferenceField(Usuario, required=True)
Пример #15
0
class ProblemCondition(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    student = fields.ReferenceField(Student)
    problem = fields.ReferenceField(Problem)
    result = fields.StringField()
    wrong = fields.ListField(fields.StringField())
    times = fields.IntField()
Пример #16
0
class Campaign(mongoengine.Document):
    mongoengine.connect(db='mop',
                        host='mongodb://mongo_main:27017/mop',
                        alias='campaigns_connection')

    meta = {
        'collection': 'mop_campaigns',
        'allow_inheritance': True,
        'db_alias': 'campaigns_connection'
    }

    name = fields.StringField(required=True)
    gameMaster = fields.ObjectIdField(required=True)
    players = fields.ListField(fields.ObjectIdField())
    characters = fields.ListField(fields.ObjectIdField())
    rules = fields.ListField(fields.ObjectIdField())
    initial_date = fields.DateTimeField(default=datetime.datetime.utcnow)
Пример #17
0
class Tag(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    description = fields.StringField()
    types = fields.StringField()
    difficulty = fields.IntField()
    book = fields.ReferenceField(Book)
    topic = fields.ListField(fields.ListField(fields.ReferenceField(Chapter)))
Пример #18
0
class School(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    area_code = fields.StringField()
    administrator = fields.StringField()
    types = fields.StringField()
    rank = fields.IntField()
    description = fields.StringField()
    register = fields.StringField()
Пример #19
0
class Application(BaseDocument):
    meta = {
        'allow_inheritance': False,
        'collection': 'application',
    }

    class State():
        APPLIED = "APPLIED"
        MATCHED = "MATCHED"
        NOT_MATCHED = "NOT_MATCHED"

    job_id = f.ObjectIdField(required=True)
    student_id = f.ObjectIdField(required=True)
    state = f.StringField(required=True, default=State.APPLIED)
    student_ranking = f.IntField(required=False, min_value=1)
    employer_ranking = f.IntField(required=False, min_value=1)

    def to_dict(self):
        student = Student.by_id(self.student_id)
        _dict = {
            'id': str(self.id),
            'job_id': str(self.job_id),
            'student_id': str(self.student_id),
            'student_ranking': self.student_ranking,
            'employer_ranking': self.employer_ranking,
            'state': self.state
        }
        if student:
            _dict.update({
                'student_name': student.name,
            })
        return _dict

    # To dict specifically for students
    def to_dict_student(self):
        _dict = self.to_dict()
        _dict.update({'student_ranking': self.student_ranking})
        return _dict

    # To dict specifically for students
    def to_dict_employer(self):
        _dict = self.to_dict()
        _dict.update({'employer_ranking': self.student_ranking})
        return _dict
class Character(mongoengine.Document):
    mongoengine.connect(db='mop', host='mongodb://mongo_main:27017/mop',
                        alias='campaigns_connection')

    meta = {'collection': 'mop_characters', 'db_alias': 'campaigns_connection'}

    user = fields.StringField(required=True)
    character_sheet = fields.StringField(required=True)
    campaign = fields.ObjectIdField(required=True)
    character_mementoes = fields.ListField(fields.StringField())
Пример #21
0
class users(Document):
    _id = fields.ObjectIdField(require=True)
    email = fields.StringField(required=True)
    userName = fields.StringField(required=True)
    password = fields.StringField(required=True)
    photo = fields.StringField(required=True)
    point = fields.StringField(required=True)
    type = fields.StringField(required=True)
    favourites = fields.ListField(required=True)
    _class = fields.StringField()
    meta = {'collection' : 'users'}
Пример #22
0
class Lezione(EmbeddedDocument):
    """
    Definizione di una lezione.
    """
    id = fields.ObjectIdField(primary_key=True, required=True)
    data = fields.StringField()
    inizio = fields.StringField()
    fine = fields.StringField()
    sede = fields.StringField()
    anno = fields.IntField()
    doy = fields.IntField()
    ore = fields.FloatField()
Пример #23
0
class SimpleDoc(Document):
    f_str = fields.StringField()
    f_url = fields.URLField()
    f_eml = fields.EmailField()
    f_int = fields.IntField()
    f_lng = fields.LongField()
    f_flt = fields.FloatField()
    f_dec = fields.DecimalField()
    f_bool = fields.BooleanField()
    f_dt = fields.DateTimeField()
    f_oid = fields.ObjectIdField()
    f_uuid = fields.UUIDField()
Пример #24
0
class Exercise(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    types = fields.StringField()
    problems = fields.ListField(fields.ReferenceField(Problem))
    final_results = fields.ListField(fields.IntField())
    allow_time = fields.IntField()
    publish_time = fields.DateTimeField()
    aim = fields.StringField()
    publisher = fields.ListField(fields.ReferenceField(People))
    targets = fields.ListField(fields.ReferenceField(Student))
    subject = fields.ReferenceField(Subject)
Пример #25
0
class Problem(Document):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    types = fields.StringField()
    description = fields.ListField(fields.StringField())
    images = fields.ListField(fields.ImageField())
    formula = fields.ListField(fields.StringField())
    sub = fields.ListField(fields.ReferenceField('Problem'))
    book = fields.ReferenceField('Book')
    chapter = fields.ReferenceField('Chapter')
    tags = fields.ListField(fields.ReferenceField('Tag'))
    solutions = fields.ListField(fields.ReferenceField('Solution'))
Пример #26
0
class Student(People):
    _id = fields.ObjectIdField()
    name = fields.StringField()
    effort = fields.IntField()
    frustration = fields.IntField()
    habits = fields.IntField()
    correction = fields.IntField()
    comprehension = fields.IntField()
    logics = fields.IntField()
    abstraction = fields.IntField()
    imagination = fields.IntField()
    summary = fields.IntField()
Пример #27
0
class UserToken(BaseDocument):
    user = fields.ObjectIdField()
    token = fields.StringField(max_length=512, required=True)
    expires_in = fields.IntField(default=-1)

    meta = {"auto_create_index": False, "indexes": [{"fields": ["$token"]}]}

    def __str__(self):
        return f"{self.token} {self.expires_in}"

    @property
    def user_object(self):
        return User.objects.filter(id=self.user).first()
Пример #28
0
class DBImageThumbnail(Document):
    DBImage = fields.ObjectIdField(required=True)
    file = fields.FileField(required=True)
    width = fields.IntField(required=True)
    height = fields.IntField(required=True)
    mime_type = fields.StringField(required=True)
    meta = {
        'max_documents': 200000,
        'indexes': [{
            'fields': ['DBImage'],
            'unique': True
        }]
    }
Пример #29
0
class Archivo(EmbeddedDocument):
    _id = fields.ObjectIdField(default=ObjectId)
    nombre = fields.StringField(required=True)
    tamaño = fields.IntField(required=True)
    extension = fields.StringField(required=True)
    fichero = fields.FileField()

    @property
    def size_to_mb(self):
        return round((self.tamaño / 1048576), 2)

    @property
    def id_to_str(self):
        return str(self._id)
Пример #30
0
class CcUserVehicleInfo(Document):
    user_auth_id = fields.IntField(required=True, unique=True)
    user_vehicle_id = fields.ObjectIdField(required=False)  #needs to be true
    user_profile_id = fields.ObjectIdField(required=False)  #needs to be true
    user_account_id = fields.ObjectIdField(required=False)  #needs to be true
    cc_project_id = fields.ObjectIdField(required=True)
    cc_user_type_id = fields.ObjectIdField(required=False)  # needs to be true
    user_vehicle_vin_number = fields.IntField(required=True)
    user_vehicle_registration_number = fields.IntField(required=True)
    user_vehicle_registration_date = fields.DateTimeField()
    user_vehicle_others_info = fields.DynamicField(required=False)
    user_vehicle_odometer_history = fields.DynamicField(required=True)
    is_active = fields.BooleanField(default=False, required=False)
    created_by = fields.IntField(required=True)
    created_at = fields.DateTimeField()
    updated_by = fields.IntField(required=True)
    updated_at = fields.DateTimeField(default=datetime.utcnow)

    def save(self, *args, **kwargs):
        if not self.created_at:
            self.created_at = datetime.utcnow()

        return super(CcUserVehicleInfo, self).save(*args, **kwargs)