class PercentLibraryForState(Document): _totalLibraryForState = DictField(required=True) _totalLibrary = IntField(required=True) _createDate = DateTimeField(required=True) @property def total_library_for_state(self): return self._totalLibraryForState @total_library_for_state.setter def total_library_for_state(self, number): self._totalLibraryForState = number @property def total_library(self): return self._totalLibrary @total_library.setter def total_library(self, number): self._totalLibrary = number @property def create_date(self): return self._createDate @create_date.setter def create_date(self, number): self._createDate = number
class DecisionSignal(Document): created_at = DateTimeField(default=datetime.datetime.now) date = DateTimeField(default=datetime.datetime.now) processor_used = StringField(choices=ChannelNameChoices.choices) message = ReferenceField(Message) initial_price = DecimalField(precision=6) pair = StringField(choices=pairs_without_slash, required=True) take_profits = ListField() stop_loss = DictField() type = StringField(choices=DecisionSignalTypeChoices.choices) def clean(self): if self.pair is not None: self.pair = self.pair.replace('/', '').upper() return super(DecisionSignal, self).clean() def validate(self, clean=True): self.clean() if self.pair not in pairs_without_slash: raise IncorrectDecisionSignalPair(**{"pair": self.pair}) if self.message.type not in [ MessageTypeChoices.SIGNAL, MessageTypeChoices.SIGNAL_EXTRA ]: raise IncorrectDecisionSignalMessageType return super(DecisionSignal, self).validate(clean) def save(self, *args, **kwargs): return super(DecisionSignal, self).save(*args, **kwargs)
class Losers(Document): meta = {'collection': 'losers'} sport = StringField() week_end = DateTimeField() loser = StringField() scores = DictField() punishment = StringField(default='')
class UserSocialAuth(Document, UserSocialAuthMixin): """Social Auth association model""" user = ReferenceField(User) provider = StringField(max_length=32) uid = StringField(max_length=255, unique_with='provider') extra_data = DictField() @classmethod def get_social_auth_for_user(cls, user): return cls.objects(user=user) @classmethod def create_social_auth(cls, user, uid, provider): if not isinstance(type(uid), basestring): uid = str(uid) return cls.objects.create(user=user, uid=uid, provider=provider) @classmethod def username_max_length(cls): return UserSocialAuth.user_model().username.max_length @classmethod def user_model(cls): return User @classmethod def create_user(cls, username, email=None): # Empty string makes email regex validation fail if email == '': email = None return cls.user_model().objects.create_user(username=username, email=email)
class PerformedStep(EmbeddedDocument): name = StringField() description = StringField() status = StringField() jobs = ListField(ReferenceField(Job), default=list) params = DictField() step = ReferenceField('CodedStep')
class FilesStorage(Document): ''' class creates file storage model for entrt in MongoDb. Model saves unique key of uploaded files, loasded date, path for upload the file and realation entry author to the user ''' uniq_file_key = StringField(required=True) created = DateTimeField(default=datetime.datetime.now(), required=True) path_to_load = StringField(required=True) meta_data = DictField() author = ReferenceField(User) def generate_key(self): ''' method creates a unique key for file entry ''' self.uniq_file_key = str(uuid4()) def save(self): ''' method generates key before saved file model entry ''' try: self.generate_key() super().save() except Exception as e: raise e
class Ip(Observable): geoip = DictField() regex = r'(?P<search>((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.,](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\[?[.,]\]?(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\[?[.,]\]?(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b)\[?\.\]?){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(([0-9A-Fa-f]{1,4}:){0,5}:((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b)\[?\.\]){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(::([0-9A-Fa-f]{1,4}:){0,5}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b)\[?\.\]){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)))' version = IntField() exclude_fields = Observable.exclude_fields + ['version'] DISPLAY_FIELDS = Observable.DISPLAY_FIELDS + [("version", "IP version"), ("geoip__country", "Country"), ("geoip__city", "City")] ignore = iptools.IpRangeList( iptools.ipv4.BENCHMARK_TESTS, iptools.ipv4.BROADCAST, iptools.ipv4.DUAL_STACK_LITE, iptools.ipv4.IETF_PROTOCOL_RESERVED, iptools.ipv4.LINK_LOCAL, iptools.ipv4.LOOPBACK, iptools.ipv4.LOCALHOST, iptools.ipv4.MULTICAST, iptools.ipv4.MULTICAST_INTERNETWORK, iptools.ipv4.MULTICAST_LOCAL, iptools.ipv4.PRIVATE_NETWORK_10, iptools.ipv4.PRIVATE_NETWORK_172_16, iptools.ipv4.PRIVATE_NETWORK_192_168) @classmethod def is_valid(cls, match): value = refang(match.group('search')) return iptools.ipv4.validate_ip(value) or iptools.ipv6.validate_ip( value) def normalize(self): self.value = refang(self.value) if iptools.ipv4.validate_ip(self.value): self.value = iptools.ipv4.hex2ip(iptools.ipv4.ip2hex(self.value)) self.version = 4 elif iptools.ipv6.validate_ip(self.value): self.value = iptools.ipv6.long2ip(iptools.ipv6.ip2long(self.value)) self.version = 6
class PercentAgentsForState(Document): _totalAgentsForStates = DictField(required=True) _totalAgents = IntField(required=True) _createDate = DateTimeField(required=True) @property def total_agents_for_states(self): return self._totalAgentsForStates @total_agents_for_states.setter def total_agents_for_states(self, number): self._totalAgentsForStates = number @property def total_agents(self): return self._totalAgents @total_agents.setter def total_agents(self, number): self._totalAgents = number @property def create_date(self): return self._createDate @create_date.setter def create_date(self, number): self._createDate = number
class PercentAgentsPerAreaOperation(Document): _totalAgentsPerAreaOreration = DictField(required=True) _totalAgents = IntField(required=True) _createDate = DateTimeField(required=True) @property def total_agents_per_area_oreration(self): return self._totalAgentsPerAreaOreration @total_agents_per_area_oreration.setter def total_agents_per_area_oreration(self, number): self._totalAgentsPerAreaOreration = number @property def total_agents(self): return self._totalAgents @total_agents.setter def total_agents(self, number): self._totalAgents = number @property def create_date(self): return self._createDate @create_date.setter def create_date(self, number): self._createDate = number
class Campaign(Document): user_id = ObjectIdField(required=True) name = StringField(required=True) created_at = DateTimeField(default=datetime.datetime.now()) status = BaseField(default='draft', choices=['draft', 'published']) state = DictField()
class VariantSetMetadata(Document, CreateAndSaveMixin): key = StringField(unique_with="variant_set") value = StringField() type = StringField() # The number of values that can be included in a field described by this # metadata. number = IntField() description = StringField() info = DictField() variant_set = ReferenceField("VariantSet") @classmethod def create(cls, key, value, type, variant_set, number=None, description=None, info=None): return cls(key=key, value=value, type=type, description=description, info=info, variant_set=variant_set)
class SavedSearch(CritsDocument, CritsSchemaDocument, DynamicDocument): """ savedSearch class """ meta = { "collection": "saved_search", "crits_type": "saved_search", "latest_schema_version": 1, "schema_doc": {} } name = StringField(required=True) dashboard = ObjectIdField(required=True) tableColumns = ListField(required=True) sortBy = DictField(required=False) searchTerm = StringField(required=False) objType = StringField(required=False) top = IntField(required=False, default=-1) left = IntField(required=False, default=-1) width = IntField(required=False) maxRows = IntField(required=False) isDefaultOnDashboard = BooleanField(required=True, default=False) isPinned = BooleanField(required=True, default=True) def getSortByText(self): textString = "None" if self.sortBy: for col in self.tableColumns: if col["field"] == self.sortBy["field"]: textString = col["caption"] + " - " + self.sortBy['direction'].upper() break; return textString
class PercentLibraryPerAreaOfActivity(Document): _totalLibraryPerAreaOfActivity = DictField(required=True) _totalLibrary = IntField(required=True) _createDate = DateTimeField(required=True) @property def total_library_per_area_of_activity(self): return self._totalLibraryPerAreaOfActivity @total_library_per_area_of_activity.setter def total_library_per_area_of_activity(self, number): self._totalLibraryPerAreaOfActivity = number @property def total_library(self): return self._totalLibrary @total_library.setter def total_library(self, number): self._totalLibrary = number @property def create_date(self): return self._createDate @create_date.setter def create_date(self, number): self._createDate = number
class PercentLibrariesTypeSphere: _totalLibrariesTypeSphere = DictField(required=True) _totalLibrary = IntField(required=True) _createDate = DateTimeField(required=True) @property def _total_libraries_type_sphere(self): return self._totalLibrariesTypeSphere @_total_libraries_type_sphere.setter def _total_libraries_type_sphere(self, number): self._totalLibrariesTypeSphere = number @property def total_library(self): return self._totalLibrary @total_library.setter def total_library(self, number): self._totalLibrary = number @property def create_date(self): return self._createDate @create_date.setter def create_date(self, number): self._createDate = number
class Event(Document): """ Stores the experimental data. All events point to RunStart, in other words, to RunStart serves as an entry point for all events. Within each event, one can access both RunStart and EventDescriptor. Make sure an event does not exceed 16 MB in size. This is essential since this tool is geared for metadata only. If more storage is required, please use fileStore. Attributes ---------- descriptor : mongoengine.DynamicDocument EventDescriptor foreignkey uid : str Globally unique identifier for this Event seq_num: int Sequence number to identify the location of this Event in the Event stream data: dict Dict of lists that contain e.g. data = {'motor1': [value, timestamp]} time : float The event time. This maybe different than the timestamps on each of the data entries """ descriptor = ReferenceField(EventDescriptor, reverse_delete_rule=DENY, required=True, db_field='descriptor_id') uid = StringField(required=True, unique=True) seq_num = IntField(min_value=0, required=True) # TODO validate on this better data = DictField(required=True) time = FloatField(required=True) meta = {'indexes': ['-descriptor', '-_id', '-uid'], 'db_alias': ALIAS}
class Host(Document): id = StringField(default="", primary_key=True) name = StringField(default="") worker_api = StringField(default="") create_ts = DateTimeField(default=datetime.datetime.now) status = StringField(default="active") type = StringField(default="") log_level = StringField(default=LOG_LEVEL.INFO.name) log_type = StringField(default="") log_server = StringField(default="") autofill = BooleanField(default=False) schedulable = BooleanField(default=False) capacity = IntField(default=0) clusters = ListField(default=[]) vcparam = DictField(default={}) k8s_param = DictField(default={})
class UserModel(db.Document): username = db.StringField(required=True, max_length=200, min_length=3) first_name = db.StringField(required=True, max_length=200, min_length=3) last_name = db.StringField(required=True, max_length=200, min_length=3) email = db.EmailField(required=True, max_length=200, min_length=10, unique=True) password = db.StringField(required=False, max_length=200, min_length=5) user_id = db.StringField(required=True, max_length=20, min_length=3, unique=True) fb_id = db.StringField(max_length=200, min_length=3) hospital_id = db.StringField(max_length=200, min_length=3) referenceID = db.StringField(max_length=200, min_length=3) plan_id = db.StringField(max_length=200, min_length=3) contexts = db.ListField() is_verified = db.BooleanField(default=False) is_active = db.BooleanField(default=False) is_on_plan = db.BooleanField(default=False) created_at = db.DateTimeField(default=datetime.datetime.now()) session_ids = db.ListField() has_sent_first_message = db.BooleanField(default=False) is_temp_user = db.BooleanField(default=True) has_hospital = db.BooleanField(default=False) temp_id = db.StringField(max_length=20, min_length=3) reg_num = db.StringField(max_length=50, min_length=3) last_seen = db.DateTimeField(default=datetime.datetime.now()) drug_use_reminders = DictField() awaiting_message = db.BooleanField(default=False) normanName = db.StringField(max_length=200, min_length=3)
class MongoTaskResults(EmbeddedDocument): """Document with the most important results produced by the AbiPy |Task|""" #meta = {'allow_inheritance': True} #: The initial input structure for the calculation in the pymatgen json representation #initial_structure = DictField(required=True) initial_structure = MSONField(required=True) #: The final relaxed structure in a dict format. final_structure = DictField(required=True) @classmethod def from_task(cls, task): # TODO Different Documents depending on task.__class__ or duck typing? #initial_structure = MSONField().to_mongo(task.input.structure.as_dict()) initial_structure = task.input.structure.as_dict() #print(type(initial_structure)) final_structure = initial_structure if hasattr(task, "open_gsr"): with task.open_gsr() as gsr: final_structure = gsr.structure.as_dict() new = cls( initial_structure=initial_structure, final_structure=final_structure, ) return new
class Document(Base): uid = StringField() order_id = StringField() title = StringField(fulltext=True, sortable=True) description = StringField(fulltext=True) note = StringField(fulltext=True) origination = StringField() help_required = IntField(default=0) date = DateTimeField(datetime_format='date') date_begin = DateTimeField(datetime_format='date') date_end = DateTimeField(datetime_format='date') date_text = StringField() category = ListField(ReferenceField('Category', deref_document=True)) tags = ListField(StringField()) files = ListField(ReferenceField('File', deref_document=True)) address = StringField() postcode = StringField() locality = StringField() lat = FloatField() lon = FloatField() georeferencePrecision = StringField() georeferenceDone = DateTimeField(datetime_format='datetime') extra_fields = DictField(delete_document=True) document_type = StringField() def __repr__(self): return '<Document %r>' % self.title
class CoinGeckoCoin(Document): id = StringField(), symbol = StringField(), name = StringField(), image = StringField(), current_price = FloatField(), market_cap = FloatField(), market_cap_rank = IntField(), fully_diluted_valuation = IntField(), total_volume = IntField(), high_24h = FloatField(), low_24h = FloatField(), price_change_24h = FloatField(), price_change_percentage_24h = FloatField(), market_cap_change_24h = IntField(), market_cap_change_percentage_24h = FloatField(), circulating_supply = IntField(), total_supply = IntField(), max_supply = IntField(), ath = FloatField(), ath_change_percentage = FloatField(), ath_date = DateTimeField(), atl = FloatField(), atl_change_percentage = FloatField(), atl_date = DateTimeField(), roi = DictField(default={}), last_updated = DateTimeField() price_change_percentage_14d_in_currency = FloatField(), price_change_percentage_1h_in_currency = FloatField(), price_change_percentage_24h_in_currency = FloatField(), price_change_percentage_30d_in_currency = FloatField(), price_change_percentage_7d_in_currency = FloatField()
class Location(Document, OParlDocument): type = 'https://schema.oparl.org/1.0/Location' description = StringField(fulltext=True) geojson = DictField() streetAddress = StringField() room = StringField() postalCode = StringField() subLocality = StringField() locality = StringField() body = ListField(ReferenceField('Body', dbref=False, deref_location=False), default=[]) person = ListField(ReferenceField('Person', dbref=False, deref_location=True), default=[]) organization = ListField(ReferenceField('Organization', dbref=False, deref_location=True), default=[]) meeting = ListField(ReferenceField('Meeting', dbref=False, deref_location=True), default=[]) paper = ListField(ReferenceField('Paper', dbref=False, deref_location=True), default=[]) license = StringField() keyword = ListField(StringField(fulltext=True), default=[]) created = DateTimeField(datetime_format='datetime') modified = DateTimeField(datetime_format='datetime') web = StringField() deleted = BooleanField() # Politik bei Uns Felder originalId = StringField(vendor_attribute=True) mirrorId = StringField(vendor_attribute=True) autogenerated = BooleanField(vendor_attribute=True) street = ReferenceField('Street', vendor_attribute=True, delete_street=False, deref_paper_location=False, deref_street=False) streetNumber = ReferenceField('StreetNumber', vendor_attribute=True, delete_street=False, deref_paper_location=False, deref_street=False) locationType = StringField( vendor_attribute=True) # could be street, address, point-of-interest region = ReferenceField('Region', vendor_attribute=True) # Felder zur Verarbeitung _object_db_name = 'location' _attribute = 'location' def __init__(self, *args, **kwargs): super(Document, self).__init__(*args, **kwargs) def __repr__(self): return '<Location %r>' % self.streetAddress
class EmailValidationTx(Document): transactionId = StringField(max_length=40) email = StringField(max_length=128) did = StringField(max_length=128) status = StringField(max_length=32) reason = StringField(max_length=128) isEmailSent = BooleanField() verifiableCredential = DictField() created = DateTimeField() modified = DateTimeField(default=datetime.datetime.utcnow) def __repr__(self): return str(self.as_dict()) def as_dict(self): return { "transactionId": str(self.transactionId), "did": self.did, "email": self.email, "status": self.status, "reason": self.reason, "isEmailSent": self.isEmailSent, "verifiableCredential": self.verifiableCredential, "created": str(self.created), "modified": str(self.modified) } def save(self, *args, **kwargs): if not self.created: self.created = datetime.datetime.utcnow() self.modified = datetime.datetime.utcnow() return super(EmailValidationTx, self).save(*args, **kwargs)
class Posts(Document): title = StringField(db_field='blog-title-test') url = StringField() content = StringField() metatag = DictField() categorys = ListField() authors = ListField() status = StringField() updated_at = DateTimeField() created_at = DateTimeField() meta = { 'collection': 'custom-post-collection', 'auto_create_index': True, 'index_background': True, 'indexes': [{ 'name': 'status', 'fields': ( 'status', 'created_at', ) }, { 'name': 'url', 'fields': ('url', ), 'unique': True }] }
class Notification(Document): icum_face_id = StringField(requred=False) msg = StringField(max_length=500, required=True) msg_type = StringField(max_length=15, required=False) attributes = DictField() meta = { 'collection': 'notifications', 'ordering': ['-_id'], 'auto_create_index': True, 'strict': False } def to_eventhub_json(self): res = { 'url': 'http://icumistercontrolpanel.azurewebsites.net' + url_for('show_notification', notification_id=str(self.id)), 'msg': self.msg, 'type': self.msg_type if self.msg_type else 'unknown', 'timestamp': str(datetime.datetime.now()), 'time_elapsed': 5 } return res
class CachedAPIValue(Document): """Data storage for cached API results.""" meta = dict( allow_inheritance = False, collection = "APICache", indexes = [ dict(fields=['key', 'name', 'arguments'], unique=True), dict(fields=['expires'], expireAfterSeconds=0) ] ) key = IntField() name = StringField(max_length=200) arguments = StringField() # Stores a hash of the arguments. expires = DateTimeField() result = DictField() def __repr__(self): return "CachedAPIValue(%s, %s)" % (self.name, self.key or "-") @classmethod def current(cls): return cls.objects(expires__gte=datetime.utcnow()) @classmethod def expired(cls): return cls.objects(expires__lt=datetime.utcnow())
class UASZone(Document): identifier = StringField(required=True, primary_key=True, max_length=7) country = StringField(min_length=3, max_length=3, required=True) name = StringField(max_length=200) type = StringField(choices=CodeZoneType.choices(), required=True) restriction = StringField(choices=CodeRestrictionType.choices(), max_length=200, required=True) restriction_conditions = ListField(StringField(), db_field='restrictionConditions') region = IntField(min_value=0, max_value=0xffff) reason = ListField(StringField(choices=CodeZoneReasonType.choices()), max_length=9) other_reason_info = StringField(max_length=30) regulation_exemption = StringField(choices=CodeYesNoType.choices()) u_space_class = StringField(db_field='uSpaceClass', choices=CodeUSpaceClassType.choices(), max_length=100) message = StringField(max_length=200) zone_authority = EmbeddedDocumentField(Authority, db_field='zoneAuthority', required=True) applicability = EmbeddedDocumentField(TimePeriod) geometry = EmbeddedDocumentListField(AirspaceVolume, required=True) extended_properties = DictField(db_field='extendedProperties') user = ReferenceField(User, required=True) def clean(self): if self.user is not None: self.user = _get_or_create_user(self.user)
class Hackathon(HDocumentBase): name = StringField(unique=True, required=True) display_name = StringField(required=True) ribbon = StringField() # a short sentence of advertisement short_description = StringField() location = StringField() description = StringField() banners = ListField() status = IntField(default=0) # 0-new 1-online 2-offline 3-apply-online creator = ReferenceField(User) config = DictField() # max_enrollment, auto_approve, login_provider type = IntField(default=1) # enum.HackathonType organizers = EmbeddedDocumentListField(Organization) tags = ListField() awards = EmbeddedDocumentListField(Award) templates = ListField(ReferenceField(Template, reverse_delete_rule=PULL)) # templates for hackathon azure_keys = ListField(ReferenceField(AzureKey)) event_start_time = DateTimeField() event_end_time = DateTimeField() registration_start_time = DateTimeField() registration_end_time = DateTimeField() judge_start_time = DateTimeField() judge_end_time = DateTimeField() archive_time = DateTimeField() def __init__(self, **kwargs): super(Hackathon, self).__init__(**kwargs)
class AccountAction(BaseDocument): """ 动作链表 """ choices = ('ACTION', 'CRAWL', 'WATCH', 'CREATE') start_url = StringField(max_length=128, required=True) # 起始url source_id = ObjectIdField() # 平台id account_source = ReferenceField('AccountSource', required=True) # 所属平台 action_name = StringField(max_length=64, unique_with='source_id') # 描述行为的名称 action_type = StringField(choices=choices) # 动作链的类型 action_config = DictField(required=True) # 页面动作的全json crawl_elements = DictField() # 爬虫的爬取元素 data_download_settings = DictField() # 爬虫数据存储位置的配置 file_download_settings = DictField() # 爬虫文件下载的配置 create_time = FloatField(required=True) # 创建时间 status = StringField(choices=('ENABLE', 'DISABLE'), default='ENABLE') # 状态
class Importer(Document): """ Defines schema for a pulp 2 importer in the `repo_importers` collection. """ repo_id = StringField(required=True) importer_type_id = StringField(required=True) config = DictField() scratchpad = DictField(default=None) # not used in the migration plugin last_sync = StringField() # not used in the migration plugin last_updated = DateTimeField() last_override_config = DictField() # not used in the migration plugin # For backward compatibility _ns = StringField(default="repo_importers") meta = {"collection": "repo_importers", "allow_inheritance": False}
class Task(DynamicDocument): created_at = DateTimeField(default=datetime.now()) completed_at = DateTimeField(default=None) status = StringField(default="pending") instruction = StringField() deadLine = DateTimeField() params = DictField() type = StringField()