コード例 #1
0
class Patients(models.Model):
    id = models.AutoField(primary_key=True)
    firstName = models.CharField(max_length=100)
    lastName = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    GENDER = (
        ('Male', 'Male'),
        ('Female', 'Female'),
    )
    gender = models.CharField(choices=GENDER, max_length=20, default='Male')
    photo = models.ImageField(
        default='',
        verbose_name='Photo',
        blank=True,
    )
    address = map_fields.AddressField(max_length=200, blank=True)
    geolocation = map_fields.GeoLocationField(max_length=100, blank=True)
    contact = models.IntegerField(blank=True)
    docor_name = models.CharField(max_length=100, blank=True)
    disease_name = models.CharField(max_length=200, blank=True)
    medicine_detail = models.CharField(max_length=200, blank=True)
    emergency_contact_name = models.CharField(max_length=200, blank=True)
    emergency_contact_no = models.IntegerField(blank=True)

    dob = models.DateField(default='2018-11-11')

    def __str__(self):
        return self.firstName

    class Meta:
        verbose_name_plural = "Patients"
コード例 #2
0
ファイル: venue.py プロジェクト: Deanna2000/StudyWhere
class Venue(models.Model):
    '''
    author: Deanna Vickers
    purpose: to build out data structure for venues that can be used for studying while at NSS.
    '''
    student = models.ForeignKey(User, on_delete=models.CASCADE)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)
    latitude = models.FloatField(null=True, blank=True)
    longitude = models.FloatField(null=True, blank=True)
    name = models.CharField(max_length=100)
    description = models.CharField(max_length=255, blank=True)
    hours = models.CharField(max_length=255, blank=True)
    price = models.CharField(max_length=100, blank=True)
    venue_rating = models.IntegerField(
        default=1,
        validators=[MaxValueValidator(5),
                    MinValueValidator(1)],
        blank=True)
    food_served = models.BooleanField(default=False)
    drinks_served = models.BooleanField(default=False)
    wifi_available = models.BooleanField(default=False)
    image = models.ImageField(upload_to='image/',
                              default='image/none/no-image.jpg',
                              height_field=None,
                              width_field=None,
                              max_length=None)

    def __str__(self):
        return self.name

    class Meta:
        db_table = "venues"
コード例 #3
0
class Center(models.Model):
    name = models.TextField(blank=False)
    addres = map_fields.AddressField(max_length=200)
    aditional_information = models.TextField(blank=True,
                                             verbose_name='Place Description')
    geolocation = map_fields.GeoLocationField(max_length=100)
    slug = AutoSlugField(unique=True, populate_from='name', always_update=True)
    user = models.OneToOneField(User,
                                unique=True,
                                null=True,
                                related_name='center')
    free = models.BooleanField(default=False)
    service = models.ManyToManyField(Service, through='ServiceCenter')

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('Center:center_detail', args=[
            self.slug,
        ])

    def save(self, *args, **kwargs):
        self.geolocation = self.addres
        super().save(*args, **kwargs)
コード例 #4
0
class Googlemap(models.Model):
    place_name = models.CharField(max_length=30, verbose_name='장소 이름')
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)

    def __str__(self):
        return self.place_name
コード例 #5
0
class Location(RulesModel):
    class Meta:
        rules_permissions = {
            "add": pred.is_super_admin | pred.is_admin | pred.is_editor,
            "view": rules.always_allow,
            "change": pred.is_super_admin | pred.is_admin | pred.is_editor,
            "delete": pred.is_super_admin | pred.is_admin,
        }

    name = models.CharField(max_length=100, unique=True)
    description = models.CharField(blank=True, null=True, max_length=300)
    country = CountryField()
    postal_code = models.CharField(blank=True, null=True, max_length=20)
    city = models.CharField(blank=True, null=True, max_length=30)
    state = models.CharField(blank=True, null=True, max_length=30)
    street = models.CharField(blank=True, null=True, max_length=30)
    address = map_fields.AddressField(max_length=200, null=True)
    geolocation = map_fields.GeoLocationField(max_length=100, null=True)
    map_zoom = models.FloatField(default=14)

    def belongs_to_host(self, host):
        return True

    def lat(self):
        return self.geolocation.lat

    def lng(self):
        return self.geolocation.lon

    def __str__(self):
        return self.name + " (" + self.country.name + ")"
