示例#1
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'
class Tweet(Document):
    user = fields.ReferenceField(Users, dbref=True)
    tweetedOn = fields.DateTimeField(default=datetime.datetime.now)
    hashtags = fields.ListField()
    lang = fields.StringField()
    retweet_count = fields.IntField()
    text = fields.StringField()
示例#3
0
class Corso(Document):
    """
    Definizione del corso
    """
    codice_edizione = fields.StringField(primary_key=True, max_length=10)
    denominazione = fields.StringField(max_length=150)
    ordine = fields.ReferenceField('OrdineProduzione')
    data_inizio = fields.DateTimeField()
    data_fine = fields.DateTimeField()
    durata = fields.IntField(default=8, min_value=1)
    note = fields.StringField(max_length=1000)
    partecipanti = fields.IntField(default=16, min_value=1)
    docente = fields.StringField()
    cartella_corso = fields.BooleanField(default=False)
    stato = fields.IntField(min_value=0,
                            default=CartelleCorsoTask.STATO_ATTESA_LAVORAZIONE)

    lezioni = fields.ListField(EmbeddedDocumentField(Lezione))

    class Meta:
        verbose_name = "Corso"
        verbose_name_plural = "Corsi"

    def __str__(self):
        return self.codice_edizione + ' ' + self.denominazione

    def clean(self):
        """
            Validazione del modello nel suo complesso.
        """
        print("Inizio la validazione")

        # La durata del corso deve essere di almeno un'ora.
        """
        if self.durata < 2:
            raise ValidationError(field_name='Adurata', message="Must be louder!")
            #message='La durata del corso deve essere positiva.')
        self.errors = kwargs.get('errors', {})
        self.field_name = kwargs.get('field_name')
        self.message = message
        """

        # La data di inizio deve essere maggiore o uguale a quella di fine.
        #if self.data_fine < self.data_inizio:
        #    raise ValidationError({'data_fine': 'La data di fine corso deve essere maggiore o uguale a quella '
        #                                        'di inizio corso.'})
        self.codice_edizione = self.codice_edizione.upper()
示例#4
0
class Signalrun(OrionDocument, Status):
    """Signalrun object.

    The Signalrun object represents a single executions of a Pipeline on a Signal
    within a Datarun.

    It contains information about whether the execution was successful or not, when
    it started and ended, the number of events that were found by the Pipeline, and
    where the model and metrics are stored.
    """
    datarun = fields.ReferenceField(Datarun, reverse_delete_rule=CASCADE)
    signal = fields.ReferenceField(Signal, reverse_delete_rule=CASCADE)
    start_time = fields.DateTimeField()
    end_time = fields.DateTimeField()
    model_location = fields.StringField()
    metrics_location = fields.StringField()
    num_events = fields.IntField(default=0)

    @property
    def events(self):
        return Event.find(signalrun=self)

    def start(self):
        """Mark this Signalrun as started on DB.

        The ``start_time`` will be set to ``datetime.utcnow()``,
        the ``status`` will be set to RUNNING.
        """
        self.start_time = datetime.utcnow()
        self.status = self.STATUS_RUNNING
        self.save()

    def end(self, status, events):
        """Mark this Signalrun as ended on DB.

        The ``end_time`` will be set to ``datetime.utcnow()``, the ``status``
        will be set to the given value, and the given events will be inserted
        into the Database.
        """
        try:
            if events is None:
                events = []
            for start_time, stop_time, severity in events:
                Event.insert(
                    signalrun=self,
                    signal=self.signal,
                    start_time=start_time,
                    stop_time=stop_time,
                    severity=severity,
                    source=Event.SOURCE_ORION,
                )
        except Exception:
            LOGGER.exception('Error storing signalrun %s events', self.id)
            status = self.STATUS_ERRORED

        self.end_time = datetime.utcnow()
        self.status = status
        self.num_events = len(events)
        self.save()
