Esempio n. 1
0
class Comuni(models.Model):
    _database = 'lifeten'
    id = models.IntegerField(primary_key=True)
    comu = models.SmallIntegerField(null=True, blank=True)
    nome = models.CharField(db_column='name', max_length=40, blank=True)
    altcom = models.IntegerField(null=True, blank=True)
    geom = models.MultiPolygonField(srid=25832, null=True, blank=True)
    objects = models.GeoManager()

    class Meta:
        db_table = u'comuni'

    def __unicode__(self):
        """Funzione che serve per ottenere la rappresentazione testuale"""
        return smart_str(self.nome)
Esempio n. 2
0
class DjangoAdminLog(models.Model):
    action_time = models.DateTimeField()
    object_id = models.TextField(blank=True, null=True)
    object_repr = models.CharField(max_length=200)
    action_flag = models.SmallIntegerField()
    change_message = models.TextField()
    content_type = models.ForeignKey('DjangoContentType',
                                     models.DO_NOTHING,
                                     blank=True,
                                     null=True)
    user = models.ForeignKey(AccountsUser, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'django_admin_log'
Esempio n. 3
0
class Poi(models.Model):
    "Misto - bod v mape"
    nazev = models.CharField(max_length=255,
                             blank=True)  # Name of the location

    # Relationships
    znacka = models.ForeignKey(Znacka)  # "Znacky"   - misto ma prave jednu
    status = models.ForeignKey(Status)  # "Statuty"  - misto ma prave jeden

    # "dulezitost" - modifikator minimalniho zoomu, ve kterem se misto zobrazuje.
    # Cim vetsi, tim vice bude poi videt, +20 = bude videt vydycky
    # Cil je mit vyber zakladnich objektu viditelnych ve velkych meritcich
    # a zabranit pretizeni mapy znackami v prehledce.
    # Lze pouzit pro placenou reklamu! ("Vas podnik bude videt hned po otevreni mapy")
    dulezitost = models.SmallIntegerField(default=0)

    # Geographical intepretation
    geom = models.PointField(verbose_name=u"Poloha", srid=4326)
    objects = models.GeoManager()

    # Own content (facultative)
    desc = models.TextField(null=True, blank=True)
    desc_extra = models.TextField(
        null=True,
        blank=True,
        help_text="text do podrobnějšího výpisu podniku (mimo popup)")
    url = models.URLField(null=True,
                          blank=True)  # Odkaz z vypisu - stranka podniku apod.
    # address = models.CharField(max_length=255, null=True, blank=True)
    remark = models.TextField(
        null=True, blank=True
    )  # Interni informace o objektu, ktere se nebudou zobrazovat!

    # navzdory nazvu jde o fotku v plnem rozliseni
    foto_thumb = models.ImageField(null=True, blank=True, upload_to='foto')

    viditelne = ViditelneManager()

    class Meta:
        verbose_name_plural = "místa"

    def __unicode__(self):
        if self.nazev:
            return self.nazev
        return unicode(self.znacka)

    def get_absolute_url(self):
        return "/misto/%i/" % self.id
Esempio n. 4
0
class Sdr(models.Model):
    zotero = models.CharField(max_length=8, verbose_name='zotero ID')
    name_short = models.CharField(max_length=255, verbose_name='short name')
    sdr_year = models.SmallIntegerField(verbose_name='earliest year depicted')
    intended_features = models.ManyToManyField(DefFeatureType)
    areas = models.ManyToManyField(DefArea)
    type = models.ForeignKey(DefType, on_delete=models.PROTECT)
    sdraccloc = models.ForeignKey(DefAccuracyLocation,
                                  verbose_name='location accuracy',
                                  on_delete=models.PROTECT)
    sdraccsiz = models.ForeignKey(DefAccuracySize,
                                  verbose_name='size accuracy',
                                  on_delete=models.PROTECT)
    sdraccgeo = models.ForeignKey(DefAccuracyGeoref,
                                  verbose_name='georeferencing accuracy',
                                  on_delete=models.PROTECT)
    notes = models.TextField(blank=True)
    notes_sdraccloc = models.TextField(blank=True,
                                       verbose_name='location accuracy notes')
    notes_sdraccsiz = models.TextField(blank=True,
                                       verbose_name='size accuracy notes')
    notes_sdraccgeo = models.TextField(
        blank=True, verbose_name='georeferencing accuracy notes')
    last_modified = models.DateTimeField(auto_now=True,
                                         verbose_name='last modified')

    objects = SdrManager()

    def save(self, *args, **kwargs):
        super(Sdr, self).save(*args, **kwargs)
        # Save every child object to ensure filenames stay consistent with SDR name
        for s in self.scan_set.all():
            s.save()
        for g in self.georef_set.all():
            g.save()
        for f in self.feature_set.all():
            f.save()

    def __str__(self):
        name = str(self.name_short)
        if len(name) > 30:
            return '%s...' % name[:30]
        return name

    class Meta:
        verbose_name = 'spatial data resource'
        verbose_name_plural = 'spatial data resources'
        ordering = ['-last_modified']
Esempio n. 5
0
class RoomScore(models.Model):
    score = models.FloatField(
        validators=[MinValueValidator(0.0),
                    MaxValueValidator(5.0)], )
    price = models.IntegerField()
    is_lived = models.BooleanField(default=True)
    description = models.TextField(blank=True, null=True)
    population = models.SmallIntegerField(default=1)
    deposit = models.IntegerField(null=True, blank=True)
    room_no = models.ForeignKey('Room',
                                on_delete=models.CASCADE,
                                related_name='scores')
    reviewer = models.ForeignKey('auth.User',
                                 on_delete=models.CASCADE,
                                 related_name='roomReviews')
    created_time = models.DateTimeField(auto_now_add=True)
Esempio n. 6
0
class Restaurant(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4)
    rating = models.SmallIntegerField()
    name = models.CharField(max_length=128, blank=False)
    site = models.URLField()
    email = models.CharField(max_length=128, blank=True, default='')
    phone = models.CharField(max_length=32, blank=True, default='')
    street = models.CharField(max_length=128, blank=True, default='')
    city = models.CharField(max_length=128, blank=True, default='')
    state = models.CharField(max_length=128, blank=True, default='')
    location = models.PointField(geography=True, default=Point(0.0, 0.0))
    lat = models.FloatField()
    lng = models.FloatField()

    class Meta:
        ordering = ['name']
Esempio n. 7
0
class TrailStep(models.Model):
    trail = models.ForeignKey("Trail",
                              on_delete=models.CASCADE,
                              related_name="steps")
    lat = models.DecimalField(max_digits=19,
                              decimal_places=16,
                              default=Decimal("0"))
    lng = models.DecimalField(max_digits=19,
                              decimal_places=16,
                              default=Decimal("0"))
    point = models.PointField()
    order = models.SmallIntegerField()

    class Meta:
        verbose_name = _("Trail Step")
        verbose_name_plural = _("Trail Steps")
Esempio n. 8
0
class Transaction(models.Model):
    ctime = models.DateTimeField(auto_now_add=True)
    user = models.ForeignKey(UserSettings)
    key = models.CharField(
        max_length=64, null=True, blank=True, default="premium")
    value = models.FloatField(null=True, blank=True, default=30)
    fiat = models.SmallIntegerField(null=True, blank=True, default=300)
    comment = models.TextField(null=True, blank=True)
    phone = models.CharField(max_length=80, null=True, blank=True)
    gosnum = models.CharField(max_length=16, null=True, blank=True)
    end_time = models.DateTimeField(null=True, blank=True)
    notified = models.BooleanField(default=False)
    pin = models.CharField(max_length=16, null=True, blank=True)
    vip = models.BooleanField(default=0)

    def __unicode__(self):
        return "%s_%s_%s" % (self.user.session_key[:6], self.ctime, self.fiat)

    def save(self, *args, **kwargs):
        if not self.pin:
            self.pin = "%d-%d-%d" % (
                random.randint(100, 999),
                random.randint(100, 999),
                random.randint(100, 999))
        super(Transaction, self).save(*args, **kwargs)

    @property
    def warning(self):
        delta = self.end_time - datetime.timedelta(days=2)
        if datetime.datetime.now() > delta:
            return True
        else:
            return False
    @property
    def countdown(self):
        delta = self.end_time - datetime.datetime.now()
        delta_days = delta.days + 1
        if delta_days > 1:
            ed = MORPH.parse(u'день')[0]
            amount = delta_days
        else:
            ed = MORPH.parse(u'час')[0]
            amount = int(delta.total_seconds() / 60 / 60)
        word = ed.make_agree_with_number(amount).word
        ost = MORPH.parse(u'осталось')[0]
        ost = ost.make_agree_with_number(amount).word
        return u"%s %s %s" % (ost, amount, word)
Esempio n. 9
0
class Empleado(models.Model):
    ESTADO_ACTIVO = 0
    ESTADO_INACTIVO = 1
    ESTADO_CHOICES = (
        (ESTADO_ACTIVO, 'Activo'),
        (ESTADO_INACTIVO, 'Inactivo'),
    )

    persona = models.ForeignKey(PersonaNatural)
    estado = models.SmallIntegerField(choices=ESTADO_CHOICES,
                                      default=ESTADO_ACTIVO)
    observaciones = models.TextField(max_length=2000, null=True)
    plazas_trabajo = models.ManyToManyField(PlazaTrabajo)
    usuario = models.OneToOneField(User, null=True, blank=True)
    foto = models.ImageField(upload_to="fotos", null=True, blank=True)

    class Meta:
        permissions = (('genera_nomina', 'Puede generar la nómina'), )

    def __str__(self):
        return self.persona.apellido_paterno + " " + self.persona.nombres

    def nombres(self):
        return format_html(
            '<span style="color: red;">{} {}</span>',
            #self.color_code,
            self.persona.apellido_paterno,
            self.persona.nombres,
        )

    def as_data(self):
        dic = self.__dict__
        dic['usuario'] = self.usuario.username
        dic['nombres'] = self.persona.nombres
        dic['apellido_paterno'] = self.persona.apellido_paterno
        dic['apellido_materno'] = self.persona.apellido_materno
        dic['cedula'] = self.persona.cedula
        dic['sexo'] = self.persona.sexo
        dic['email'] = self.usuario.email
        dic['plazas_trabajo'] = self.plazas_trabajo.all()
        dic['foto'] = self.foto
        dic['fecha_nacimiento'] = self.persona.fecha_nacimiento
        dic['ciudad'] = self.persona.ciudad_nacimiento
        dic['provincia'] = self.persona.ciudad_nacimiento.provincia
        dic['pais'] = self.persona.ciudad_nacimiento.provincia.pais

        return dic
Esempio n. 10
0
class Sample(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    version = AutoIncVersionField()
    public_data = models.BooleanField(default=False)
    number = models.CharField(max_length=35)
    owner = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='samples')
    aliases = ArrayField(models.CharField(max_length=35, blank=True),
                         blank=True,
                         null=True)
    collection_date = models.DateTimeField(blank=True, null=True)
    description = models.TextField(blank=True, null=True)
    location_name = models.CharField(max_length=50, blank=True, null=True)
    location_coords = models.PointField()
    location_error = models.FloatField(blank=True, null=True)
    rock_type = models.ForeignKey(RockType)
    date_precision = models.SmallIntegerField(blank=True, null=True)
    metamorphic_regions = models.ManyToManyField('MetamorphicRegion')
    metamorphic_grades = models.ManyToManyField('MetamorphicGrade')
    minerals = models.ManyToManyField('Mineral', through='SampleMineral',
                                      related_name='samples')
    references = models.ManyToManyField('GeoReference', related_name='samples')

    # Free-text field. Ugh. Stored as an CharField to avoid joining to the
    # country table every time we retrieve sample(s).
    country = models.CharField(max_length=100, blank=True, null=True)

    # Free-text field; stored as an ArrayField to avoid joining to the
    # regions table every time we retrieve sample(s).
    regions = ArrayField(models.CharField(max_length=100, blank=True),
                         blank=True,
                         null=True)

    # Free text field with no validation;
    collector_name = models.CharField(max_length=50, blank=True, null=True)

    # Unused; here for backward compatibility
    collector_id = models.ForeignKey(settings.AUTH_USER_MODEL,
                                     db_column='collector_id',
                                     related_name='+',
                                     blank=True,
                                     null=True)

    # Unused; here for backward compatibility
    sesar_number = models.CharField(max_length=9, blank=True, null=True)

    class Meta:
        db_table = 'samples'
Esempio n. 11
0
class Person(models.Model):
    first_name = models.CharField(max_length=512)
    last_name = models.CharField(max_length=512,
                                 blank=True,
                                 null=True)
    status = models.SmallIntegerField(verbose_name=_("status"),
                                      help_text=_(
                                          "0 = en création, 1 = en validation, 3 = public, "
                                          "4 = exporté vers le cahier spécial"),
                                      blank=True,
                                      null=True)
    contact_name = models.CharField(max_length=128,
                                    blank=True,
                                    null=True)
    mail = models.EmailField(verbose_name=_("adresse email"),
                             blank=True,
                             null=True)
    adresse = models.TextField(blank=True,
                               null=True,
                               verbose_name=_("adresse postale")
    )
    telephone = models.CharField(max_length=128,
                                 verbose_name=_("numéro de téléphone"),
                                 blank=True,
                                 null=True)
    cellphone = models.CharField(max_length=128,
                                 verbose_name=_("numéro de natel"),
                                 blank=True,
                                 null=True)
    slug = models.SlugField(null=True,
                            blank=True,
                            help_text=_("nom formaté pour les URLs"))

    def name(self):
        return self.first_name+' '+self.last_name

    class Meta:
        verbose_name = _("artiste")
        verbose_name_plural = _("artistes")

    def __str__(self):
        return self.name()
    def save(self, **kwargs):
        from regionfestival.snippets import unique_slugify
        unique_slugify(self, self.name)
        super(Person, self).save(**kwargs)
Esempio n. 12
0
class HistoriaPredioCultivo(models.Model):
    anno = models.IntegerField()
    mes = models.SmallIntegerField()
    sem = models.IntegerField()
    area_cultivo = models.DecimalField(max_digits=11,
                                       decimal_places=4,
                                       validators=[MinValueValidator(1)])
    codigo_predio = models.ForeignKey(Predio, on_delete=models.DO_NOTHING)
    id_cultivo = models.ForeignKey(TipoCultivo, on_delete=models.DO_NOTHING)
    Consumo = models.DecimalField(max_digits=11, decimal_places=4)
    lamina = models.DecimalField(max_digits=6, decimal_places=3)
    usuario_registro = models.ForeignKey(User,
                                         related_name='HPCusuarioregistro',
                                         null=True,
                                         blank=True)
    fecha_registro = models.DateTimeField(auto_now_add=True,
                                          null=True,
                                          blank=True)
    usuario_modifica = models.ForeignKey(User,
                                         related_name='HPCusuariomodifica',
                                         null=True,
                                         blank=True)
    fecha_modifica = models.DateTimeField(auto_now=True, null=True, blank=True)

    @property
    def json(self):
        if self.sem == 1:
            return {
                'codigo_predio': self.codigo_predio.codigo_predio,
                'id_cultivo': self.id_cultivo.nombre_cultivo,
                'area_cultivo': self.area_cultivo,
                'Consumo': self.Consumo,
                'anno': self.anno,
                'sem': 'A',
                'mes': self.mes,
            }
        else:
            return {
                'codigo_predio': self.codigo_predio.codigo_predio,
                'id_cultivo': self.id_cultivo.nombre_cultivo,
                'area_cultivo': self.area_cultivo,
                'Consumo': self.Consumo,
                'anno': self.anno,
                'sem': 'B',
                'mes': self.mes,
            }
Esempio n. 13
0
class CampsiteBooking(models.Model):
    BOOKING_TYPE_CHOICES = ((0, 'Reception booking'), (1, 'Internet booking'),
                            (2, 'Black booking'))

    campsite = models.ForeignKey('Campsite',
                                 db_index=True,
                                 on_delete=models.PROTECT)
    date = models.DateField(db_index=True)
    booking = models.ForeignKey('Booking', on_delete=models.PROTECT, null=True)
    booking_type = models.SmallIntegerField(choices=BOOKING_TYPE_CHOICES,
                                            default=0)

    def __str__(self):
        return '{} - {}'.format(self.campsite, self.date)

    class Meta:
        unique_together = (('campsite', 'date'), )
Esempio n. 14
0
class UserProfile(models.Model):
    """
    User Profile data
    """
    user = models.ForeignKey(User, unique=True)

    name = models.CharField(max_length=60, blank=True, null=True)
    gender = models.SmallIntegerField(choices=SEXO_CHOICES,
                                      blank=True,
                                      null=True)

    point = models.PointField(srid=settings.SRID, blank=True, null=True)
    python_frameworks = models.ManyToManyField(
        PythonFrameWorks,
        blank=True,
        null=True,
        help_text="Select one or more choices")

    #google address format
    locality = models.CharField(max_length=60, blank=True, null=True)
    administrative_area_level_1 = models.CharField(max_length=60,
                                                   blank=True,
                                                   null=True)
    country = models.CharField(max_length=6, blank=True, null=True)

    public_email = models.NullBooleanField(
        'Public e-mail address ?',
        help_text=
        "If 'yes', everyone may see your e-mail adress on your profile page.")

    bio = models.TextField()

    #occupation = models.ManyToManyField(Occupation)
    #organization =  models.CharField(max_length=60 , blank=True, null=True )
    #organization_site = models.URLField()
    #blog = models.URLField(verify_exists=True, blank=True, null=True )
    #site = models.URLField(verify_exists=True, blank=True, null=True )
    #twitter = models.CharField(blank=True, null=True )
    #bio  = models.TextField( blank=True, null=True , blank=True, null=True )
    objects = models.GeoManager()

    def __unicode__(self):
        return self.user.username

    def get_absolute_url(self):
        return reverse('user-profile', args=[self.id])
Esempio n. 15
0
class TimeZone(models.Model):
    last_modified = models.DateTimeField(auto_now=True,
                                         null=True,
                                         editable=False)

    code = models.CharField(max_length=50)
    utc_offset = models.SmallIntegerField()

    def __unicode__(self):
        return '%s (UTC%+03d%02d)' % (
            self.code,
            (abs(self.utc_offset) / 60) * (-1 if self.utc_offset < 0 else 1),
            abs(self.utc_offset % 60),
        )

    class Meta:
        ordering = ('utc_offset', )
Esempio n. 16
0
class VoterRegistrationByAge(models.Model):
    age = models.SmallIntegerField()
    year_2006 = models.FloatField(db_column="2006")
    year_2007 = models.FloatField(db_column="2007")
    year_2008 = models.FloatField(db_column="2008")
    year_2009 = models.FloatField(db_column="2009")
    year_2010 = models.FloatField(db_column="2010")
    year_2011 = models.FloatField(db_column="2011")
    year_2012 = models.FloatField(db_column="2012")
    year_2013 = models.FloatField(db_column="2013")
    year_2014 = models.FloatField(db_column="2014")
    year_2015 = models.FloatField(db_column="2015")
    year_2016 = models.FloatField(db_column="2016")

    class Meta:
        managed = False
        db_table = 'age_group_registration_percent'
Esempio n. 17
0
class Habitat(models.Model):
    _database = 'lifeten'
    gid = models.IntegerField(primary_key=True)
    note = models.CharField(max_length=254, blank=True)
    codice = models.CharField(max_length=16, blank=True)
    vegetaz = models.CharField(max_length=254, blank=True)
    nome = models.CharField(max_length=254, blank=True)
    prior = models.CharField(max_length=1, blank=True)
    ii_codice = models.CharField(max_length=16, blank=True)
    ii_vegetaz = models.CharField(max_length=254, blank=True)
    ii_hab_it = models.CharField(max_length=254, blank=True)
    ii_prior = models.CharField(max_length=1, blank=True)
    anno = models.SmallIntegerField(null=True, blank=True)
    geom = models.MultiPolygonField(srid=25832, null=True, blank=True)
    objects = models.GeoManager()

    class Meta:
        db_table = u'habitat'
Esempio n. 18
0
class TimeZone(models.Model):
    last_modified = models.DateTimeField(default=now, null=True, editable=False)
    code = models.CharField(max_length=50)
    utc_offset = models.SmallIntegerField()

    @property
    def as_tzinfo(self):
        return timezone(timedelta(minutes=self.utc_offset), self.code)

    def __str__(self):
        return "%s (UTC%+03d%02d)" % (
            self.code,
            (abs(self.utc_offset) / 60) * (-1 if self.utc_offset < 0 else 1),
            abs(self.utc_offset % 60),
        )

    class Meta:
        ordering = ("utc_offset",)
Esempio n. 19
0
class Address(models.Model):
    STATE = [
        ('tehran', 'تهران'),
        ('alborz', 'البرز'),
        ('markazi', 'مرکزی'),
    ]

    state = models.CharField('استان', choices=STATE, max_length=20)
    city = models.CharField('شهر', max_length=50)
    street = models.CharField('خیابان', max_length=50)
    alley = models.CharField('کوچه', max_length=50)
    number = models.CharField('پلاک', max_length=50)
    poste_code = models.CharField('کدپستی', max_length=50)
    priority_address = models.SmallIntegerField()
    location = models.PointField('موقعیت جغرافیایی')

    objects = models.Manager()
    teh_objects = TehAddressManager()
Esempio n. 20
0
class V2OfCampaigns(models.Model):
    create_date = models.DateTimeField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)
    name = models.CharField(max_length=70, blank=True, null=True)
    active = models.SmallIntegerField(blank=True, null=True)
    area = models.ForeignKey(V2OfAreas,
                             on_delete=models.CASCADE,
                             blank=True,
                             null=True)
    user = models.ForeignKey(V2OfUsers,
                             on_delete=models.CASCADE,
                             blank=True,
                             null=True)

    class Meta:
        managed = False
        db_table = 'v2of_campaigns'
        verbose_name_plural = format_lazy('{}', db_table)
