class RoleBase(Document):
    role_name = fields.StringField(required=True, unique=True)
    description = fields.StringField(required=False, null=True)
    creation_date = fields.DateTimeField(default=timezone.now(), null=True)
    created_by = fields.StringField(null=True)
    last_updated_date = fields.DateTimeField(default=timezone.now(), null=True)
    last_updated_by = fields.StringField(null=True)
Пример #2
0
class User(Document):
    meta = {
        "indexes": [
            'email',
        ]
    }

    id = fields.UUIDField(primary_key=True, binary=False)
    username = fields.StringField(required=True, max_length=50)
    email = fields.EmailField(required=True, unique=True)
    password = fields.StringField(required=True)
    role = fields.StringField(default="user")
    active = fields.BooleanField(default=True)
    created_at = fields.DateTimeField(default=datetime.datetime.utcnow())
    modified_at = fields.DateTimeField(default=datetime.datetime.utcnow())

    def get_id(self):
        return self.id.__str__()

    def dict(self):
        return {
            'id': self.get_id(),
            'username': self.username,
            'email': self.email,
            'role': self.role,
            'active': self.active
        }
Пример #3
0
class Drink(Document):
    '''
    Represents a single drink.
    '''
    modified = fields.DateTimeField(default=datetime.datetime.now())

    # Meta
    created_by_user = fields.IntField()
    drink_id = fields.StringField()
    ## Information
    # The canonical name of the drink
    #   Will be shown on the page
    name = fields.StringField()
    maker = fields.StringField()

    # Distillery, brewery, etc
    maker_type = fields.StringField()
    drink_type = fields.StringField()

    # Actual bottled year, i.e., 1996
    age = fields.IntField()
    # Exact Date drink released to the public
    release_date = fields.DateTimeField(default=datetime.datetime.now())
    # Manufacturer's description, often listed on the bottle
    manu_desc = fields.StringField()
Пример #4
0
class SubTask(Document):
    """"""
    task = fields.ReferenceField('Task',
                                 required=True,
                                 unique=True,
                                 reverse_delete_rule=mongoengine.CASCADE)
    created_on = fields.DateTimeField()
    modified_on = fields.DateTimeField(default=datetime.datetime.now())
    task_parent = fields.ReferenceField('Task',
                                        required=False,
                                        null=True,
                                        blank=True,
                                        unique=False)
    sub_task = fields.ListField(fields.ReferenceField(
        'Task',
        required=False,
        null=True,
        reverse_delete_rule=mongoengine.PULL),
                                blank=True)

    def save(self, *args, **kwargs):
        if not self.created_on:
            self.created_on = datetime.datetime.now()
        self.modified_on = datetime.datetime.now()
        return super(SubTask, self).save(*args, **kwargs)
Пример #5
0
class Project(DynamicDocument):
    '''
    Project model with following attributes
    project_name = String
    project_uid = String
    owned_by = String
    project_description = String
    created_at = DateTime
    date_modified = DateTime
    start_date = Date
    estimated_completion_date = Date
    actual_completion_date = Date
    status = String
    activity_timeline = Activity
        
    '''

    project_name = fields.StringField()
    project_uid = fields.StringField()
    owned_by = fields.StringField()
    project_description = fields.StringField()
    created_at = fields.DateTimeField()
    date_modified = fields.DateTimeField()
    start_date = fields.DateTimeField()
    estimated_completion_date = fields.DateTimeField()
    actual_completion_date = fields.DateTimeField()
    status = fields.StringField()
    activity = fields.ListField(EmbeddedDocumentField(Activity))
Пример #6
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)
Пример #7
0
class Project_Profile(Document):
    name = fields.StringField(required=True, unique=True)
    description = fields.StringField(required=False, null=True)
    creation_date = fields.DateTimeField(default=timezone.now(), null=True)
    created_by = fields.StringField()
    last_updated_date = fields.DateTimeField(default=timezone.now(), null=True)
    last_updated_by = fields.StringField()   