コード例 #6
0
class LocationTrack(models.Model):
    id = models.AutoField(primary_key=True)
    patient_id = models.ForeignKey(Patients, on_delete=models.CASCADE)
    address = map_fields.AddressField(max_length=200, blank=True)
    geolocation = map_fields.GeoLocationField(max_length=100, blank=True)
    date = models.DateField(blank=True)
    time = models.TimeField(blank=True)
コード例 #7
0
ファイル: models.py プロジェクト: nlyubchich/aquila
class WaterIntakePoint(models.Model):
    name = models.CharField(max_length=200, null=False, blank=False)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField()

    def __str__(self):
        return "{name} ({address})".format(name=self.name, address=self.address)
コード例 #8
0
class Address(TimestampedMixin, NexusModel):
    address1 = models.CharField(max_length=512)
    address2 = models.CharField(max_length=512, null=True, blank=True)
    city = models.CharField(max_length=512)
    county = models.CharField(max_length=32, null=True, blank=True)
    state = models.CharField(max_length=32)
    latitude = models.CharField(max_length=32, null=True, blank=True)
    longitude = models.CharField(max_length=32, null=True, blank=True)
    google_address = map_fields.AddressField(max_length=200,
                                             null=True,
                                             blank=True)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              null=True,
                                              blank=True)
    zipcode = models.CharField(max_length=16)
    property = models.ForeignKey('Property')

    class Meta:
        ordering = ['state', 'city', 'zipcode', 'address1']

    @property_
    def uri(self):
        from .api import AddressResource
        return AddressResource().get_resource_uri(self)

    def json(self):
        from api import AddressResource
        res = AddressResource()
        bundle = res.build_bundle(obj=self)
        return res.serialize(None, res.full_dehydrate(bundle),
                             'application/json')
コード例 #9
0
ファイル: models.py プロジェクト: abdikaalbiyan/P_Asset
class AssetMasyarakat(models.Model):
    owner = models.ForeignKey(CustomUser,
                              on_delete=models.CASCADE,
                              default=None)
    kode_asset = models.CharField(blank=True, max_length=100)
    nama = models.CharField(blank=True, max_length=100)
    merk = models.CharField(blank=True, max_length=100)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    tahun_pembuatan = models.PositiveIntegerField(
        default=current_year(),
        validators=[MinValueValidator(1970), max_value_current_year])
    umur_asset = models.CharField(blank=True, max_length=100)
    harga = models.FloatField(blank=True, null=True)
    tgl_beli = models.DateTimeField(blank=True, null=True)
    lokasi = models.CharField(blank=True, max_length=100)
    deskripsi = models.TextField(blank=True)
    foto = models.ImageField(blank=True)
    surat_kepemilikan = models.TextField(blank=True)
    latitude = models.FloatField(blank=True, null=True)
    longitude = models.FloatField(blank=True, null=True)
    google_places_id = models.CharField(max_length=255, blank=True)

    address = map_fields.AddressField(max_length=200,
                                      blank=True,
                                      null=True,
                                      default=None)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              blank=True,
                                              null=True,
                                              default=None)

    def __str__(self):
        return f"[{self.kode_asset}, {self.nama}]"