Esempio n. 21
0
class GeoLocation(models.Model):
    title = models.CharField(max_length=255)
    address = models.CharField(max_length=250, blank=True, null=True)
    zoom = models.SmallIntegerField(blank=True, null=True)
    location = models.PointField(srid=4326, null=True, blank=True)

    panels = [
        FieldPanel("title"),
        MultiFieldPanel(
            [
                GeoAddressPanel("address", geocoder=geocoders.GOOGLE_MAPS),
                FieldPanel("zoom"),
                GoogleMapsPanel(
                    "location", address_field="address", zoom_field="zoom"),
            ],
            _("Geo details"),
        ),
    ]
Esempio n. 22
0
class Building(models.Model):

    objects = BuildingManager()

    general_id = models.AutoField(primary_key=True)

    risk_category = models.CharField(max_length=50, db_index=True)
    registration_number = models.IntegerField(null=True)
    examination_year = models.IntegerField(null=True)
    certified_expert = models.CharField(max_length=100, null=True)
    observations = models.CharField(max_length=1000, null=True)

    # this will need to be modified as a GIS field
    # Reffer to geo Django for details
    lat = models.FloatField(null=True)
    lng = models.FloatField(null=True)

    location = models.PointField(srid=4326, null=True, blank=True)

    county = models.CharField(max_length=60)
    address = models.CharField(max_length=250, null=True)
    post_code = models.CharField(max_length=250)
    locality = models.CharField(max_length=20)

    year_built = models.IntegerField(null=True)
    height_regime = models.CharField(max_length=50, null=True)
    apartment_count = models.IntegerField(null=True)
    surface = models.FloatField(null=True)

    cadastre_number = models.IntegerField(null=True)
    land_registry_number = models.CharField(max_length=50, null=True)
    administration_update = models.DateField(null=True, blank=True)
    admin_update = models.DateField(null=True, blank=True)

    status = models.SmallIntegerField(default=0,
                                      choices=BUILDING_STATUS_CHOICES,
                                      db_index=True)

    def __str__(self):
        return self.address

    def save(self, *args, **kwargs):
        self.location = Point(self.lng, self.lat)
        super(Building, self).save(*args, **kwargs)
