示例#1
0
class QuestionModel(db.DynamicDocument):
    """
    正常使用的题目 question
    """
    text = db.StringField(max_length=40960)
    level = db.IntField(min_value=1, max_value=10)
    q_type = db.IntField(min_value=1, max_value=6)  # type是留字,可能会有一些坑,故使用q_type
    # 1 朗读 2 复述 3 问答 4 选择 5 短文本英文阅读 6 长文本英文阅读
    used_times = db.IntField(min_value=0, default=0)
    up_count = db.IntField(min_value=0, default=0)  # 疑似废弃字段?feedback_ups 替代
    down_count = db.IntField(min_value=0,
                             default=0)  # 疑似废弃字段?feedback_downs 替代
    wordbase = db.DictField(default={})
    weights = db.DictField(default={})
    questions = db.ListField(default=None)  # 选择题集合可以包含若干选择题
    index = db.IntField(min_value=0)  # 题号,从0开始
    in_optimize = db.BooleanField(default=False)  # 现在是否在优化中
    last_optimize_time = db.DateTimeField(default=None)  # 最后优化时间
    auto_optimized = db.BooleanField(default=False)  # 是否被自动优化过
    feedback_ups = db.IntField(default=0)  # 短时重复切换状态时,请求可能不按顺序到达,可能短时间内<0
    feedback_downs = db.IntField(default=0)
    feedback_likes = db.IntField(default=0)

    meta = {'collection': 'questions'}

    def __str__(self):
        return "{id:%s,text:%s,level:%s,q_type:%s,used_times:%s,wordbase:%s}" % (
            self.id, self.text.__str__(), self.level.__str__(),
            self.q_type.__str__(), self.used_times.__str__(),
            self.wordbase.__str__())
示例#2
0
class Hospital(db.Document):
    name = db.StringField()
    email = db.StringField()
    password = db.StringField()
    address = db.StringField()
    location = db.DictField(db.StringField())
    blood_units = db.DictField(db.FloatField())

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.email

    def create(self, obj):
        self.name = obj["name"]
        self.email = obj["email"]
        self.password = obj["password"]
        self.blood_units = obj["blood_units"]
        self.address = obj["address"]
        self.location = obj["location"]
示例#3
0
class CurrentQuestionEmbed(db.EmbeddedDocument):
    """
    用户做题的题目 current.question[x]
    """
    q_id = db.StringField(max_length=32)
    q_type = db.IntField(min_value=1, max_value=3)
    q_text = db.StringField(max_length=512)
    file_location = db.StringField(max_length=32)
    wav_upload_url = db.StringField(max_length=256)
    wav_temp_url = db.StringField(max_length=256)
    # status: "none|question_fetched|url_fetched|handling|finished",finished 由docker设置
    status = db.StringField(max_length=32, default="none")
    analysis_start_time = db.DateTimeField()
    feature = db.DictField(default={})
    score = db.DictField(default={})  # score field may has a set of scores
    analysis_end_time = db.DateTimeField()
    stack = db.StringField(max_length=1024)
    analysed = db.BooleanField()  # 这个回答是否被分析过

    # 默认没有get函数,手动添加支持
    def get(self, key, default=None):
        if hasattr(self, key):
            return getattr(self, key)
        else:
            return default
示例#4
0
文件: models.py 项目: Qupid/WebQ
class Document(db.Document):
    url = db.StringField()
    title = db.StringField()
    snippet = db.StringField()
    sentiment = db.DecimalField()# db.EmbeddedDocumentField('Sentiment')
    emotion = db.DictField() #db.EmbeddedDocumentField('Emotion') #db.DictField()
    entities = db.ListField(db.DictField())
    trustworthiness = db.DecimalField()
    source = db.StringField()
示例#5
0
class Shop(db.Document):
    name = db.StringField(required=True)
    slug = db.StringField()
    nit = db.StringField(required=True, unique=True)
    email = db.EmailField(required=True, unique=True)
    phone = db.IntField(required=True, unique=True)
    address = db.DictField()
    shipping = db.DictField()
    categories = db.ReferenceField(Category)
示例#6
0
class Products(db.Document):
    name = db.StringField()
    slug = db.StringField(required=True)
    description = db.StringField()
    image = db.DictField()
    extras = db.DictField()
    preco = db.DictField()
    category = db.StringField()
    shop = db.StringField()