コード例 #10
0
ファイル: models.py プロジェクト: oxigenocc/oxigeno.cc
class Distribuidor(models.Model):
    id = models.AutoField(primary_key=True)
    nombre_distribuidor = models.CharField(max_length=100)
    horario = models.CharField(max_length=100)
    estado = models.CharField(max_length=50)
    direccion = models.TextField()    
    ciudad = models.CharField(max_length=100)
    a_domicilio =  models.BooleanField()
    pago_con_tarjeta = models.BooleanField()
    notas = models.TextField(null=True, blank=True)
    notas_internas = models.TextField(null=True, blank=True)
    telefono = models.CharField(max_length=20)
    whatsapp = models.CharField(max_length=20, null=True, blank= True)
    link_pagina = models.CharField(max_length=100, null=True, blank=True)        
    address = map_fields.AddressField(max_length=200, default='')
    geolocation = map_fields.GeoLocationField(max_length=100, default='')
    dar_de_baja = models.BooleanField(default=False)
    fecha_creacion = models.DateTimeField(auto_now_add=True)
    ultima_actualizacion = models.DateTimeField(auto_now=True)
    abre_sabado = models.BooleanField(default=True)
    abre_domingo = models.BooleanField(default=True)
    abre_24h = models.BooleanField(default=True)
    recarga_gratis = models.BooleanField(default=False)
    history = HistoricalRecords()

    class Meta: 
        verbose_name_plural = "distribuidores"


    def __str__(self):
        return self.nombre_distribuidor
コード例 #11
0
ファイル: models.py プロジェクト: xyzuva/Meetup-Finder
class Events(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null = True)
    organizer = models.CharField(max_length=200)
    name = models.CharField("Event Name", max_length=200)
    comment = models.CharField("Details", max_length=1000)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(null=True, max_length=100)
    event_date = models.DateField(null=True)
    event_time = models.TimeField(null=True)

    class Meta:
        verbose_name_plural = "Events"
        permissions = (
            ('can_delete', 'Can delete event'),
        )

    def __str__(self):
        return self.name

    def is_past(self):
        event_datetime = datetime.datetime(self.event_date.year,
                                           self.event_date.month,
                                           self.event_date.day,
                                           self.event_time.hour,
                                           self.event_time.minute,
                                           self.event_time.second,
                                           self.event_time.microsecond,
                                           timezone.now().tzinfo)
        return event_datetime < timezone.now()
コード例 #12
0
class Vendor(TimeStamped, Titled):
    """
    A vendor that offers product / services to parents
    """
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)
    geolocation_updated = models.DateTimeField(blank=True, null=True)

    phone = models.CharField("Phone", max_length=100)
    email = models.EmailField("Email", max_length=254, blank=True)
    website = models.CharField("Website", max_length=100, blank=True)
    description = models.TextField("Description", blank=True)

    subjects = models.ManyToManyField(Subject, related_name="vendors")
    types = models.ManyToManyField(Type, related_name="vendors")

    class Meta:
        ordering = ["title"]

    @property
    def geolocation_update_allowed(self):
        """
        Only allow geolocation updates if the vendor has been updated at least one minute
        after the last geolocation attempt.

        This is a crude way to make sure we don't continually attempt geolocation updates
        on vendors that have wrong or nonexistent addresses.
        """
        if self.geolocation_updated is None:
            return True
        return (self.updated -
                self.geolocation_updated) > timedelta(seconds=60)

    def update_geolocation(self, force=False):
        """
        Attempt to get new coordinates based on a vendor's address.
        """
        if not force and not self.geolocation_update_allowed:
            raise GeolocationError(
                "{} has not been updated since last geocode attempt".format(
                    self))

        error = None
        api = googlemaps.Client(key=settings.GOOGLE_MAPS_API_KEY)
        try:
            result = api.geocode(self.address)
            self.geolocation.lat = result[0]["geometry"]["location"]["lat"]
            self.geolocation.lon = result[0]["geometry"]["location"]["lng"]
        except googlemaps.exceptions.ApiError as e:
            error = "API error ({}) when processing {}".format(e, self)
        except IndexError:
            error = "No geolocation results found for {}".format(self)

        # Always save to keep track of the latest geolocation attempt, even if failed
        self.geolocation_updated = now()
        self.save()

        if error:
            raise GeolocationError(error)