Esempio n. 23
0
class TileLayer(NamedModel):
    url_template = models.CharField(
        max_length=200, help_text=_("URL template using OSM tile format"))
    minZoom = models.IntegerField(default=0)
    maxZoom = models.IntegerField(default=18)
    attribution = models.CharField(max_length=300)
    rank = models.SmallIntegerField(
        blank=True,
        null=True,
        help_text=_('Order of the tilelayers in the edit box'))
    # See https://wiki.openstreetmap.org/wiki/TMS#The_Y_coordinate
    tms = models.BooleanField(default=False)

    @property
    def json(self):
        return dict((field.name, getattr(self, field.name))
                    for field in self._meta.fields)

    @classmethod
    def get_default(cls):
        """
        Returns the default tile layer (used for a map when no layer is set).
        """
        return cls.objects.order_by('rank')[0]  # FIXME, make it administrable

    @classmethod
    def get_list(cls):
        default = cls.get_default()
        l = []
        for t in cls.objects.all():
            fields = t.json
            if default and default.pk == t.pk:
                fields['selected'] = True
            l.append(fields)
        return l

    class Meta:
        ordering = (
            'rank',
            'name',
        )
        verbose_name = 'Background map'
        verbose_name_plural = 'Background maps'
Esempio n. 24
0
class StudentsV2(models.Model):
    uid = models.CharField(max_length=256, primary_key=True)
    student_id = models.BigIntegerField(blank=True, null=True)
    school_code = models.IntegerField(blank=True, null=True)
    school_name = models.CharField(max_length=256, blank=True)
    class_num = models.SmallIntegerField(blank=True, null=True)
    cluster = models.CharField(db_index=True, max_length=256, blank=True)
    block = models.CharField(db_index=True, max_length=256, blank=True)
    district = models.CharField(db_index=True, max_length=256, blank=True)
    child_name = models.CharField(max_length=256, blank=True)
    dob = models.DateField(blank=True, null=True)
    sex = models.CharField(max_length=16, blank=True)
    father_name = models.CharField(max_length=256, blank=True)
    mother_name = models.CharField(max_length=256, blank=True)
    entry_ts = models.DateTimeField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'students_v2'