class Tokens(db.EmbeddedDocument):
    def __init__(self, arena=None, messenger=None):
        if arena:
            self.arena = arena
        if messenger:
            self.messenger = messenger

    meta = {'strict': False}
    messenger = db.DictField()  #format {"token":   , "expiry":     }
    arena = db.DictField()  #format {"token":   , "expiry":     }
示例#8
0
class OptimizeModel(db.DynamicDocument):
    question_num = db.IntField(min_value=0, default=-1)
    wordbase = db.DictField(default={})
    weights = db.DictField(default={})
    key_history_cost = db.ListField(db.FloatField(default=0))
    detail_history_cost = db.ListField(db.FloatField(default=0))
    complete_time = db.DateTimeField(
        default=lambda: datetime.datetime.utcnow())
    finish = db.BooleanField(default=True)
    meta = {'collection': 'optimize'}
示例#9
0
class ItemSpec(db.Document):
    """"""
    meta = {
        'db_alias':
        'db_inventory',
        'indexes': [
            'item_id',
            'web_sku',
            'sku',
            'price',
            'original_price',
            'availability',
            'attributes',
            'created_at',
            'stock',
        ],
        'ordering': ['price']
    }

    item_id = db.IntField(required=True)
    sku = db.SequenceField(required=True, unique=True, primary_key=True)
    web_sku = db.StringField(required=True)

    images = db.ListField(db.StringField(required=True))

    original_price = db.FloatField(required=True, min_value=0)
    price = db.FloatField(required=True, min_value=0)
    china_prive = db.FloatField(default=0, min_value=0)

    availability = db.BooleanField(default=True, required=True)
    stock = db.IntField(default=-1)

    # spec.attributes: {color: 'Blue', size: 'M'}
    attributes = db.DictField()
    shipping_info = db.DictField()

    created_at = db.DateTimeField(default=datetime.utcnow, required=True)
    modified = db.DateTimeField()

    url = db.StringField()
    extra = db.DictField(default={})

    @property
    def item(self):
        return Item.objects(item_id=self.item_id).first()

    def __unicode__(self):
        return '{}'.format(self.sku)

    def update_spec(self, new_spec):
        for k, v in new_spec.items():
            setattr(self, k, v)
        self.save()
示例#10
0
class Animals(db.Document):
    title = db.StringField(required=True, max_length=30, min_length=1)
    route = db.StringField(required=True, max_length=25, min_length=1)
    categories = db.ReferenceField(Categories)
    description = db.MapField(db.EmbeddedDocumentField(DescriptionItem))
    descriptionExtended = db.MapField(
        db.EmbeddedDocumentField(DescriptionItem))
    contact = db.DictField()
    address = db.DictField()
    conditions = db.DictField()
    pageText = db.StringField(required=True, max_length=500, min_length=1)
    adjective = db.StringField(required=True, max_length=50, min_length=1)
    images = db.ListField()
示例#11
0
class Stream(db.Document):
    #     __tablename__ = 'sensors'
    #     id = db.Column(db.Integer, primary_key=True)
    #     name = db.Column(db.String(64), index=True)
    #     items = db.relationship('Item', backref='sensor', lazy='dynamic')
    created_at = db.DateTimeField(default=datetime.now(), required=True)
    sensor_id = db.StringField(max_length=255, required=True)
    sensor_data = db.DictField()

    def __repr__(self):
        return '<Stream %r>' % self.idd

    def get_url(self):
        return url_for('api.get_stream',
                       idd=str(self.sensor_id),
                       _external=True)

    def export_data(self):
        return {
            'self_url': self.get_url(),
            'sensor_id': self.sensor_id,
            'sensor_data': self.sensor_data,
        }

    def import_data(self, data):
        try:
            self.sensor_id = data['sensor_id']
            self.sensor_data = data['sensor_data']
        except KeyError as e:
            raise ValidationError('Invalid stream: missing ' + e.args[0])
        return self