コード例 #13
0
ファイル: models.py プロジェクト: redfors/realty
class Realty(models.Model):
    STATUS_CHOICES = (
        ('draft', 'Draft'),
        ('published', 'Published'),
    )
    name = models.CharField("Name", max_length=150)
    url = models.SlugField(max_length=250, unique=True)
    overview = models.CharField("Overview", max_length=255)
    image = models.ImageField(upload_to='images/%Y/%m/%d', null=True)
    description = models.TextField("Description")
    description_data = models.TextField("Description data")
    description_details = models.TextField("Detailed description")
    place = models.TextField("Object location")
    address = map_fields.AddressField(max_length=200, default='Любляна')
    geolocation = map_fields.GeoLocationField(
        max_length=100, default='46.05187370933915,14.506043267333983')
    code = models.CharField("Code", max_length=50)
    type = models.CharField("Type", max_length=255)
    area = models.CharField("Area", max_length=255)
    floor_number = models.CharField("Floor number", max_length=255)
    namber_of_floors = models.CharField("Namber of floors", max_length=255)
    price = models.CharField("Price", max_length=255)
    buiding = models.CharField("Buiding", max_length=255)
    adaptation = models.CharField("Adaptation", max_length=255)
    rooms = models.CharField("Rooms", max_length=255)
    garage = models.BooleanField("Garage")
    pool = models.BooleanField("Pool")
    furniture = models.BooleanField("Furniture")
    air_conditioner = models.BooleanField("Air conditioner")

    status_realty = models.ForeignKey(StatusesRealty,
                                      on_delete=models.CASCADE,
                                      verbose_name="Status realty",
                                      blank=True,
                                      null=True)
    user = models.ForeignKey(Profile,
                             on_delete=models.CASCADE,
                             verbose_name="User",
                             blank=True,
                             null=True)
    created = models.DateTimeField('Created', auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    delited = models.DateTimeField(auto_now=True)

    published = models.CharField('Status',
                                 max_length=10,
                                 choices=STATUS_CHOICES,
                                 default='draft')

    def get_absolute_url(self):
        return reverse('realty_details', kwargs={'slug': self.url})

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = """object"""
        verbose_name_plural = """objects"""
コード例 #14
0
class Entity(models.Model):
    text = models.TextField(max_length=200)
    version = models.ForeignKey(Version,
                                related_name='entity',
                                on_delete=models.CASCADE)
    created_by = models.ForeignKey(User,
                                   related_name='entity',
                                   on_delete=models.CASCADE)
    geolocation = map_fields.GeoLocationField(max_length=100)
コード例 #15
0
ファイル: models.py プロジェクト: derrick-gopher/googlemaps
class Rental(models.Model):
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=200)

    class Meta:
        verbose_name_plural = "Rentals"

    def __str__(self):
        return self.address
コード例 #16
0
ファイル: models.py プロジェクト: Maliksel/biciurban
class Ruta(models.Model):
    nombre = models.CharField(max_length=200)
    valor = models.IntegerField(max_length=200)
    address = map_fields.AddressField(max_length=200,
                                      verbose_name='Dirección',
                                      blank=True,
                                      null=True)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              verbose_name='Coordenada Inicio',
                                              blank=True,
                                              null=True)
    geolocation2 = map_fields.GeoLocationField(max_length=100,
                                               verbose_name='Coordenada Final',
                                               blank=True,
                                               null=True)

    def __str__(self):
        return str(self.nombre)
コード例 #17
0
ファイル: models.py プロジェクト: graytoli/pt_br_etym_dict
class Region(models.Model):
    name = models.CharField(max_length=164)
    # latitude = models.FloatField(default=0)
    # longitude = models.FloatField(default=0)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)

    def __str__(self):
        return self.name
コード例 #18
0
ファイル: models.py プロジェクト: JulianArdila/Class
class Escuela(models.Model):
    nombre = models.CharField(max_length=200)
    address = map_fields.AddressField(max_length=200,
                                      verbose_name='Dirección',
                                      blank=True,
                                      null=True)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              verbose_name='Coordenadas',
                                              blank=True,
                                              null=True)