Пример #8
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)
Пример #9
0
class Historico_Parametros(DynamicDocument):
    PROPIEDAD_ID = fields.LazyReferenceField(Usuarios,
                                             passthrough=False,
                                             dbref=False)
    TIPO = fields.StringField(required=True)
    FECHA_DESDE = fields.DateTimeField(default=datetime.datetime.utcnow)
    FECHA_HASTA = fields.DateTimeField(default=datetime.datetime.utcnow)
Пример #10
0
class ChargeStation(Document):
    meta = {
        "indexes": [
            'network',
            'locationId',
        ]
    }
    id = fields.IntField(required=True, primary_key=True)
    network = fields.ReferenceField(Network)
    locationId = fields.IntField(required=True)
    name = fields.StringField(required=True, max_length=200)

    #0 = Unknown
    #1 = Free
    #2 = Fee
    cost = fields.IntField()
    cost_description = fields.StringField(max_length=1000)
    address = fields.StringField(max_length=300)
    available = fields.IntField(required=True)
    hours = fields.StringField(max_length=400)
    geoLocation = fields.PointField(auto_index=True)
    score = fields.FloatField(min_value=0, max_value=10.0, required=True)
    images = fields.ListField(fields.URLField())
    chargePoints = fields.ListField(fields.ReferenceField(ChargePoint))
    created_at = fields.DateTimeField()
    modified_at = fields.DateTimeField(default=datetime.datetime.utcnow())
Пример #11
0
class CcUserProfile(Document):

    user_auth_id = fields.IntField(required=False)
    first_name = fields.StringField(required=False)
    last_name = fields.StringField(required=False)
    mobile_no = fields.StringField(required=False)
    email = fields.EmailField(required=False)
    gender = fields.IntField(required=False)
    alternate_number = fields.StringField(required=False)
    is_profile_verified = fields.DynamicField(required=False)
    cc_src_type_id = fields.IntField(null=True, required=False)
    cc_project_id = fields.IntField(required=False)
    cc_default_profile = fields.BooleanField(required=False)
    profile_type = fields.IntField(required=False)
    profile_others_info = fields.DynamicField(required=False)
    profile_max_lock_limit = fields.IntField(required=False)
    is_profile_active = fields.BooleanField(required=False)
    country_id = fields.StringField(null=True, required=False)
    state_id = fields.StringField(null=True, required=False)
    city_id = fields.StringField(null=True, required=False)
    area_id = fields.IntField(null=True, required=False)
    cc_user_type_id = fields.IntField(null=True, required=False)
    is_active = fields.BooleanField(default=False, required=False)
    created_by = fields.IntField(required=False)
    created_at = fields.DateTimeField(required=False)
    updated_by = fields.IntField(required=False)
    updated_at = fields.DateTimeField(default=datetime.utcnow)

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

        return super(CcUserProfile, self).save(*args, **kwargs)
Пример #12
0
class Activity(Document):
    url_number = fields.IntField()
    name = fields.StringField(verbose_name=u'活动名称')
    detail = fields.StringField(verbose_name=u'活动详情')
    creator = fields.GenericReferenceField()  # 发起社团

    start_time = fields.DateTimeField()
    finish_time = fields.DateTimeField()
    place = fields.StringField(verbose_name=u'活动地点')
    max_student = fields.IntField()  # 人数上限

    pay = fields.IntField(verbose_name=u'人均花费')

    who_likes = fields.ListField(
        fields.ReferenceField(Student, reverse_delete_rule=PULL))  # 喜欢活动的人
    who_entered = fields.ListField(
        fields.ReferenceField(Student, reverse_delete_rule=PULL))  # 参加这个活动的人
    clicks = fields.IntField()  # 点击数
    is_active = fields.BooleanField()

    def description(self):
        return self.creator.corporation.name + "发起了" + self.name

    def is_started(self):  # 判断是否已经开始
        if self.finish_time < datetime.datetime.now():
            return True
        else:
            return False

    def get_reply(self):
        from reply.models import Reply
        return Reply.objects(target=self)