示例#5
0
class Collection(IIIFModel):
    # PROPERTIES FOR INTERNAL USE
    name = fields.StringField(
        required=True,
        unique=True,
        regex=valid_name,
        help_text=("The name of this IIIF Collection.")
    )

    # TECHNICAL PROPERTIES
    ATtype = fields.StringField(
        required=True,
        default='sc:Collection',
        regex=valid_type,
        help_text=("The type of this IIIF resource. Must be: sc:Collection.")
    )
    navDate = fields.StringField(
        null=True,
        help_text=("A date that the client can use for navigation purposes when presenting the resource to the user in a time-based user interface, such as a calendar or timeline. The value must be an xsd:dateTime literal in UTC, expressed in the form YYYY-MM-DDThh:mm:ssZ.")
    )

    # PAGING PROPERTIES
    first = fields.StringField(
        null=True,
        help_text=("A link from a resource with pages, such as a collection or layer, to its first page resource, another collection or an annotation list respectively. The page resource should be referenced by just its URI (from @id) but may also have more information associated with it as an object.")
    )
    last = fields.StringField(
        null=True,
        help_text=("A link from a resource with pages to its last page resource. The page resource should be referenced by just its URI (from @id) but may also have more information associated with it as an object.")
    )
    next = fields.StringField(
        null=True,
        help_text=("A link from a page resource to the next page resource that follows it in order. The resource should be referenced by just its URI (from @id) but may also have more information associated with it as an object.")
    )
    prev = fields.StringField(
        null=True,
        help_text=("A link from a page resource to the previous page resource that precedes it in order. The resource should be referenced by just its URI (from @id) but may also have more information associated with it as an object.")
    )
    total = fields.IntField(
        null=True,
        help_text=("The total number of leaf resources, such as annotations within a layer, within a list of pages. The value must be a non-negative integer.")
    )
    startIndex = fields.IntField(
        null=True,
        help_text=("The 0 based index of the first included resource in the current page, relative to the parent paged resource. The value must be a non-negative integer.")
    )
示例#6
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()
示例#7
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)))
示例#8
0
class employee_details(Document):
    name = fields.StringField(required=True)
    contact = fields.IntField(required=True)

    def employee_details(self):
        val = employee_details.objects.all()
        print(val)
        return employee_details.objects.all()
示例#9
0
class Tweet(Document):
    tweet_id = fields.IntField()
    text = fields.StringField()
    media = fields.StringField()
    binary_file = fields.BinaryField()
    username = fields.StringField()
    type = fields.StringField()
    created_at = fields.DateTimeField(null=False)
示例#10
0
class Tool(Document):
    label = fields.StringField(required=True)
    description = fields.StringField(required=True, null=True)
    level = fields.IntField(required=True)
    inputs = fields.ListField(fields.EmbeddedDocumentField(ToolInput))

    def __str__(self):
        return self.label
示例#11
0
class Person(mongoengine.Document):
    """A human person.

    A Person has one Member for each Congress.
    """

    born: t.Optional[int] = fields.IntField()
    biography: t.Optional[str] = fields.StringField()
    id: str = fields.StringField()
    bioguide_id: t.Optional[str] = fields.StringField()
    died: t.Optional[int] = fields.IntField()
    bioname: str = fields.StringField()
    _id = fields.ObjectIdField()
    icpsr_list = fields.ListField(fields.IntField())
    last_updated = fields.DateTimeField()

    meta = {"collection": "voteview_persons", "strict": False}
示例#12
0
class User(Document):

    username = fields.StringField(required=True)
    email = fields.EmailField(required=True, )
    firstname = fields.StringField(required=True)
    lastname = fields.StringField(required=True, null=True)
    status = fields.IntField(required=True, default=1)
    userdetails = ListField(EmbeddedDocumentField('UserDetails'))
示例#13
0
class Page(Document):
    url = fields.StringField(required=True)
    dom_origin = fields.StringField(required=True)
    dom_origin_md5 = fields.StringField(required=True)
    dom_reduce_md5 = fields.StringField(required=True)
    leaves_node = fields.IntField(required=True)
    max_depth = fields.IntField(required=True)
    histogram_color = fields.StringField(required=True)
    full_screen = fields.StringField(required=True)
    test_screen = fields.StringField(required=False)
    listElement = fields.ListField(fields.EmbeddedDocumentField(Element),
                                   required=False)
    compare_img1 = fields.StringField(required=False, null=True)
    compare_img2 = fields.StringField(required=False, null=True)

    class Meta:
        app_label = 'no_sql'
示例#14
0
class Comment(EmbeddedDocument):
    """
    """
    name = fields.StringField()
    comment = fields.StringField()
    timestamp = fields.DateTimeField(default=datetime.utcnow().replace(
        tzinfo=utc))
    helpfulRating = fields.IntField(default=0)
    reported = fields.IntField(default=0)

    def toJSType(self):
        return dict(name=self.name,
                    comment=self.comment,
                    timestamp=json.dumps(self.timestamp,
                                         default=json_util.default),
                    helpfulRating=self.helpfulRating,
                    reported=self.reported)