コード例 #19
0
class Mapa(models.Model):
    name = models.CharField(max_length=200, db_index=True)
    slug = models.SlugField(max_length=200, unique=True)
    image = models.ImageField(upload_to='products/%Y/%m/%d',
                              blank=True)
    description = models.TextField(blank=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)
    available = models.BooleanField(default=True)
コード例 #20
0
class Sede(models.Model):
    nombre_sede = models.CharField(max_length=30)
    tipo_sede = models.CharField(max_length=30)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    def __str__(self):
        return '%s %s' % (self.nombre_sede, self.tipo_sede)
コード例 #21
0
ファイル: models.py プロジェクト: abdikaalbiyan/P_Asset
class EP(models.Model):
    kode_ep = models.CharField(blank=True, max_length=100)
    nama_ep = models.CharField(blank=True, max_length=100)
    lokasi = models.CharField(blank=True, max_length=100)
    google_places_id = models.CharField(max_length=255, blank=True)

    address = map_fields.AddressField(max_length=200, blank=True, null=True, default=None)
    geolocation = map_fields.GeoLocationField(max_length=100, blank=True, null=True, default=None)

    def __str__(self):
        return self.kode_ep
コード例 #22
0
class Usuarios(models.Model):

    nombre = models.CharField(max_length=15)
    apellido = models.CharField(max_length=20)
    ciudad = models.CharField(max_length=11)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)
    estadogeo = models.BooleanField(default=False)

    def save(self, *args, **kwargs):
        self.estadogeo = True
        return super(Usuarios, self).save(*args, **kwargs)
コード例 #23
0
ファイル: models.py プロジェクト: fedesoft231/bogotrash
class Queja(models.Model):
    descripcion = models.CharField(max_length=500)
    fecha_creacion = models.DateTimeField(auto_now_add=True)
    foto = models.ImageField(upload_to='img/fotosapp/', blank=True, null=True)
    address = map_fields.AddressField(max_length=200,
                                      verbose_name='Dirección',
                                      blank=True,
                                      null=True)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              verbose_name='Coordenadas',
                                              blank=True,
                                              null=True)
    user = models.ForeignKey(Usuario, on_delete=models.CASCADE)
コード例 #24
0
class Department(models.Model):
    city = models.CharField(_('Город'), max_length=128, null=True)
    address = map_fields.AddressField(_('Адрес [ru]'), max_length=128)
    address_ua = models.CharField(_('Адрес [ua]'), max_length=255, null=True)
    geolocation = map_fields.GeoLocationField(max_length=100, null=True)
    schedule = models.CharField(_('Режим работы'), max_length=128)
    phone = models.CharField(_('Телефон'), max_length=32)
    email = models.EmailField(_('Электронная почта'), max_length=64)

    class Meta:
        verbose_name = _('Отделение')
        verbose_name_plural = _('Отделения')

    def __str__(self):
        return self.address if self.address else str(self.id)
コード例 #25
0
ファイル: models.py プロジェクト: Acon94/ACRE
class Listing(models.Model):
    AMENITY_CHOICES = (
        ('Air Conditioned', 'Air Conditioned'),
        ('Board Aproval Required', 'Board Aproval Required'),
        ('Doorman', 'Doorman'),
        ('Dishwasher', 'Dishwasher'),
        ('Elevator', 'Elevator'),
        ('Furnished', 'Furnished'),
        ('Fireplace', 'Fireplace'),
        ('Loft', 'Loft'),
        ('Sublet', 'Sublet'),
        ('Storage', 'Storage'),
        ('Wash/Dryer in unit', 'Wash/Dryer in unit'),
        ('Public outdoor area', 'Public outdoor area'),
        ('Private outdoor area', 'Private outdoor area'),
        ('Pets allowed', 'Pets allowed'),
        ('Parking', 'Parking'),
        ('Smoke free', 'Smoke free'),
        ('Gym', 'Gym'),
        ('Has Parking', 'Has Parking'),
    )
    realtor = models.ForeignKey(Realtor, on_delete=models.DO_NOTHING)
    title = models.CharField(max_length=200)
    address = models.CharField(max_length=200)
    city = models.CharField(max_length=200)
    state = models.CharField(max_length=200)
    zipcode = models.CharField(max_length=200)
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100, blank=True)
    description = models.TextField(blank=True)
    price = models.IntegerField()
    bedrooms = models.IntegerField()
    bathrooms = models.DecimalField(max_digits=2, decimal_places=1)
    sqft = models.IntegerField()
    amenitys = MultiSelectField(choices=AMENITY_CHOICES)
    lot_size = models.DecimalField(max_digits=5, decimal_places=1)
    photo_main = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_1 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_2 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_3 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_4 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_5 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    photo_6 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True)
    is_published = models.BooleanField(default=True)
    list_date = models.DateTimeField(default=datetime.now, blank=True)

    def __str__(self):
        return self.title
