Ejemplo n.º 1
0
class WithSellingPrice(WithPrice, Model):
    total_price = PositiveIntegerField('preţ total', blank=True, default=None)
    total_price_currency = CharField('', max_length=4, choices=Currencies.choices, default=Currencies.EUR)
    util_price = PositiveIntegerField('preţ / mp util sau UM', blank=True, default=None)
    util_price_currency = CharField('', max_length=4, choices=Currencies.choices, default=Currencies.EUR)

    class Meta:
        abstract = True
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
class WithHouseSurfaces(Model):
    util_surface = DecimalField('suprafaţa utilă (mp)', max_digits=7, decimal_places=2, default=None, blank=True)
    constructed_surface = DecimalField('suprafaţa construită (amprentă la sol) (mp)', max_digits=7, decimal_places=2,
                                       default=None, blank=True)
    unfolded_surface = DecimalField('suprafaţă desfăşurată (mp)', max_digits=7, decimal_places=2, default=None,
                                    blank=True)
    terrain_surface = DecimalField('suprafaţă teren (mp)', max_digits=7, decimal_places=2, default=None, blank=True)
    street_fronts_nr = PositiveIntegerField('nr. fronturi stradale', default=None, blank=True)
    street_front = DecimalField('front stradal (m)', max_digits=5, decimal_places=2, default=None, blank=True)
    terrace_nr = PositiveIntegerField('nr. terase', default=None, blank=True)
    terrace_surface = DecimalField('suprafaţă terase (mp)', max_digits=6, decimal_places=2, default=None, blank=True)

    class Meta:
        abstract = True
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
class Algorithm(Model):
    name = CharField(max_length=128)
    project = ForeignKey(Project, on_delete=CASCADE)
    user = ForeignKey(User, on_delete=PROTECT)
    description = CharField(max_length=1024, null=True, blank=True)
    manifest = FileField(upload_to=ProjectBasedFileLocation, null=True, blank=True)
    cluster = ForeignKey(JobCluster, null=True, blank=True, on_delete=SET_NULL)
    files_per_job = PositiveIntegerField(
        default=1,
        validators=[MinValueValidator(1),]
    )
    max_concurrent = PositiveIntegerField(
        default=1,
        validators=[MinValueValidator(1),]
    )

    def __str__(self):
        return self.name
Ejemplo n.º 8
0
class Favorite(Model):
    """ Stores an annotation saved by a user.
    """
    project = ForeignKey(Project, on_delete=CASCADE, db_column='project')
    user = ForeignKey(User, on_delete=CASCADE, db_column='user')
    meta = ForeignKey(LocalizationType, on_delete=CASCADE, db_column='meta')
    name = CharField(max_length=128)
    page = PositiveIntegerField(default=1)
    values = JSONField()
Ejemplo n.º 9
0
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')

    def selectOnMedia(media_id):
        return EntityLocalizationBase.objects.filter(media=media_id)
Ejemplo n.º 10
0
class JobCluster(Model):
    name = CharField(max_length=128)
    owner = ForeignKey(User, null=True, blank=True, on_delete=SET_NULL)
    host = CharField(max_length=1024)
    port = PositiveIntegerField()
    token = CharField(max_length=1024)
    cert = TextField(max_length=2048)

    def __str__(self):
        return self.name
Ejemplo n.º 11
0
class FrameAssociation(AssociationType):
    frame = PositiveIntegerField()
    extracted = ForeignKey(EntityMediaImage,
                           on_delete=SET_NULL,
                           null=True,
                           blank=True)

    def states(media_id):
        frameAssociations = FrameAssociation.objects.filter(media__in=media_id)
        return EntityState.objects.filter(association__in=frameAssociations)
Ejemplo n.º 12
0
class WithRoomsAndAnnexes(Model):
    rooms_nr = PositiveIntegerField('nr. camere', default=None)
    kitchens_nr = PositiveIntegerField('nr. bucătării', blank=True, default=None)
    bathrooms_nr = PositiveIntegerField('nr. băi', blank=True, default=None)
    balconies_nr = PositiveIntegerField('nr. balcoane', blank=True, default=None)
    closed_balconies_nr = PositiveIntegerField('din care închise', blank=True, default=None)
    garages_nr = PositiveIntegerField('nr. garaje', blank=True, default=None)
    parking_lots_nr = PositiveIntegerField('nr. locuri parcare', blank=True, default=None)

    class Meta:
        abstract = True