Пример #13
0
class Article(DocumentMixin, DynamicDocument):
    meta = {"collection": "articles", "indexes": ["ID", "category.ID"]}

    ID = fields.IntField()

    title = fields.StringField()
    alias = fields.StringField()

    category = fields.EmbeddedDocumentField(Category, null=True)

    created = fields.DateTimeField(null=True)
    updated = fields.DateTimeField(null=True)

    @classmethod
    def from_instance(cls, instance):

        if instance.category is not None:
            category = Category.from_instance(instance.category)
        else:
            category = None

        return cls(
            ID=instance.id,
            title=instance.title,
            alias=instance.alias,
            created=instance.created,
            updated=instance.updated,
            category=category,
        )
Пример #14
0
class InteractionLog(document.Document):
    meta = {
        "collection": "noc.log.sa.interaction",
        "allow_inheritance": False,
        "indexes": [
            ("object", "-timestamp"),
            {
                "fields": ["expire"],
                "expireAfterSeconds": 0
            }
        ]
    }

    OP_COMMAND = 0
    OP_LOGIN = 1
    OP_LOGOUT = 2
    OP_REBOOT = 3
    OP_STARTED = 4
    OP_HALTED = 5
    OP_CONFIG_CHANGED = 6

    timestamp = fields.DateTimeField()
    expire = fields.DateTimeField()
    object = fields.IntField()
    user = fields.StringField()
    op = fields.IntField()
    text = fields.StringField()

    def __unicode__(self):
        return str(self.id)
Пример #15
0
class Task(Document):
    """"""
    name = fields.StringField(required=True)
    description = fields.StringField()
    start_date = fields.DateField()
    end_date = fields.DateField()
    phase = fields.StringField(choices=PHASES_CHOICE, required=True)
    project = fields.ReferenceField('Project',
                                    required=True,
                                    reverse_delete_rule=mongoengine.CASCADE)
    assignee = fields.ReferenceField('User',
                                     required=True,
                                     reverse_delete_rule=mongoengine.CASCADE)
    reporter = fields.ReferenceField('User',
                                     reverse_delete_rule=mongoengine.NULLIFY)
    comments = fields.StringField(null=True)
    created_on = fields.DateTimeField()
    modified_on = fields.DateTimeField(default=datetime.datetime.now())
    parent_task = fields.ReferenceField(
        'self',
        required=False,
        blank=True,
        null=True,
        reverse_delete_rule=mongoengine.CASCADE)

    def save(self, *args, **kwargs):
        if not self.created_on:
            self.created_on = datetime.datetime.now()
        self.modified_on = datetime.datetime.now()
        return super(Task, self).save(*args, **kwargs)
Пример #16
0
class Goods(Document):
    source = fields.StringField(max_length=50)
    goods_id = fields.StringField(max_length=64)
    goods_url = fields.StringField(max_length=1024, unique=True)
    title = fields.StringField(max_length=1024)
    goods_type = fields.StringField(max_length=50)
    country = fields.StringField(max_length=100)
    link = fields.StringField(max_length=1024)
    mobile_link = fields.StringField(max_length=1024)
    image_link = fields.StringField(max_length=1024)
    images = fields.ListField(fields.StringField(max_length=1024))
    availability = fields.StringField(max_length=100)
    availability_date = fields.StringField(max_length=100)
    price = fields.StringField(max_length=100)
    sale_price = fields.FloatField()
    sale_price_effective_date = fields.StringField(max_length=100)
    brand = fields.StringField(max_length=100)
    material = fields.StringField(max_length=100)
    pattern = fields.StringField(max_length=100)
    shipping = fields.StringField(max_length=100)
    shipping_weight = fields.StringField(max_length=100)
    shipping_label = fields.StringField(max_length=100)
    multipack = fields.StringField(max_length=100)
    sku = fields.ListField(fields.EmbeddedDocumentField(Sku))
    specs = fields.ListField(fields.EmbeddedDocumentField(Specs))
    description = fields.StringField(max_length=1024)
    offer = fields.DateTimeField(Offer)
    price_history = fields.ListField(
        fields.EmbeddedDocumentField(PriceHistory))
    pub_date = fields.DateTimeField(default=datetime.datetime.now)