Esempio n. 25
0
class AbstractFloorPlan(TimeStampedEditableModel):
    location = models.ForeignKey('django_loci.Location',
                                 on_delete=models.CASCADE)
    floor = models.SmallIntegerField(_('floor'))
    image = models.ImageField(
        _('image'),
        upload_to=app_settings.FLOORPLAN_STORAGE.upload_to,
        storage=app_settings.FLOORPLAN_STORAGE(),
        help_text=_('floor plan image'),
    )

    class Meta:
        abstract = True
        unique_together = ('location', 'floor')

    def __str__(self):
        if self.floor != 0:
            suffix = _('{0} floor').format(ordinal(self.floor))
        else:
            suffix = _('ground floor')
        return '{0} {1}'.format(self.location.name, suffix)

    def clean(self):
        self._validate_location_type()

    def delete(self, *args, **kwargs):
        super().delete(*args, **kwargs)
        self._remove_image()

    def _validate_location_type(self):
        if not hasattr(self, 'location') or not hasattr(self.location, 'type'):
            return
        if self.location.type and self.location.type != 'indoor':
            msg = 'floorplans can only be associated ' 'to locations of type "indoor"'
            raise ValidationError(msg)

    def _remove_image(self):
        path = self.image.path
        if os.path.isfile(path):
            os.remove(path)
        else:
            msg = 'floorplan image not found while deleting {0}:\n{1}'
            logger.error(msg.format(self, path))