Ejemplo n.º 13
0
class LocalizationType(Model):
    dtype = CharField(max_length=16,
                      choices=[('box', 'box'), ('line', 'line'),
                               ('dot', 'dot')])
    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)
    colorMap = JSONField(null=True, blank=True)
    line_width = PositiveIntegerField(default=3)
    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.
    """
    def __str__(self):
        return f'{self.name} | {self.project}'
Ejemplo n.º 14
0
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)
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
class LandBaseModel(BaseOfferModel, WithOtherDetails, WithDestination, WithExclusivity, WithOtherZoneDetails):
    land_type = CharField('tip teren', max_length=12, choices=LandType.choices, default=LandType.CONSTRUCTII)
    street_fronts_nr = PositiveIntegerField('nr. fronturi stradale', default=None, blank=True)
    classification = CharField('clasificare', max_length=12, choices=LandClassification.choices,
                               default=LandClassification.INTRAVILAN)
    street_front = PositiveIntegerField('front stradal (m)', default=None, blank=True)
    terrain_surface = PositiveIntegerField('suprafaţă teren', default=None, blank=True)
    terrain_surface_type = CharField('', max_length=3, choices=SurfaceType.choices, default=SurfaceType.M)
    terrain_angle = IntegerField('înclinaţie teren (%)', default=None, blank=True)
    pot = IntegerField('P.O.T (%)', default=None, blank=True,
                       help_text='Procentajul de ocupare al terenului (suprafaţa ocupată/suprafaţa totală * 100')
    cut = IntegerField('C.U.T (%)', default=None, blank=True,
                       help_text='Coeficientul de utilizare al terenului (suma suprafeţelor desfăşurate/suprafaţa totală * 100')
    height_regime = PositiveIntegerField('regim înălţime (m)', default=None, blank=True)
    urban_coefficients_source = CharField('sursă informaţii coef. urbanistici', max_length=25,
                                          choices=URBAN_COEFF_SOURCES, default=None, blank=True)
    terrain_construction = BooleanField('construcţie pe teren', default=False)
    constructed_surface = PositiveIntegerField('suprafaţă construită (mp)', default=None, blank=True)
    access_road_width = PositiveIntegerField('lăţime drum de acces (m)', default=None, blank=True)
    documents = TextField('acte/avize', default=None, blank=True)
    plots_lot = BooleanField('lot parcele', default=False)
    plots_lot_name = CharField('nume lot parcele', max_length=100, default=None, blank=True)

    has_current = BooleanField('curent', default=False)
    has_three_phase_current = BooleanField('curent trifazic', default=False)
    has_water = BooleanField('apă', default=False)
    has_sewerage = BooleanField('canalizare', default=False)
    has_irrigation_system = BooleanField('sistem irigaţie', default=False)
    has_gas = BooleanField('gaz', default=False)
    has_utilities_nearby = BooleanField('utilităţi în zonă', default=False)

    has_investment_opportunity = BooleanField('oportunitate de investiţie', default=False)
    can_be_demolished = BooleanField('construcţie demolabilă', default=False)
    can_be_splitted = BooleanField('parcelabil', default=False)
    is_near_road = BooleanField('la şosea', default=False)
    has_auto_access = BooleanField('acces auto', default=False)
    is_surrounded_terrain = BooleanField('teren  împrejmuit', default=False)

    class Meta:
        abstract = True
Ejemplo n.º 17
0
class State(Model):
    """
    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.
    """
    project = ForeignKey(Project,
                         on_delete=SET_NULL,
                         null=True,
                         blank=True,
                         db_column='project')
    meta = ForeignKey(StateType,
                      on_delete=SET_NULL,
                      null=True,
                      blank=True,
                      db_column='meta')
    """ Meta points to the defintion of the attribute field. That is
        a handful of AttributeTypes are associated to a given EntityType
        that is pointed to by this value. That set describes the `attribute`
        field of this structure. """
    attributes = JSONField(null=True, blank=True)
    """ Values of user defined attributes. """
    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='state_created_by',
                            db_column='created_by')
    modified_datetime = DateTimeField(auto_now=True, null=True, blank=True)
    modified_by = ForeignKey(User,
                             on_delete=SET_NULL,
                             null=True,
                             blank=True,
                             related_name='state_modified_by',
                             db_column='modified_by')
    version = ForeignKey(Version,
                         on_delete=SET_NULL,
                         null=True,
                         blank=True,
                         db_column='version')
    modified = BooleanField(default=True, 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.
    """
    media = ManyToManyField(Media, related_name='media')
    localizations = ManyToManyField(Localization)
    segments = JSONField(null=True, blank=True)
    color = CharField(null=True, blank=True, max_length=8)
    frame = PositiveIntegerField(null=True, blank=True)
    extracted = ForeignKey(Media,
                           on_delete=SET_NULL,
                           null=True,
                           blank=True,
                           related_name='extracted',
                           db_column='extracted')

    def selectOnMedia(media_id):
        return State.objects.filter(media__in=media_id)