Пример #17
0
class Analysis(Document):
    meta = {
        "db_alias": "stream_db"
    }
    tweet_id = fields.IntField()
    text = fields.StringField()
    clean_text = fields.ListField()
    user_name = fields.StringField()
    user_id = fields.IntField()
    user_screen_name = fields.StringField()
    user_location = fields.StringField()
    user_created_at = fields.DateTimeField()
    user_description = fields.StringField()
    user_followers_count = fields.IntField()
    user_friends_count = fields.IntField()
    user_statuses_count = fields.IntField()
    user_favourites_count = fields.IntField()
    create_date = fields.DateTimeField()
    create_date_timestamp_ms = fields.IntField()
    source = fields.StringField()
    media_type = fields.DynamicField()
    is_quote_status = fields.BooleanField()
    retweet_count = fields.IntField()
    favorite_count = fields.IntField()
    user_mentions = fields.ListField()
    hashtags = fields.ListField()
Пример #18
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()
Пример #19
0
class User(Document):
    email = fields.EmailField(unique=True)
    password = fields.StringField()
    name = fields.StringField()
    profile = fields.URLField()
    acquisition_date = fields.DateTimeField()
    last_login = fields.DateTimeField()
    boards = fields.ListField(fields.LazyReferenceField('Board'))
Пример #20
0
class TimeStampedModel(Document):
    created_at = fields.DateTimeField(default=timezone.now)
    updated_at = fields.DateTimeField(default=timezone.now)

    meta = {'abstract': True}

    class Meta:
        app_label = 'no_sql'
Пример #21
0
class VehiculoTemporalField(EmbeddedDocument):
    TIPO = fields.StringField(required=True)
    MARCA = fields.StringField(required=True)
    REFERENCIA = fields.StringField(required=True)
    COLOR = fields.StringField(required=True)
    PLACA = fields.StringField(required=True)
    FECHA_INICIO = fields.DateTimeField(default=datetime.datetime.utcnow)
    FECHA_FIN = fields.DateTimeField(default=datetime.datetime.utcnow)
Пример #22
0
class AsignacionPHField(EmbeddedDocument):
    ROL = fields.StringField(required=True)
    FECHA_INICIO = fields.DateTimeField(default=datetime.datetime.utcnow)
    FECHA_FIN = fields.DateTimeField(default=datetime.datetime.utcnow)
    PROPIEDAD_ID = fields.LazyReferenceField('Propiedades_Horizontales',
                                             passthrough=False,
                                             dbref=False)
    HABILITADO = fields.BooleanField()
Пример #23
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())
Пример #24
0
class Page(document.Document):
    url = fields.StringField(required=True, max_length=6000, unique=True)
    parsed = fields.DateTimeField(required=False)
    created = fields.DateTimeField(default=datetime.datetime.utcnow)

    meta = {'queryset_class': PageQuerySet}

    def parsed_now(self):
        self.parsed = datetime.datetime.utcnow()
Пример #25
0
class ModeUsage(Document):
    """Модель 'Использование режима'."""

    user = fields.ReferenceField(User,
                                 reverse_delete_rule=CASCADE,
                                 required=True)
    mode_id = fields.IntField(required=True)
    date_start = fields.DateTimeField(required=True)
    date_end = fields.DateTimeField(required=False)
Пример #26
0
class ControllerState(db.Document):
    state_update = fields.DateTimeField(
        required=True, default=lambda: datetime.datetime.now())
    mm_state = fields.StringField(required=True,
                                  default=lambda: MaintenanceState.NONE)
    em_state = fields.StringField(required=True,
                                  default=lambda: MaintenanceState.NONE)
    em_due = fields.DateTimeField()
    mm_due = fields.DateTimeField()