コード例 #26
0
class Jobform(models.Model):
    #user = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    company = models.ForeignKey(CompanyProfile, on_delete=models.CASCADE)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    jobtype = models.ForeignKey(Jobtype, on_delete=models.CASCADE)
    description = models.TextField()

    datenow = datetime.date(datetime.now())
    timenow = datetime.time(datetime.now())

    postdate = models.DateField()
    posttime = models.TimeField()

    deadlinedate = models.DateField()
    deadlinetime = models.TimeField()

    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)

    salary_min = models.IntegerField()
    salary_max = models.IntegerField()

    US_author_required = models.BooleanField(default=False)

    def open(self):
        if self.postdate == self.datenow:
            return self.posttime <= self.timenow
        if self.deadlinedate == self.datenow:
            return self.deadlinetime >= self.timenow
        return (self.deadlinedate > self.datenow
                and self.postdate < self.datenow)

    def age(self):
        diff = datetime.now().date() - self.postdate
        if diff == 0:
            return "today"
        elif diff == 1:
            return "1 day"
        else:
            return "{} days".format(diff.days)

    def save(self, *args, **kwargs):
        created = self.pk is None
        super(Jobform, self).save(*args, **kwargs)
        if created:
            Category.objects.filter(name=self.category.name).update(
                count=F('count') + 1)
コード例 #27
0
ファイル: models.py プロジェクト: imadarshj/covaid
class DonationCenter(models.Model):
    name = models.CharField(max_length=200)
    photo = models.ImageField(upload_to='photos/%Y/%m/%d/',
                              null=True,
                              blank=True)
    description = models.TextField(blank=True)
    phone = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    is_approved = models.BooleanField(default=False)
    is_verified = models.BooleanField(default=False)
    address = map_fields.AddressField(max_length=200, null=True, blank=True)
    geolocation = map_fields.GeoLocationField(max_length=100,
                                              null=True,
                                              blank=True)

    def __str__(self):
        return self.name

    def send_account_creation_email_to_system_admin(self):
        """Send notification email to system admin on account creation."""
        recipient = '*****@*****.**'
        send_mail(
            'Donation Center Account Creation Request',
            'Dear BDSG Admin ',
            '\n' + self.name +
            ' has requested for an account creation. You can view the donation center details at http://127.0.0.1:8000/admin/donations/donationcenter/'
            + self.id + '/',
            '*****@*****.**', [recipient],
            fail_silently=False)

    def send_activation_email_to_donation_center(self):
        """Send notification email to donation center on activation."""
        recipient = self.email
        send_mail(
            'Account activation',
            'Dear ' + self.name + ', \n' +
            'Your account has been created at BDSG. You can view the website at http://127.0.0.1:8000/',
            '*****@*****.**', [recipient],
            fail_silently=False)

    def save(self, *args, **kwargs):
        """Ensure validations are run and updated/created preserved."""
        self.full_clean(exclude=None)
        if self.is_approved and self.is_verified:
            self.send_activation_email_to_donation_center()
        if not self.is_approved and self.is_verified:
            self.send_account_creation_email_to_system_admin()
        super(DonationCenter, self).save(*args, **kwargs)