示例#15
0
class Combat(mongoengine.Document):
    mongoengine.connect(db='mop',
                        host='mongodb://mongo_main:27017/mop',
                        alias='campaigns')
    meta = {'collection': 'mop_combat', 'db_alias': 'campaigns'}

    turn_list = fields.ListField(fields.ReferenceField('Turn'))
    active_turn = fields.IntField()
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__()
示例#17
0
class Carreras(Document):
    id = fields.ObjectId
    temporada = fields.IntField(required=False)
    categoria = fields.StringField(required=False)
    abreviatura = fields.StringField(required=False)
    titulo = fields.StringField(required=False)
    lugar = fields.StringField(required=False)
    fecha = fields.DateTimeField(required=False)
    pos = fields.IntField(required=False)
    puntos = fields.IntField(required=False)
    num = fields.IntField(required=False)
    piloto = fields.StringField(required=False)
    pais = fields.StringField(required=False)
    equipo = fields.StringField(required=False)
    moto = fields.StringField(required=False)
    kmh = fields.FloatField(required=False)
    diferencia = fields.StringField(required=False)
示例#18
0
class DetalleUnitario(EmbeddedDocument):
    cantidad_unitaria = fields.IntField()
    nombre_sub_presentacion = fields.StringField(max_length=35)
    unidad_medida = fields.StringField(max_length=20)
    precio_unidad = fields.FloatField()

    def __str__(self):
        return self.nombre_sub_presentacion
示例#19
0
文件: models.py 项目: grimpy/hexa-a
class ResetToken(BaseModel):
    user = fields.ReferenceField(User, required=True)
    email = fields.EmailField(unique=True, required=True)
    salt = fields.StringField(required=True)
    secret = fields.StringField(required=True)
    created_at = fields.IntField(required=True)
    # db collection
    meta = {"collection": "reset_tokens"}
class clothe_images(Document):
    category = fields.StringField(required=False)
    brand = fields.StringField(required=False)
    product_code = fields.StringField(required=False)
    price = fields.IntField(required=False)
    image_path = fields.StringField(required=False)
    size_fit_information = fields.StringField(required=False)
    editors_notes = fields.StringField(required=False)
示例#21
0
class Network(Document):
    id = fields.IntField(required=True, primary_key=True)
    name = fields.StringField(required=True, max_length=200)
    phone = fields.StringField()
    url = fields.StringField()
    image = fields.StringField()
    created_at = fields.DateTimeField()
    modified_at = fields.DateTimeField(default=datetime.datetime.utcnow())
class UniqueTogetherModel(Document):
    meta = {
        'indexes': [
            {'fields': ['name', 'code'], 'unique': True}
        ]
    }
    name = fields.StringField()
    code = fields.IntField()
示例#23
0
 class Schema1Doc1(Document):
     doc1_int = fields.IntField()
     doc1_str = fields.StringField()
     doc1_str_empty = fields.StringField()
     doc1_str_ten = fields.StringField(choices=[str(x) for x in range(11)])
     doc1_float = fields.FloatField()
     doc1_int_empty = fields.IntField()
     doc1_long = fields.LongField()
     doc1_decimal = fields.DecimalField()
     doc1_complex_datetime = fields.ComplexDateTimeField()
     doc1_list = fields.ListField()
     doc1_ref_self = fields.ReferenceField('self')
     doc1_cachedref_self = fields.CachedReferenceField('self')
     doc1_emb_embdoc1 = fields.EmbeddedDocumentField('Schema1EmbDoc1')
     doc1_emb_embdoc2 = fields.EmbeddedDocumentField('Schema1EmbDoc2')
     doc1_emblist_embdoc1 = fields.EmbeddedDocumentListField('Schema1EmbDoc1')
     doc1_emblist_embdoc2 = fields.EmbeddedDocumentListField('Schema1EmbDoc2')
示例#24
0
class Attack(Skill):
    def __str__(self):
        return 'Attack'

    attack_multiplier = fields.StringField()
    defense_multiplier = fields.StringField()
    attack_range = fields.IntField()
    attack_dices = fields.ListField(fields.StringField())
示例#25
0
 def get_field(self):
     """
     Return *Field instance
     """
     name = str(self.name)
     if self.is_table:
         if self.type == "str":
             l = self.max_length if self.max_length else 256
             return models.CharField(
                 name=name,
                 db_column=self.db_column,
                 null=True, blank=True,
                 max_length=l, choices=self.get_enums())
         elif self.type == "int":
             return models.IntegerField(
                 name=name,
                 db_column=self.db_column,
                 null=True, blank=True)
         elif self.type == "bool":
             return models.BooleanField(
                 name=name,
                 db_column=self.db_column,
                 default=False)
         elif self.type == "date":
             return models.DateField(
                 name=name,
                 db_column=self.db_column,
                 null=True, blank=True)
         elif self.type == "datetime":
             return models.DateTimeField(
                 name=name,
                 db_column=self.db_column,
                 null=True, blank=True)
         else:
             raise NotImplementedError
     else:
         if self.type == "str":
             return fields.StringField(
                 db_field=self.db_column,
                 required=False
             )
         elif self.type == "int":
             return fields.IntField(
                 db_field=self.db_column,
                 required=False
             )
         elif self.type == "bool":
             return fields.BooleanField(
                 db_field=self.db_column,
                 required=False
             )
         elif self.type in ("date", "datetime"):
             return fields.DateTimeField(
                 db_field=self.db_column,
                 required=False
             )
         else:
             raise NotImplementedError