示例#12
0
class Job(db.DynamicDocument):
    task_information = db.StringField()

    model_file = db.StringField()
    model_meta_file = db.StringField()

    vocabulary = db.StringField()
    num_training_examples_in_model = db.IntField()

    checkpoints = db.DictField()

    current_hit_ids = db.ListField()

    status = db.StringField()

    control_strategy = db.StringField()

    experiment_id = db.StringField()

    mturk_connection = db.StringField()

    exceptions = db.ListField()

    control_data = db.StringField()

    logging_data = db.StringField()
class User(db.Document):
    username = db.StringField(db_field="user_name", required=True, unique=True)
    password = db.StringField(db_field="password", required=True)
    email = db.EmailField(db_field="email", required=True, unique=True)
    first_name = db.StringField(db_field="first_name", max_length=50)
    last_name = db.StringField(db_field="last_name", max_length=50)
    created_at = db.IntField(db_field="created_at", default=utc_now_ts())
    bio = db.StringField(db_field="bio", max_length=160)
    # confirm user email after register
    email_confirmed = db.BooleanField(db_field="email_confirmed",
                                      default=False)
    # the files will be changed and need confirm
    change_configuration = db.DictField(db_field="change_config")
    avatar = db.StringField(db_field="avatar", default=None)

    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        document.username = document.username.lower()
        document.email = document.email.lower()

    def profile_imgsrc(self, size):
        if self.avatar:
            return url_for('static',
                           filename=os.path.join(
                               'images', 'user',
                               '%s.%s.%s.png' % (self.id, self.avatar, size)))
        else:
            return url_for('static',
                           filename=os.path.join('images', 'user',
                                                 'no-profile.%s.png' % (size)))

    meta = {'indexes': ['username', 'email', '-created_at']}
class CONFIGURATIONS(db.Document):
    system_object = db.StringField(max_length=255, required=True)
    system_object_id = db.StringField(max_length=255, required=True)
    created_date = db.DateTimeField(default=datetime.now)
    config = db.DictField()

    meta = {"db_alias": "DEV_BLANKSPIDER"}
示例#15
0
class User(db.Document):
    """The database uses mongoEngine and when called saves the user's details to the database"""

    username = db.StringField(db_field="u", required=True, unique=True)
    password = db.StringField(db_field="p", required=True)
    email = db.EmailField(db_field="e", required=True, unique=True)
    first_name = db.StringField(db_field="fn", max_length=50)
    last_name = db.StringField(db_field="ln", max_length=50)
    created = db.IntField(db_field="c", default=time_stamp())
    bio = db.StringField(db_field="b", max_length=150)
    email_confirmed = db.BooleanField(db_field="ec", default=False)
    change_configuration = db.DictField(db_field="cc")
    profile_image = db.StringField(db_field="pi", default=None)

    def profile_image_src(self, size):
        """profile_image_src(str) -> return img path

           The profile function allows the user of the application to fetch the path
           of the desired image which will then be rendered to by the application

          :param
             size: Takes a string relating to the size of image
        """
        if self.profile_image:
            return join_path(
                STATIC_IMAGE_URL, 'users',
                "{}.{}.{}.png".format(self.id, self.profile_image,
                                      size)).replace("\\", '/')
        return join_path(STATIC_IMAGE_URL, "users",
                         "no_profile.jpg").replace("\\", '/')

    meta = {"indexes": ["username", "email", "-created"]}
示例#16
0
class StoresDB(db.Document):
    """"""

    store_id = db.StringField(required=True)
    store_name = db.StringField(db_field='sn', max_length=30, required=True, unique=True)
    description = db.StringField(db_field='d', max_length=900, required=True)
    url_prefix = db.URLField(db_field='up', required=True, unique=True)
    tag_name = db.StringField(db_field='tn', required=True)
    query = db.DictField(db_field='q', required=True)
    predefined_store = db.BooleanField(db_field='ps', default=False)
    mall = db.ReferenceField(MallDB, reverse_delete_rule=CASCADE)
    user = db.ReferenceField(UserDB, reverse_delete_rule=CASCADE)
    user_email = db.EmailField(db_field='ue')
    creation_date = db.DateTimeField(db_field='cd', default=time_now())

    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        """"""

        document.store_name = document.store_name.title()
        document.url_prefix = document.url_prefix.lower()
        document.tag_name = document.tag_name.lower()

    meta = {
        'indexes': ['store_name', 'url_prefix', 'store_id', 'predefined_store']
    }