コード例 #28
0
class CustomUser(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(_("email address"), unique=True)
    username = models.CharField(unique=True, max_length=200)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    date_joined = models.DateTimeField(default=timezone.now)
    is_superuser = models.BooleanField(default=False)
    first_name = models.CharField(max_length=200)
    last_name = models.CharField(max_length=200)
    address = map_fields.AddressField(max_length=200, null=True)
    geolocation = map_fields.GeoLocationField(max_length=100, null=True)
    dob = models.DateTimeField(null=True, blank=True, default=timezone.now)
    phone = models.CharField(max_length=200, blank=True)
    phone_activated = models.BooleanField(default=False)
    phone_activation_code = models.CharField(max_length=200)
    genderChoices = [("Male", "Male"), ("Female", "Female"),
                     ("Other", "Other")]
    gender = models.CharField(max_length=200,
                              choices=genderChoices,
                              default="Male")
    profile_image = models.ImageField(blank=True)
    cover_photo = models.ImageField(blank=True)
    facebook_link = models.CharField(max_length=200, blank=True)
    twitter_link = models.CharField(max_length=200, blank=True)
    instagram_link = models.CharField(max_length=200, blank=True)
    youtube_link = models.CharField(max_length=200, blank=True)
    linkedin_link = models.CharField(max_length=200, blank=True)
    sendEmail = models.BooleanField(default=True)
    sendSMS = models.BooleanField(default=True)
    activation = models.CharField(max_length=200)

    class Meta:
        verbose_name = "User"
        verbose_name_plural = "Users"

    objects = AccountManager()

    USERNAME_FIELD = "email"
    REQUIRED_FIELDS = []

    def __str__(self):
        return self.email

    def save(self, *args, **kwargs):
        self.username = self.email
        super(CustomUser, self).save(*args, **kwargs)
コード例 #29
0
class Lead(models.Model):
    choices_measure = (
        ('KG', 'KG'),
        ('Gram', 'Gram'),
        ('Unit', 'Unit'),
    )

    def __str__(self):
        return "Food: %s - Kind of food: %s" % (self.food, self.kindoffood)

    email = models.EmailField(unique=True)
    kindoffood = models.CharField(
        "Kind",
        max_length=200,
        help_text="What kind of food the ducks are fed?")
    food = models.CharField("Food",
                            max_length=200,
                            help_text="What food the ducks are fed?")
    how_much_food = models.PositiveIntegerField(
        "How much food?", help_text="KG, grams or units")  #value in grams
    measure = models.CharField(
        "Measure",
        max_length=4,
        help_text="What is the usual measure of the food the ducks are fed?",
        choices=choices_measure,
        default="KG")

    how_many_ducks = models.PositiveIntegerField(
        "Number of ducks", help_text="How many ducks are fed?")
    fed_time = models.TimeField("Time",
                                help_text="What time the ducks are fed?")

    fed_everyday = models.BooleanField(
        "Feed everyday?",
        blank=True,
        help_text="Do you feed the ducks everyday?")
    address = map_fields.AddressField(
        help_text="What is the address where the ducks are fed?",
        blank=True,
        max_length=200)
    geolocation = map_fields.GeoLocationField(
        help_text="What are the coordinates where the ducks are fed?",
        blank=True,
        max_length=100)
    created_at = models.DateTimeField(verbose_name="Data created in",
                                      auto_now_add=True)
コード例 #30
0
class Request(models.Model):
    sender = models.ForeignKey(TUser,
                               models.SET_NULL,
                               related_name="TUser_sender",
                               blank=True,
                               null=True)
    recipient = models.ForeignKey(TUser,
                                  models.SET_NULL,
                                  related_name="TUser_recipient",
                                  blank=True,
                                  null=True)
    subject = models.CharField(max_length=500, default="")
    description = models.CharField(max_length=500, default="")
    address = map_fields.AddressField(
        max_length=200, default="164 McCormick Rd, Charlottesville, VA 22903")
    geolocation = map_fields.GeoLocationField(max_length=100, default="")
    latitude = models.FloatField(default=38.036460)
    longitude = models.FloatField(default=-78.506080)