class WithConditioning(Model): has_air_conditioning = BooleanField('aer condiţionat', default=False) has_fan = BooleanField('ventiloconvectoare', default=False) has_air_heater = BooleanField('aeroterme', default=False) class Meta: abstract = True
class Order(Base): complete = BooleanField(default=False) duration = IntegerField(null=True) # how long it took to process the order edited = BooleanField(default=False) # tells you whether they opened it for editing... not whether any actual edits were made end = DateTimeField(null=True) end_user_timezone = CharField(max_length=20, null=True) map_format = CharField(max_length=20, null=True) open_source = BooleanField(default=False) #is this map open-sourced, such that it can be included in open source training data? start = DateTimeField(auto_now_add=True, null=True) # it will never be null, but have to do this because migration asks for default otherwise style = ForeignKey("MapStyle", null=True, on_delete=SET_NULL) token = CharField(max_length=200, null=True, unique=True) # the random string that's used to find the order in the maps url = URLField(null=True, max_length=1000, unique=True) # URL if started from url or iframe embeded on a webpage def __str__(self): return self.token def d(self): self.delete_map() self.delete() def delete_map(self): rmtree("/home/usrfd/maps/" + self.token) def finish(self): self.complete = True self.end = end = datetime.now().replace(tzinfo=utc) self.duration = (end - self.start).total_seconds() self.save()
class WithDestination(Model): is_residential = BooleanField('rezidenţial', default=False) is_comercial = BooleanField('comercial', default=False) for_offices = BooleanField('birouri', default=False) for_vacation = BooleanField('de vacanţă', default=False) class Meta: abstract = True
class WithPrice(Model): not_include_vat = BooleanField('nu include TVA', default=False) price_details = TextField('alte detalii preţ', blank=True, default=None) zero_commission = BooleanField('comision 0%', default=False) buyer_commission = CharField('comision cumpărător', max_length=50, blank=True, default=None) class Meta: abstract = True
class WithInternetAccess(Model): has_wired_net = BooleanField('cablu', default=False) has_fiber = BooleanField('fibră optică', default=False) has_wireless = BooleanField('wireless', default=False) has_dial_up = BooleanField('dial-up', default=False) class Meta: abstract = True
class MediaType(Model): dtype = CharField(max_length=16, choices=[('image', 'image'), ('video', 'video'), ('multi', 'multi')]) project = ForeignKey(Project, on_delete=CASCADE, null=True, blank=True, db_column='project') name = CharField(max_length=64) description = CharField(max_length=256, blank=True) visible = BooleanField(default=True) """ Whether this type should be displayed in the UI.""" editTriggers = JSONField(null=True, blank=True) file_format = CharField(max_length=4, null=True, blank=True, default=None) keep_original = BooleanField(default=True, null=True, blank=True) default_volume = IntegerField(default=0) """ Default Volume for Videos (default is muted) """ attribute_types = JSONField(default=list, null=True, blank=True) """ User defined attributes. An array of objects, each containing the following fields: name: Name of the attribute. description: (optional) Description of the attribute. order: Order that the attribute should appear in web UI. Negative means do not display. dtype: Data type of the attribute. Valid values are bool, int, float, string, enum, datetime, geopos. default: (optional) Default value. Valid for all dtypes except datetime. The type should correspond to the dtype (string/enum are strings, int/float are numbers, geopos is a [lon, lat] list). minimum: (optional) Minimum value. Valid for int and float dtypes. maximum: (optional) Maximum value. Valid for int and float dtypes. choices: (optional) Available choices for enum dtype. labels: (optional) Labels for available choices for enum dtype. autocomplete: (optional) Object of the form {'serviceUrl': '<url>'} that specifies URL of the autocomplete service. Valid for string dtype only. use_current: (optional) Boolean indicating whether to use the current time as the default for datetime dtype. """ archive_config = JSONField(default=None, null=True, blank=True) streaming_config = JSONField(default=None, null=True, blank=True) overlay_config = JSONField(default=None, null=True, blank=True) """ Overlay configuration provides text overlay on video / image based on configruation examples: Example: {"mode": "constant", "source": "name"} Overlays file name Time example: {"mode": "datetime", "locale": [locale], "options" : [options]} options can contain 'timeZone' which comes from the TZ database name https://en.wikipedia.org/wiki/List_of_tz_database_time_zones Example: America/Los_Angeles or America/New_York """ def __str__(self): return f'{self.name} | {self.project}'
class StateType(Model): dtype = CharField(max_length=16, choices=[('state', 'state')], default='state') project = ForeignKey(Project, on_delete=CASCADE, null=True, blank=True, db_column='project') name = CharField(max_length=64) description = CharField(max_length=256, blank=True) visible = BooleanField(default=True) """ Whether this type should be displayed in the UI.""" grouping_default = BooleanField(default=True) """ Whether to group elements in the UI by default.""" media = ManyToManyField(MediaType) interpolation = CharField(max_length=16, choices=[('none', 'none'), ('latest', 'latest')], default='latest') association = CharField(max_length=64, choices=AssociationTypes, default=AssociationTypes[0][0]) attribute_types = JSONField(default=list, null=True, blank=True) """ User defined attributes. An array of objects, each containing the following fields: name: Name of the attribute. description: Description of the attribute. order: Order that the attribute should appear in web UI. Negative means do not display. dtype: Data type of the attribute. Valid values are bool, int, float, string, enum, datetime, geopos. default: (optional) Default value. Valid for all dtypes except datetime. The type should correspond to the dtype (string/enum are strings, int/float are numbers, geopos is a [lon, lat] list). minimum: (optional) Minimum value. Valid for int and float dtypes. maximum: (optional) Maximum value. Valid for int and float dtypes. choices: (optional) Available choices for enum dtype. labels: (optional) Labels for available choices for enum dtype. autocomplete: (optional) Object of the form {'serviceUrl': '<url>'} that specifies URL of the autocomplete service. Valid for string dtype only. use_current: (optional) Boolean indicating whether to use the current time as the default for datetime dtype. style: (optional) String of GUI-related styles. """ delete_child_localizations = BooleanField(default=False) """ If enabled, child localizations will be deleted when states of this type are deleted. """ def __str__(self): return f'{self.name} | {self.project}'
class WithBuildingInfo(Model): has_basement = BooleanField('are subsol', default=False) has_semi_basement = BooleanField('are demisol', default=False) has_ground_floor = BooleanField('parter', default=True) levels_nr = PositiveIntegerField('nr. niveluri', blank=True, default=None) has_mansard = BooleanField('mansardă', default=False) building_year = PositiveIntegerField('an finalizare construcţie', blank=True, default=None) building_period = CharField('perioada construire', max_length=10, choices=BuildingPeriod.choices, blank=True, default=None) resistance_structure = CharField('structura de rezistenţă', max_length=10, choices=ResistanceStructure.choices, blank=True, default=None) class Meta: abstract = True
class Section(Model): """ Stores either a lucene search or raw elasticsearch query. """ project = ForeignKey(Project, on_delete=CASCADE, db_column='project') name = CharField(max_length=128) """ Name of the section. """ lucene_search = CharField(max_length=1024, null=True, blank=True) """ Optional lucene query syntax search string. """ media_bools = JSONField(null=True, blank=True) """ Optional list of elasticsearch boolean queries that should be applied to media. These are applied to the boolean query "filter" list. """ annotation_bools = JSONField(null=True, blank=True) """ Optional list of elasticsearch boolean queries that should be applied to annotations. These are applied to the boolean query "filter" list. """ tator_user_sections = CharField(max_length=128, null=True, blank=True) """ Identifier used to label media that is part of this section via the tator_user_sections attribute. If not set, this search is not scoped to a "folder". """ visible = BooleanField(default=True) """ Whether this section should be displayed in the UI.
class WithHotelRegime(WithRentPrice, Model): hotel_regime = BooleanField('regim hotelier', default=False) hotel_regime_price = DecimalField('chirie / zi', max_digits=6, decimal_places=2, blank=True, default=None) hotel_regime_currency = CharField('', max_length=4, choices=Currencies.choices, default=Currencies.EUR) class Meta: abstract = True
class Version(Model): name = CharField(max_length=128) description = CharField(max_length=1024, blank=True) number = PositiveIntegerField() project = ForeignKey(Project, on_delete=CASCADE) created_datetime = DateTimeField(auto_now_add=True, null=True, blank=True) created_by = ForeignKey(User, on_delete=SET_NULL, null=True, blank=True, related_name='version_created_by') show_empty = BooleanField(default=True) """ Tells the UI to show this version even if the current media does not have any annotations. """ bases = ManyToManyField('self', symmetrical=False, blank=True) """ This version is a patch to an existing version. A use-case here is using one version for each generation of a state-based inference algorithm; all referencing localizations in another layer. """ def __str__(self): out = f"{self.name}" if self.description: out += f" | {self.description}" return out
class EntityTypeBase(PolymorphicModel): project = ForeignKey(Project, on_delete=CASCADE, null=True, blank=True) name = CharField(max_length=64) description = CharField(max_length=256, blank=True) visible=BooleanField(default=True) def __str__(self): return f'{self.name} | {self.project}'
class WithSpaceSellingPrice(WithPrice, Model): price = PositiveIntegerField('preţ cerut', default=None) price_currency = CharField('', max_length=4, choices=Currencies.choices, default=Currencies.EUR) hide_price = BooleanField('nu doresc să fie afişat vizitatorilor site-ului', default=False) class Meta: abstract = True
class BaseOfferModel(BaseModel): agent = ForeignKey(UserProfile, on_delete=SET_NULL, null=True) is_published = BooleanField('publicat?', default=False) address = PointField('adresă', max_length=200, null=True) hide_address_on_imobiliare = BooleanField('ascunde adresa în imobiliare.ro', default=False) county = ForeignKey(County, related_name='%(class)ss', related_query_name='%(class)s', on_delete=SET_NULL, null=True, verbose_name='judeţ') locality = ForeignKey(Locality, related_name='%(class)ss', related_query_name='%(class)s', on_delete=SET_NULL, null=True, verbose_name='localitate') sector = CharField('sectorul', max_length=2, blank=True, default=None, choices=Sector.choices) hide_exact_location_on_imobiliare = BooleanField('ascunde localizarea exactă pe imobiliare.ro', default=False) postal_code = CharField('cod poştal', max_length=50, blank=True, default=None) neighborhood = CharField('vecinătăţi', max_length=100, blank=True, default=None) description = TextField('descriere emoţională', default=None, blank=True) class Meta: abstract = True
class WithExclusivity(Model): has_exclusivity = BooleanField('exclusivitate', default=False) contract = CharField(max_length=200, blank=True, default=None) validity_from = DateTimeField('valabilitate de la', blank=True, default=None) validity_up_to = DateTimeField('până la', blank=True, default=None) class Meta: abstract = True
class WithServices(Model): has_administration = BooleanField('administrare', default=False) has_housekeeping = BooleanField('menaj', default=False) has_security = BooleanField('pază', default=False) has_video_security = BooleanField('supraveghere video', default=False) has_cleaning = BooleanField('curăţenie', default=False) has_bed_sheets = BooleanField('lenjerie de pat', default=False) has_towels = BooleanField('prosoape', default=False) has_station_transfer = BooleanField('transfer aeroport/gară', default=False) has_city_tour = BooleanField('tur oraş', default=False) class Meta: abstract = True
class EntityTypeMediaVideo(EntityTypeMediaBase): entity_name = 'Video' dtype = 'video' file_format = CharField(max_length=3, null=True, blank=True, choices=FileFormat, default=FileFormat[0][0]) keep_original = BooleanField()
class User(AbstractBaseUser): email = EmailField(db_index=True, unique=True) is_active = BooleanField(default=True) is_staff = BooleanField(default=False) saved_flats = ManyToManyField(Flat) objects = UserManager() USERNAME_FIELD = 'email' @staticmethod def has_perm(perm: Any, obj: Any = None) -> bool: return True @staticmethod def has_module_perms(app_label: Any) -> bool: return True def __str__(self) -> str: return self.email
class Alert(Base): colors = (("danger", "danger"), ("info", "info"), ("success", "success"), ("warning", "warning")) color = CharField(choices=colors, max_length=200) permanent = BooleanField() text = CharField(max_length=200) user = OneToOneField(User, blank=True, null=True, on_delete=CASCADE) def __str__(self): return self.text
class EntityTypeState(EntityTypeBase): """ Used to conglomerate AttributeTypes into a set """ entity_name = 'State' dtype = 'state' media = ManyToManyField(EntityTypeMediaBase) markers = BooleanField(default=False) interpolation = EnumField(InterpolationMethods, default=InterpolationMethods.NONE) association = CharField(max_length=64, choices=AssociationTypes, default=AssociationTypes[0][0])
class WithOtherZoneDetails(Model): asphalted_street = BooleanField('asfaltate', default=False) concreted_street = BooleanField('betonate', default=False) paved_street = BooleanField('pietruite', default=False) soil_street = BooleanField('de pământ', default=False) undeveloped_street = BooleanField('neamenajate', default=False) has_illuminated_street = BooleanField('iluminat stradal', default=False) public_transport = BooleanField('mijloace de transport în comun', default=False) class Meta: abstract = True
class WithHeatingSystem(Model): has_heating = BooleanField('termoficare', default=False) has_own_boiler = BooleanField('centrală proprie', default=False) has_building_boiler = BooleanField('centrală imobil', default=False) has_fireplace_or_terracotta = BooleanField('sobă/teracotă', default=False) has_radiator = BooleanField('calorifere', default=False) has_flooring_heating = BooleanField('încălzire prin pardoseală', default=False) class Meta: abstract = True
class Project(Model): name = CharField(max_length=128) creator = ForeignKey(User, on_delete=PROTECT, related_name='creator', db_column='creator') organization = ForeignKey(Organization, on_delete=SET_NULL, null=True, blank=True, db_column='organization') created = DateTimeField(auto_now_add=True) size = BigIntegerField(default=0) """Size of all media in project in bytes. """ num_files = IntegerField(default=0) duration = BigIntegerField(default=0) """ Duration of all videos in this project. """ summary = CharField(max_length=1024) filter_autocomplete = JSONField(null=True, blank=True) attribute_type_uuids = JSONField(default=dict, null=True, blank=True) enable_downloads = BooleanField(default=True) thumb = CharField(max_length=1024, null=True, blank=True) usernames = ArrayField(CharField(max_length=256), default=list) """ Mapping between attribute type names and UUIDs. Used internally for maintaining elasticsearch field aliases. """ def has_user(self, user_id): return self.membership_set.filter(user_id=user_id).exists() def user_permission(self, user_id): permission = None qs = self.membership_set.filter(user_id=user_id) if qs.exists(): permission = qs[0].permission return permission def __str__(self): return self.name def delete(self, *args, **kwargs): Version.objects.filter(project=self).delete() MediaType.objects.filter(project=self).delete() LocalizationType.objects.filter(project=self).delete() StateType.objects.filter(project=self).delete() LeafType.objects.filter(project=self).delete() super().delete(*args, **kwargs)
class WithSpaceUtilities(Model): has_current = BooleanField('curent', default=False) has_water = BooleanField('apă', default=False) has_sewerage = BooleanField('canalizare', default=False) has_gas = BooleanField('gaz', default=False) has_heating = BooleanField('căldură', default=False) has_conditioning = BooleanField('climă', default=False) class Meta: abstract = True
class EntityState(EntityBase): """ A State is an event that occurs, potentially independent, from that of a media element. It is associated with 0 (1 to be useful) or more media elements. If a frame is supplied it was collected at that time point. """ association = ForeignKey(AssociationType, on_delete=CASCADE) version = ForeignKey(Version, on_delete=CASCADE, null=True, blank=True) modified = BooleanField(null=True, blank=True) """ Indicates whether an annotation is original or modified. null: Original upload, no modifications. false: Original upload, but was modified or deleted. true: Modified since upload or created via web interface. """ def selectOnMedia(media_id): return AssociationType.states(media_id)
class Estate(Model): url = URLField(max_length=400, unique=True) avatar = URLField(max_length=400, null=True) published = DateField() geolocation = ForeignKey(Geolocation, on_delete=CASCADE) price = DecimalField(max_digits=10, decimal_places=2) rate = DecimalField(max_digits=10, decimal_places=2) area = FloatField() is_visible = BooleanField(default=True) lookups = {} order_by = set() class Meta: abstract = True def __str__(self) -> str: return f'[{self.url}, {self.area}, {self.rate}]'
class EntityLocalizationBase(EntityBase): user = ForeignKey(User, on_delete=PROTECT) media = ForeignKey(EntityMediaBase, on_delete=CASCADE) frame = PositiveIntegerField(null=True) thumbnail_image = ForeignKey(EntityMediaImage, on_delete=SET_NULL, null=True, blank=True, related_name='thumbnail_image') version = ForeignKey(Version, on_delete=CASCADE, null=True, blank=True) modified = BooleanField(null=True, blank=True) """ Indicates whether an annotation is original or modified. null: Original upload, no modifications. false: Original upload, but was modified or deleted. true: Modified since upload or created via web interface. """ def selectOnMedia(media_id): return EntityLocalizationBase.objects.filter(media=media_id)
class Version(Model): name = CharField(max_length=128) description = CharField(max_length=1024, blank=True) number = PositiveIntegerField() project = ForeignKey(Project, on_delete=CASCADE) created_datetime = DateTimeField(auto_now_add=True, null=True, blank=True) created_by = ForeignKey(User, on_delete=SET_NULL, null=True, blank=True, related_name='version_created_by') show_empty = BooleanField(default=False) """ Tells the UI to show this version even if the current media does not have any annotations. """ def __str__(self): out = f"{self.name}" if self.description: out += f" | {self.description}" return out
class WithAdditionalPropertyInfo(Model): building_year = PositiveIntegerField('an finalizare construcţie', blank=True, default=None) building_stage = CharField('stadiu construcţie', max_length=15, choices=BUILDING_STAGE, default=None, blank=True) underground_levels_nr = PositiveIntegerField('nr. niveluri subterane', default=None, blank=True) levels_nr = PositiveIntegerField('nr. niveluri', default=None, blank=True) has_semi_basement = BooleanField('demisol', default=False) has_ground_floor = BooleanField('parter', default=True) has_mansard = BooleanField('mansardă', default=False) has_terrace = BooleanField('terasă', default=False) has_entresol = BooleanField('mezanin', default=False) has_parking_possibility = BooleanField('posibilitate parcare', default=False) parking_spaces_nr = PositiveIntegerField('nr. locuri parcare', default=None, blank=True) building_state = CharField('stare imobil', max_length=15, choices=BUILDING_STATE, default=None, blank=True) class Meta: abstract = True
class LeafType(Model): dtype = CharField(max_length=16, choices=[('leaf', 'leaf')], default='leaf') project = ForeignKey(Project, on_delete=CASCADE, null=True, blank=True, db_column='project') name = CharField(max_length=64) description = CharField(max_length=256, blank=True) visible = BooleanField(default=True) """ Whether this type should be displayed in the UI.""" attribute_types = JSONField(null=True, blank=True) """ User defined attributes. An array of objects, each containing the following fields: name: Name of the attribute. description: Description of the attribute. order: Order that the attribute should appear in web UI. Negative means do not display. dtype: Data type of the attribute. Valid values are bool, int, float, string, enum, datetime, geopos. default: (optional) Default value. Valid for all dtypes except datetime. The type should correspond to the dtype (string/enum are strings, int/float are numbers, geopos is a [lon, lat] list). minimum: (optional) Minimum value. Valid for int and float dtypes. maximum: (optional) Maximum value. Valid for int and float dtypes. choices: (optional) Available choices for enum dtype. labels: (optional) Labels for available choices for enum dtype. autocomplete: (optional) Object of the form {'serviceUrl': '<url>'} that specifies URL of the autocomplete service. Valid for string dtype only. use_current: (optional) Boolean indicating whether to use the current time as the default for datetime dtype. """ def __str__(self): return f'{self.name} | {self.project}'