示例#17
0
class User(db.DynamicDocument, db.EmbeddedDocument):
    user_id = db.IntField(required=True, unique=True)
    # user-friendly identificator
    email = db.StringField(required=True, unique=True)
    #  user-friendly name
    username = db.StringField(required=True, unique=True)
    password_hash = db.StringField(required=True)
    registered_at = db.DateTimeField(default=datetime.now, required=True)

    # store of subscribed channels and last viewed time
    unread_channels = db.DictField()

    # __init__ can't be function in inherited class from db.Document
    # def __init__(self, email, username, password):
    #     self.email = email
    #     self.username = username
    #     self.set_password(password)

    def __str__(self):
        return self.username

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.user_id

    def __repr__(self):
        return self.__str__()
示例#18
0
文件: models.py 项目: zqin/sarjitsu
class User(db.Document):
    username = db.StringField(max_length=20, unique=True, required=True)
    email = db.EmailField(unique=True, required=True)
    password = db.StringField(required=True)
    #reports =  db.ListField(db.EmbeddedDocumentField(Report))
    #ReferenceField(Report)
    reports = db.DictField()
示例#19
0
class Payment(db.Document):
    payment_id = db.IntField(required=True)
    amount = db.FloatField(min_value=0, required=True)
    order_id = db.StringField(required=True)
    receipt = db.StringField(required=True)
    user_id = db.IntField(min_value=0, required=True)
    extra = db.DictField(default={})
    razorpay_payment_id = db.StringField()
    razorpay_order_id = db.StringField()

    meta = {'collection': 'payments', 'indexes': ['payment_id']}

    def __repr__(self):
        return f'Payment(payment_id={self.payment_id})'

    @classmethod
    def add_document(cls, amount, user_id):
        next_id = Counter.get_next_sequence_value('payments')
        receipt = f'receipt_{next_id}_' + ''.join(
            random.choices(string.digits, k=6))
        payment = cls(payment_id=next_id,
                      amount=amount,
                      user_id=user_id,
                      receipt=receipt)

        return payment
示例#20
0
class Beacons(db.Document):
    beaconId = db.StringField(max_length=150, required=True, unique=True)
    beaconTag = db.StringField(max_length=15, required=True)
    beaconProject = db.StringField(max_length=50, required=True)
    beaconPlatform = db.StringField(max_length=25, required=True)
    beaconTimer = db.IntField(default=300)
    beaconData = db.DictField()
示例#21
0
class BeaconHistory(db.Document):
    beaconId = db.StringField(max_length=150, required=True)
    beaconTimestamp = db.DateTimeField(default=datetime.datetime.now)
    beaconIp = db.StringField(max_length=15)
    beaconData = db.DictField()

    meta = {'ordering': ['-beaconTimestamp']}
示例#22
0
class User(db.Document):
    username = db.StringField(db_field="username", required=True)
    first_name = db.StringField(db_field="firstname", max_length=50)
    last_name = db.StringField(db_field="lastname", max_length=50)
    passtmp = db.StringField(db_field="passtmp", required=True)
    password = db.StringField(db_field="password", required=True)
    starting_date = db.StringField(db_field="starting_date",
                                   default=utc_now_str())
    expiration_date = db.StringField(db_field="expiration_date",
                                     default=utc_now_str())
    role = db.StringField(db_field="role", default='student')
    address = db.DictField()
    contact = db.DictField()
    parent_info = db.DictField()

    meta = {'collection': 'users'}
示例#23
0
class ChannelProvider(db.Document):
    meta = {
        'db_alias': 'db_order',
    }
    name = db.StringField()
    display_name = db.StringField()
    description = db.StringField()
    service_intro = db.DictField()
    country = db.StringField()
    is_active = db.BooleanField(default=False)

    shipping = db.FloatField(required=True)
    is_recommended = db.BooleanField(default=False)

    def __repr__(self):
        return '<ChannelProvider {}>'.format(self.name)

    @classmethod
    def get_shipping(cls, channel_name, country):
        if not channel_name:
            channel_name = 'default'

        provider = cls.objects(name=channel_name, country=country).first()
        return provider.shipping

    @queryset_manager
    def active(doc_cls, queryset):
        return queryset.filter(is_active=True)

    def to_json(self):
        return dict(name=self.name,
                    display_name=self.display_name,
                    service_intro=self.service_intro,
                    desc=self.description)