示例#26
0
class InvoicingNumberingSettings(EmbeddedDocument):
    """A wrapper to Invoicing's module numbering settings."""
    SCHEMES = (("DN", _("Date, Number")), ("N", _("Number")))
    DATE_FORMATS = (("Ymd", _("YYYYMMDD")), ("dmY", _("DDMMYYYY")),
                    ("ymd", _("YYMMDD")), ("dmy", _("DDMMYY")), ("Ym",
                                                                 _("YYYYMM")),
                    ("mY", _("MMYYYY")), ("ym", _("YYMM")), ("my", _("MMYY")),
                    ("Y", _("YYYY")), ("y", _("YY")))
    DATE_STRFTIME_FORMATS = {
        "Ymd": "%Y%m%d",
        "dmY": "%d%m%Y",
        "ymd": "%y%m%d",
        "dmy": "%d%m%y",
        "Ym": "%Y%m",
        "mY": "%m%Y",
        "ym": "%y%m",
        "my": "%m%y",
        "Y": "%Y",
        "y": "%y"
    }
    SEPARATORS = (("", _("No separator")), ("-", _("- (dash)")),
                  ("_", _("_ (underscore)")), (".", _(". (dot)")),
                  (":", _(": (colon)")), ("::", _(":: (bi-colon)")),
                  ("/", _("/ (slash)")), ("#", _("# (sharp)")))

    scheme = fields.StringField(required=True, choices=SCHEMES, default="DN")
    separator = fields.StringField(required=True,
                                   choices=SEPARATORS,
                                   default="-")
    date_format = fields.StringField(required=True,
                                     choices=DATE_FORMATS,
                                     default="Ym")
    all_time_quotation_counter = fields.IntField(required=True,
                                                 min_value=1,
                                                 default=1)
    all_time_purchase_order_counter = fields.IntField(required=True,
                                                      min_value=1,
                                                      default=1)
    all_time_invoice_counter = fields.IntField(required=True,
                                               min_value=1,
                                               default=1)
    all_time_credit_note_counter = fields.IntField(required=True,
                                                   min_value=1,
                                                   default=1)
    fy_quotation_counter = fields.IntField(required=True,
                                           min_value=1,
                                           default=1)
    fy_purchase_order_counter = fields.IntField(required=True,
                                                min_value=1,
                                                default=1)
    fy_invoice_counter = fields.IntField(required=True, min_value=1, default=1)
    fy_credit_note_counter = fields.IntField(required=True,
                                             min_value=1,
                                             default=1)
    fy_reset = fields.BooleanField(required=True, default=True)
示例#27
0
class Player(Document):
    name = fields.StringField(required=True, null=False)
    photo_url = fields.StringField(required=True, null=True)
    positions = fields.ListField(fields.StringField(required=True, null=True))
    age = fields.StringField(required=True)
    birth_date = fields.StringField(required=True)
    height = fields.IntField(required=True)
    weight = fields.IntField(required=True)
    overall_rating = fields.IntField(required=True)
    potential = fields.IntField(required=True)
    value = fields.StringField(required=True)
    wage = fields.StringField(required=True)
    preferred_foot = fields.StringField(required=True)
    international_reputation = fields.IntField(required=True)
    weak_foot = fields.IntField(required=True)
    skill_moves = fields.IntField(required=True)
    work_rate = fields.StringField(required=True)
    body_type = fields.StringField(required=True)
    real_face = fields.StringField(required=True)
    release_clause = fields.StringField(default='0')
    player_hashtags = fields.ListField(
        fields.StringField(required=True, null=True))
    social = fields.EmbeddedDocumentField(PlayerSocial)
    skills = fields.EmbeddedDocumentField(PlayerSkills)
    player_traits = fields.ListField(fields.StringField(null=True), null=True)
示例#28
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)
示例#29
0
        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()
示例#30
0
class Documentacion(Document):
    id = fields.ObjectId
    temporada = fields.IntField(required=False)
    categoria = fields.StringField(required=False)
    abreviatura = fields.StringField(required=False)
    titulo = fields.StringField(required=False)
    lugar = fields.StringField(required=False)
    fecha = fields.StringField(required=False)
    documentacion = fields.ListField()