Пример #27
0
class MessageTuring(EmbeddedDocument):
    """
    
    Scénarios:
        0. Impossibilité turing
            - Pas de destinataire valide (from/x-from...)
        
        1. Envoi d'un mail de vérification
            - Mail délivré OK
            - Mail non délivré
                - Erreur 5xx
                - Erreur 4xx
        
        2a. Débloquage par confirmation expéditeur
        
        2b. Débloquage par anulation turing par destinataire ou admin
        
        2c. Dépassement de délai
        
        N. Ajout info turing au rapport quotidien envoyé au destinataire
    
    Document créé quand un MessageStore est placé en turing queue = MESSAGE_QUEUE_TURING
    
    TODO: Action/Tâche d'envoi de mail à l'expéditeur
    
    TODO: Envoi de mail récapitulatif au(x) destinataire ?
    
    TODO: Actions suite à validation : 
    
    - Ajout de l'expéditeur (email ?, domain ?, ip ?) en liste blanche
    - Livrer le mail
    - Marquer pour purge le mail et le turing
    """

    key = fields.StringField(required=True)

    created_date = fields.DateTimeField(default=utils.timestamp)

    #durée de validité ? A calculer selon settings
    mail_date = fields.DateTimeField()

    #TODO: mettre dans constants
    mail_status = fields.IntField(choices=(
        (0, gettext(u"Unsent")),
        (1, gettext(u"Sent")),
        (2, gettext(u"Unrecoverable error")),
        (3, gettext(u"Temporary error")),
        (9, gettext(u"Turing canceled")),
    ))

    valid_date = fields.DateTimeField(verbose_name=gettext(u"Validation Date"))

    #IP à partir de laquelle le turing à été validé
    valid_ip = fields.StringField()

    def __unicode__(self):
        return self.key
Пример #28
0
class Noticias(DynamicDocument):
    PROPIEDAD_ID = fields.LazyReferenceField(Propiedades_Horizontales, passthrough=False, dbref=False)
    TITULO = fields.StringField(required=True)
    MENSAJE = fields.StringField(required=True)
    IMAGEN = fields.FileField()
    TIPO = fields.StringField(required=True)
    FECHA_INICIO = fields.DateTimeField(default=datetime.datetime.utcnow)
    FECHA_FIN = fields.DateTimeField(default=datetime.datetime.utcnow)
    HABILITADO = fields.BooleanField()
Пример #29
0
class Issue(Document):
    name = fields.StringField(max_length=20)
    tags = fields.ListField(fields.ReferenceField(Tag))
    description = fields.StringField()
    createdAt = fields.DateTimeField()
    resolved = fields.DateTimeField()
    vehicle = fields.ReferenceField(Vehicle)

    meta = {'collection': 'issues'}
Пример #30
0
class BaseDocument(db.Document):

    #ex: demo values
    internal_field = fields.IntField(default=0)

    #trash
    mark_for_delete = fields.IntField(default=0)

    active = fields.BooleanField(default=True)

    created = fields.DateTimeField(default=utils.utcnow)

    updated = fields.DateTimeField()

    @classmethod
    def _count(cls, **kwargs):
        return cls.objects(**kwargs).count()

    @classmethod
    def _find(cls, **kwargs):
        return cls.objects(**kwargs)

    @classmethod
    def _find_one(cls, **kwargs):
        print("!!find one : ", kwargs)
        return cls._find(**kwargs).first()

    @classmethod
    def _create(cls, **kwargs):
        return cls(**kwargs).save()

    @classmethod
    def _update(cls, doc=None, **kwargs):
        return doc.update(**kwargs)
        #return doc

    @classmethod
    def _delete(cls, doc=None):
        return doc.delete()

    def get_pk(self):
        return self.pk()

    def as_dict(self):
        return self.to_mongo().to_dict()

    def as_json(self):
        return self.to_json()

    def save(self, **kwargs):
        if self.pk:
            self.last_updated = utils.utcnow()
        return db.Document.save(self, **kwargs)

    meta = {
        'abstract': True,
    }