Esempio n. 26
0
class ClassicGeoPageWithLeafletAndZoom(Page):
    address = models.CharField(
        max_length=250,
        help_text=_("Search powered by Nominatim"),
        blank=True,
        null=True,
    )
    location = models.CharField(max_length=250, blank=True, null=True)
    zoom = models.SmallIntegerField(blank=True, null=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                GeoAddressPanel("address", geocoder=geocoders.NOMINATIM),
                FieldPanel("zoom"),
                LeafletPanel(
                    "location",
                    address_field="address",
                    zoom_field="zoom",
                    hide_latlng=True,
                ),
            ],
            _("Geo details"),
        ),
    ]

    def get_context(self, request):
        data = super().get_context(request)
        return data

    @cached_property
    def point(self):
        from wagtailgeowidget.helpers import geosgeometry_str_to_struct

        return geosgeometry_str_to_struct(self.location)

    @property
    def lat(self):
        return self.point["y"]

    @property
    def lng(self):
        return self.point["x"]
Esempio n. 27
0
class FloorPlan(TimeStampedEditableModel):
    location = models.ForeignKey('django_loci.Location')
    floor = models.SmallIntegerField(_('floor'))
    image = models.ImageField(_('image'),
                              upload_to=_get_file_path,
                              storage=OverwriteStorage(),
                              help_text=_('floor plan image'))

    class Meta:
        unique_together = ('location', 'floor')

    def __str__(self):
        return '{0} {1} {2}'.format(self.location.name, ordinal(self.floor),
                                    _('floor'))

    def delete(self, *args, **kwargs):
        path = self.image.file.name
        super(FloorPlan, self).delete(*args, **kwargs)
        os.remove(path)