Ejemplo n.º 18
0
class Localization(Model):
    project = ForeignKey(Project,
                         on_delete=SET_NULL,
                         null=True,
                         blank=True,
                         db_column='project')
    meta = ForeignKey(LocalizationType,
                      on_delete=SET_NULL,
                      null=True,
                      blank=True,
                      db_column='meta')
    """ Meta points to the defintion of the attribute field. That is
        a handful of AttributeTypes are associated to a given LocalizationType
        that is pointed to by this value. That set describes the `attribute`
        field of this structure. """
    attributes = JSONField(null=True, blank=True)
    """ Values of user defined attributes. """
    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='localization_created_by',
                            db_column='created_by')
    modified_datetime = DateTimeField(auto_now=True, null=True, blank=True)
    modified_by = ForeignKey(User,
                             on_delete=SET_NULL,
                             null=True,
                             blank=True,
                             related_name='localization_modified_by',
                             db_column='modified_by')
    user = ForeignKey(User, on_delete=PROTECT, db_column='user')
    media = ForeignKey(Media,
                       on_delete=SET_NULL,
                       null=True,
                       blank=True,
                       db_column='media')
    frame = PositiveIntegerField(null=True, blank=True)
    thumbnail_image = ForeignKey(Media,
                                 on_delete=SET_NULL,
                                 null=True,
                                 blank=True,
                                 related_name='localization_thumbnail_image',
                                 db_column='thumbnail_image')
    version = ForeignKey(Version,
                         on_delete=SET_NULL,
                         null=True,
                         blank=True,
                         db_column='version')
    modified = BooleanField(default=True, 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.
    """
    x = FloatField(null=True, blank=True)
    """ Horizontal position."""
    y = FloatField(null=True, blank=True)
    """ Vertical position."""
    u = FloatField(null=True, blank=True)
    """ Horizontal vector component for lines."""
    v = FloatField(null=True, blank=True)
    """ Vertical vector component for lines. """
    width = FloatField(null=True, blank=True)
    """ Width for boxes."""
    height = FloatField(null=True, blank=True)
    """ Height for boxes."""
    parent = ForeignKey("self",
                        on_delete=SET_NULL,
                        null=True,
                        blank=True,
                        db_column='parent')
    """ Pointer to localization in which this one was generated from """
Ejemplo n.º 19
0
class EntityTypeLocalizationDot(EntityTypeLocalizationBase):
    entity_name = 'Dot'
    dtype = 'dot'
    marker = EnumField(Marker, max_length=9, default=Marker.CIRCLE)
    marker_size = PositiveIntegerField(default=12)
Ejemplo n.º 20
0
class EntityTypeLocalizationLine(EntityTypeLocalizationBase):
    entity_name = 'Line'
    dtype = 'line'
    line_width = PositiveIntegerField(default=3)
Ejemplo n.º 21
0
class EntityTypeLocalizationBox(EntityTypeLocalizationBase):
    entity_name = 'Box'
    dtype = 'box'
    line_width = PositiveIntegerField(default=3)
Ejemplo n.º 22
0
class FrameAssociation(AssociationType):
    frame = PositiveIntegerField()

    def states(media_id):
        frameAssociations=FrameAssociation.objects.filter(media__in=media_id)
        return EntityState.objects.filter(association__in=frameAssociations)