示例#24
0
class ExpressRequestLog(db.Document):
    """"""
    created_at = db.DateTimeField(default=datetime.utcnow, required=True)
    company = db.StringField()
    number = db.StringField()
    respond = db.DictField()
    is_success = db.BooleanField()
class BtCurrentTestModel(db.DynamicDocument):
    """
    bt_current
    """
    user_id = db.StringField(max_length=32, default=None)
    openid = db.StringField(max_length=64,
                            default=None)  # wx_christmas2019活动使用
    test_start_time = db.DateTimeField()
    paper_type = db.ListField()
    current_q_num = db.IntField(min_value=1, default=1)
    score_info = db.DictField(default={})
    questions = db.DictField(default={})
    all_analysed = db.BooleanField()  # 这个考试中的所有回答是否都被分析过
    # make questions a dict rather than a list so as to be able update one question w/o affecting other questions

    meta = {'collection': 'bt_current'}
示例#26
0
class CivicAgency(db.Document):
    civic_agency_id = db.IntField()
    city_id = db.IntField()
    district_id = db.ObjectIdField()
    state_id = db.ObjectIdField()
    title = db.DictField()

    meta = {
        'collection':
        'civic_agencies',
        'indexes': [{
            'fields': ['civic_agency_id'],
            'unique': True,
            'name': 'civic_agencies_civic_agency_id_id_unique',
        }, {
            'fields': ['district_id'],
            'name': 'civic_agencies_district_id_index',
        }, {
            'fields': ['state_id'],
            'name': 'civic_agencies_state_id_index',
        }, {
            'fields': ['city_id'],
            'name': 'civic_agencies_city_id_index',
        }, {
            'fields': ['title.*'],
            'name': 'civic_agencies_title_index',
        }]
    }
示例#27
0
class City(db.Document):
    city_id = db.IntField()
    district_id = db.ObjectIdField()
    state_id = db.ObjectIdField()
    title = db.DictField()
    code = db.StringField(max_lenght=255)
    ward_count = db.IntField(default=0)
    population_bucket = db.IntField()
    population = db.IntField()
    census_code = db.IntField()
    coordinates = db.PointField()

    meta = {
        'collection':
        'cities',
        'indexes': [{
            'fields': ['city_id'],
            'unique': True,
            'name': 'cities_city_id_unique',
        }, {
            'fields': ['state_id'],
            'name': 'cities_state_id_index',
        }, {
            'fields': ['district_id'],
            'name': 'cities_district_id_index',
        }, {
            'fields': ['title.*'],
            'name': 'cities_title_index',
        }]
    }
示例#28
0
class Worker(db.DynamicDocument):
    platform_id = db.StringField()
    platform_name = db.StringField()

    # Mapping inference strategy -> result
    # Example format:
    # strategy : {'timestamp' : timestamp, 'skill' : skill_estimate}
    inference_results = db.DictField()
示例#29
0
class HistoryTestModel(db.DynamicDocument):
    """
    history
    TODO: 大部分内容和CurrentTestMode相同,是否可直接继承CurrentTestModel??
    """
    current_id = db.StringField(max_length=32, default=None)
    user_id = db.StringField(max_length=32, default=None)
    openid = db.StringField(default=None)
    test_start_time = db.DateTimeField()
    test_expire_time = db.DateTimeField()
    paper_type = db.ListField()
    paper_tpl_id = db.StringField(max_length=24, default=None)
    current_q_num = db.IntField(min_value=1, default=1)
    score_info = db.DictField(default={})
    questions = db.DictField(default={})
    all_analysed = db.BooleanField(default=False)  # 这个考试中的所有回答是否都被分析过

    meta = {'collection': 'history'}
示例#30
0
class User(db.Document):
    username = db.StringField(max_length=50, required=True)
    email = db.StringField(required=True)
    password = db.StringField(required=True)
    homepage = db.EmbeddedDocumentField(HomePage)
    role = db.StringField(max_length=20)
    status = db.StringField(max_length=10)
    session = db.DictField()  #db.StringField()
    tags = db.ListField(db.StringField(max_length=30))