Esempio n. 28
0
class County(models.Model):
    '''Minnesota county boundaries'''
    gid = models.IntegerField(primary_key=True)
    area = models.FloatField(blank=True, null=True)
    perimeter = models.FloatField(blank=True, null=True)
    county_field = models.FloatField(
        db_column='county_', blank=True,
        null=True)  # Field renamed because it ended with '_'.
    county_id = models.FloatField(blank=True, null=True)
    county_num = models.SmallIntegerField(blank=True, null=True)
    countyname = models.CharField(max_length=17, blank=True)
    countyfips = models.CharField(max_length=3, blank=True)
    fips = models.CharField(max_length=5, blank=True)
    geom = models.MultiPolygonField(blank=True, null=True)
    objects = models.GeoManager()

    class Meta:
        #        managed = False
        db_table = 'county'
Esempio n. 29
0
class OpeningHoursSpecification(models.Model):
    GR_BASE_URL = "http://purl.org/goodrelations/v1#"
    WEEK_DAYS = (
        (1, "Monday"), (2, "Tuesday"), (3, "Wednesday"), (4, "Thursday"),
        (5, "Friday"), (6, "Saturday"), (7, "Sunday"), (8, "PublicHolidays")
    )

    place = models.ForeignKey(Place, on_delete=models.CASCADE, db_index=True,
                              related_name='opening_hours')
    opens = models.TimeField(null=True, blank=True)
    closes = models.TimeField(null=True, blank=True)
    days_of_week = models.SmallIntegerField(choices=WEEK_DAYS, null=True,
                                            blank=True)
    valid_from = models.DateTimeField(null=True, blank=True)
    valid_through = models.DateTimeField(null=True, blank=True)

    class Meta:
        verbose_name = _('opening hour specification')
        verbose_name_plural = _('opening hour specifications')
Esempio n. 30
0
class Timetable(models.Model):
    bus = models.ForeignKey(Bus)
    busstop = models.ForeignKey(NBusStop)
    direction = models.SmallIntegerField(null=True, blank=True)
    time = models.TimeField(db_index=True)
    holiday = models.BooleanField(default=False)
    xeno_title = models.CharField(max_length=128, null=True, blank=True)
    order = models.IntegerField(null=True, blank=True, db_index=True)

    mon = models.BooleanField(default=False)
    tue = models.BooleanField(default=False)
    wed = models.BooleanField(default=False)
    thu = models.BooleanField(default=False)
    fri = models.BooleanField(default=False)
    sat = models.BooleanField(default=False)
    sun = models.BooleanField(default=False)

    def __unicode__(self):
        return u"%s-%s-%s" % (self.bus, self.busstop, self.time)