示例#1
0
class USPlace(models.Model):
    state = USStateField(blank=True)
    state_req = USStateField()
    state_default = USStateField(default="CA", blank=True)
    postal_code = USPostalCodeField(blank=True)
    name = models.CharField(max_length=20)
    ssn = USSocialSecurityNumberField(blank=True)
示例#2
0
class Company(models.Model):
    name = models.CharField(max_length=500)
    category = models.CharField(max_length=100)
    funding_total = models.DecimalField(max_digits=20, decimal_places=9)
    status = models.CharField(max_length=20)
    country = CountryField()
    us_state = USStateField()
    us_city = models.CharField(max_length=200)
    funding_rounds = models.IntegerField()
    number_of_investors = models.IntegerField()
    acquirer = models.CharField(max_length=200, null=True, blank=True)
    acquirer_category = models.CharField(max_length=100, null=True, blank=True)
    acquirer_country = CountryField(null=True, blank=True)
    acquirer_us_state = USStateField(null=True, blank=True)
    acquirer_us_city = models.CharField(max_length=200, null=True, blank=True)
    acquired_price = models.DecimalField(max_digits=25,
                                         decimal_places=5,
                                         null=True,
                                         blank=True)
    acquired_currency = models.CharField(max_length=3, null=True, blank=True)
    county = models.CharField(max_length=100)
    founded_at = models.IntegerField()
    coordinates = PointField(null=True, blank=True)

    @property
    def latitude(self):
        return self.coordinates.coords[1]

    @property
    def longitude(self):
        return self.coordinates.coords[0]

    def __str__(self):
        return self.name
示例#3
0
class Video(models.Model):
    title = models.CharField(max_length=100)
    file = models.FileField(null=True)
    uploader = models.ForeignKey(User,
                                 null=True,
                                 on_delete=models.CASCADE,
                                 related_name='uploaded_videos')

    jobtypes = models.ManyToManyField(Jobtype, related_name='videos')
    tribals = models.ManyToManyField(Tribal)
    city = models.CharField(max_length=20, null=True)
    state = USStateField(null=True)
    remote = models.BooleanField(default=False)

    role = models.CharField(max_length=1,
                            choices=(('T', 'Tech'), ('M', 'MBA / Management')))

    categories = models.ManyToManyField(Category, related_name='videos')
    experiences = models.ManyToManyField(Experience, related_name='videos')

    savers = models.ManyToManyField(User, related_name='saved_videos')
    submitted_videos1 = models.ManyToManyField('self',
                                               related_name='submitted_too',
                                               symmetrical=False)
    submitted_videos = models.ManyToManyField('self',
                                              related_name='submitted_to',
                                              symmetrical=False,
                                              through='Submission')

    def get_absolute_url(self):
        return reverse('watch', kwargs={'pk': self.pk})

    def __str__(self):
        return f'{self.title}'
示例#4
0
class Company(models.Model):

    company_name = models.CharField(max_length=256, blank=False)
    legal_name = models.CharField(max_length=256, blank=True)
    website = models.URLField(max_length=200)
    primary_contact = models.ForeignKey('Contact',
                                        on_delete=models.CASCADE,
                                        null=True,
                                        blank=True)
    address = models.TextField(max_length=255, blank=True, null=True)
    address_line_two = models.TextField(max_length=255, blank=True, null=True)
    city = models.TextField(max_length=255, blank=True, null=True)
    state = USStateField(null=True, blank=True)
    zip_code = USZipCodeField(null=True, blank=True)
    country = models.CharField(max_length=256, blank=True)
    logo = models.ImageField(upload_to='request_form_app/company_logo',
                             height_field='logo_height',
                             width_field='logo_width',
                             null=True,
                             blank=True)
    logo_height = models.IntegerField(blank=True, null=True)
    logo_width = models.IntegerField(blank=True, null=True)
    company_code = models.TextField(max_length=6, blank=True, null=True)

    def __str__(self):
        return self.company_name

    def get_absolute_url(self):
        return reverse('user_console:company_detail', kwargs={'pk': self.pk})
示例#5
0
class CustomUser(AbstractUser):
    #Username, password, first name, last name, email will all be created from User, do not need to be defined here
    USER_TYPE_CHOICES = [
        ('S', 'Shelter'),
        ('P', 'Pet Parent')
    ]

    FREQ_TYPE_CHOICES = [
        ('N', 'Never'),
        ('I', 'Immediately'),
    ]

    user_type = models.CharField(max_length=2, choices=USER_TYPE_CHOICES, default='P')
    phone_number = models.CharField(max_length=40, blank=True)
    street_number = models.CharField(max_length=40, blank=True)
    street_name = models.CharField(max_length=40, blank=True)
    city = models.CharField(max_length=40, blank=True)
    state = USStateField(null=False, blank=False)
    zip = models.CharField(max_length=40, blank=True)
    document = models.FileField(upload_to='documents/', blank=True)
    profilePic = models.ImageField(upload_to='userPics/', blank=True)

    #Automatically track date
    created_at = models.DateField(auto_now_add=True)
    updated_at = models.DateField(auto_now=True)
    notify = models.CharField(max_length=2, choices=FREQ_TYPE_CHOICES, default='N')

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return "/user/%i/" % self.id
示例#6
0
class User(AbstractUser):
    username = models.CharField(max_length=30, unique=True, null=False)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    email = models.CharField(max_length=150, unique=True, null=False)
    bio = models.TextField(max_length=1000, blank=True)
    city = models.CharField(max_length=30, blank=True)
    zipcode = USZipCodeField(null=True, blank=True)
    state = USStateField(null=True, blank=True)
    country = models.CharField(max_length=30,
                               blank=True,
                               default="United States")
    birth_date = models.DateField(null=True, blank=True)
    organization = models.CharField(max_length=30, blank=True)
    passcode = models.CharField(max_length=15, blank=True)
    mentor = models.BooleanField(default=False)
    image = models.ImageField(upload_to='profile_images', blank=True)
    tags = TaggableManager(blank=True, verbose_name='Skills & Interests')

    class Meta(object):
        unique_together = ('email', )

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse('account:index', kwargs={'pk': self.pk})

    def tag_string(self):
        tags = self.tags.all()
        tags_list = []
        for tag in tags:
            tags_list.append(tag.name)

        return ', '.join(tags_list)
示例#7
0
class Page(models.Model):
    person = models.ForeignKey(Person)
    slug = models.CharField(max_length=200)
    city = models.CharField(max_length=200)
    state = USStateField()
    country = CountryField(default='US')
    zipcode = USZipCodeField(default=10012)
    title = models.CharField(max_length=200)
    key_words = models.CharField(max_length=200)
    description = models.TextField(blank=True)
    primary_latitude = models.FloatField(null=True)
    primary_longitude = models.FloatField(null=True)

    def get_absolute_url(self):
        return reverse('person_detail_page',
                       args=[
                           self.id, self.state,
                           self.city.replace(" ", "-").replace(
                               "(",
                               "").replace(")",
                                           "").replace("'",
                                                       "-").replace(".", ""),
                           self.slug.replace(".", "-")
                       ])

    def __str__(self):
        return "{0} {1} {2}".format(self.slug, self.state, self.city)
示例#8
0
class Profile(models.Model):
    BOOL_CHOICES = ((True, 'Yes'), (False, 'No'))
    GENDER_CHOICES = (('M', 'Male'), ('F', 'Female'))
    user = models.OneToOneField(settings.AUTH_USER_MODEL,
                                on_delete=models.CASCADE)
    date_of_birth = models.DateField(blank=True, null=True)
    photo = models.ImageField(upload_to='users/%Y/%m/%d/', blank=True)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
    bio = models.TextField(max_length=500, blank=True)
    address_1 = models.CharField(max_length=128)
    address_2 = models.CharField(max_length=128, blank=True)
    city = models.CharField(max_length=64)
    state = USStateField(choices=STATE_CHOICES)
    zip_code = models.CharField(max_length=32, db_index=True, blank=False)
    phone_number = PhoneNumberField(null=False, blank=False)
    created_date = models.DateTimeField(default=now, editable=False)
    is_parent = models.BooleanField(choices=BOOL_CHOICES, default=True)
    is_teacher = models.BooleanField(choices=BOOL_CHOICES, default=False)

    class Meta:
        ordering = ('zip_code', )
        verbose_name = 'profile'
        verbose_name_plural = 'profiles'

    def __str__(self):
        return f'Profile for user {self.user.username}'

    def get_absolute_url(self):
        return reverse('profile_detail', args=[str(self.id)])
示例#9
0
文件: models.py 项目: ohsk/mapusaurus
class Branch(models.Model):
    year = models.SmallIntegerField()
    institution = models.ForeignKey('Institution', to_field='institution_id')
    name = models.CharField(max_length=50)
    street = models.CharField(max_length=100)
    city = models.CharField(max_length=25)
    state = USStateField()
    zipcode = models.IntegerField()
    lat = models.FloatField(help_text='y')
    lon = models.FloatField(help_text='x')

    def branch_as_geojson(self):
        """Convert this model into a geojson string"""
        geojson = {'type': 'Feature',
                   'properties': {
                       'year': self.year,
                       'institution_id': self.institution_id,
                       'name': self.name,
                       'street': self.street,
                       'city': self.city,
                       'state': self.state,
                       'zipcode': self.zipcode,
                       'lat': self.lat,
                       'lon': self.lon}}
        geojson = json.dumps(geojson)
        return geojson
示例#10
0
class CustomUser(AbstractUser):
    full_name = models.CharField(max_length=50, blank=False)
    address1 = models.CharField(max_length=100, blank=False)
    address2 = models.CharField(max_length=100, blank=True)
    city = models.CharField(max_length=100, blank=False)
    state = USStateField()
    zipcode = USZipCodeField()
示例#11
0
class Adjustment(models.Model):

    POINTS = 'P'
    RATE = 'R'

    AFFECT_RATE_TYPE_CHOICES = ((POINTS, 'Points'), (RATE, 'Rate'))

    CONDO = 'CONDO'
    COOP = 'COOP'
    CASHOUT = 'CASHOUT-REFI'

    PROPERTY_TYPE_CHOICES = ((CONDO, 'Condo'), (COOP, 'Co-op'),
                             (CASHOUT, 'Cash-out refinance'))

    rule_id = models.IntegerField()
    product = models.ForeignKey(Product)
    affect_rate_type = models.CharField(max_length=1,
                                        choices=AFFECT_RATE_TYPE_CHOICES)
    adj_value = models.DecimalField(max_digits=6, decimal_places=3, null=True)
    min_loan_amt = models.DecimalField(max_digits=12,
                                       decimal_places=2,
                                       null=True)
    max_loan_amt = models.DecimalField(max_digits=12,
                                       decimal_places=2,
                                       null=True)
    prop_type = models.CharField(max_length=18,
                                 null=True,
                                 choices=PROPERTY_TYPE_CHOICES)
    min_fico = models.IntegerField(null=True)
    max_fico = models.IntegerField(null=True)
    min_ltv = models.DecimalField(max_digits=6, decimal_places=3, null=True)
    max_ltv = models.DecimalField(max_digits=6, decimal_places=3, null=True)
    state = USStateField(null=True)
    data_timestamp = models.DateTimeField()
示例#12
0
class Grower(models.Model):
    name = models.CharField(max_length=40)

    address_one = models.CharField(max_length=60, blank=True, null=True)
    address_two = models.CharField(max_length=40, blank=True, null=True)
    city = models.CharField(max_length=70)
    state = USStateField()
    zip_code = USZipCodeField()

    email = models.EmailField(max_length=80)
    web_site = models.URLField(max_length=100, blank=True, null=True)
    twitter = models.URLField(max_length=80, blank=True, null=True)
    instagram = models.URLField(max_length=80, blank=True, null=True)
    youtube = models.URLField(max_length=80, blank=True, null=True)

    biography = models.TextField(
        blank=True, null=True, default='Bio not available.')
    image = models.ImageField(blank=True, null=True, upload_to='growers/')
    slug = models.SlugField(blank=True, null=True, unique=True)

    class Meta:
        ordering = ['name']

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.name:
            self.slug = slugify(self.name)
        super(Grower, self).save(*args, **kwargs)
示例#13
0
class SchoolDistrict(models.Model):
    class DistrictTypes:
        PUBLIC, PUBLIC_CHARTER, RELIGIOUS, INDEPENDENT = [
            'PUBLIC', 'PUBLIC_CHARTER', 'RELIGIOUS', 'INDEPENDENT'
        ]
        choices = ((PUBLIC, 'Public'), (PUBLIC_CHARTER, 'Public charter'),
                   (RELIGIOUS, 'Religious'), (INDEPENDENT, 'Independent'))

    user = models.ForeignKey('users.User',
                             on_delete=models.CASCADE,
                             null=True,
                             editable=False)
    district_type = models.CharField(choices=DistrictTypes.choices,
                                     max_length=100,
                                     default=DistrictTypes.PUBLIC)
    name = models.CharField(max_length=200)
    address = models.TextField()
    state_province = USStateField(blank=True, default='')
    nation = CountryField(default='US')
    phone = models.CharField(max_length=200)
    website = models.URLField(blank=True, default='')
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    memo = models.TextField(blank=True, default='')
    is_active = models.BooleanField(default=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = 'school district'
        verbose_name_plural = 'school districts'
示例#14
0
class Plug(models.Model):
    RATINGS_CHOICES = [
        (1, 'Straight Trash'),
        (2, 'Kinda Sketchy'),
        (3, 'Clutch'),
        (4, 'Da Plug'),
        (5, 'El Chapo')
    ]

    user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(blank=True, null=True,
                              upload_to='accounts/customers/{}'.format(user))
    bio = models.TextField(max_length=600)
    twitter = models.URLField(max_length=80, blank=True, null=True)
    instagram = models.URLField(max_length=80, blank=True, null=True)
    youtube = models.URLField(max_length=80, blank=True, null=True)
    birth_date = models.DateField(blank=True, null=True)
    address_one = models.CharField(max_length=60, blank=True, null=True)
    address_two = models.CharField(max_length=40, blank=True, null=True)
    city = models.CharField(max_length=70)
    state = USStateField()
    zip_code = USZipCodeField()
    plug_rating = models.IntegerField(
        choices=RATINGS_CHOICES, blank=True, null=True)

    def calculate_age(self):
        current_date = datetime.datetime.today()
        user_birthdate = '%s/%s/%s' % (str(self.birth_date.year),
                                       str(self.birth_date.month), str(self.birth_date.day))
        user_birthdate = datetime.datetime.strptime(user_birthdate, '%Y/%m/%d')
        age = (current_date - user_birthdate)/365.2424
        return age

    class Meta:
        ordering = ['user', '-plug_rating']
示例#15
0
class League(models.Model):
    """
    Implicit fields:
        huddles
        suggestions
    """
    name = models.CharField(max_length=50)
    description = models.CharField(max_length=260)
    country = CountryField()
    city = models.CharField(max_length=20)
    state = USStateField(blank=True, null=True, choices=STATE_CHOICES)
    date_created = models.DateTimeField(default=timezone.now)
    is_private = models.BooleanField(default=False)

    head_official = models.ForeignKey(SH_User,
                                      related_name='HOfficial_of',
                                      on_delete=models.CASCADE)
    officials = models.ManyToManyField(SH_User, related_name='Official_of')
    members = models.ManyToManyField(SH_User, related_name='LM_of')

    def __str__(self):
        return self.name

    def is_member(self, sh_user):
        return sh_user in self.members.all()

    def is_official(self, sh_user):
        return sh_user in self.officials.all()

    def is_head_official(self, sh_user):
        return sh_user == self.head_official
class DoctorDetail(models.Model):
    # This line is required. Links UserProfile to a User model instance.

    doctor_first_name = models.CharField(max_length=50, default="Victor")
    doctor_last_name = models.CharField(max_length=50, default="Vitals")
    name_suffix = models.CharField(max_length=10, default="M.D.")
    license_number = models.CharField(max_length=8, default='A8039V92')
    prescription_network_id = models.CharField(max_length=13,
                                               default='8841038281943')
    dea = models.CharField(max_length=8, default='83059667')
    doctor_phone_number = models.CharField(max_length=14,
                                           default='(717) 444-0880')

    address_1 = models.CharField(_("address"),
                                 max_length=128,
                                 default="Grand Pasteur Clinic")
    address_2 = models.CharField(_("address cont'd"),
                                 max_length=128,
                                 default="515 Hamilton Ave")
    city = models.CharField(_("city"), max_length=64, default="Fullerton")
    state = USStateField(_("state"), default="CA")
    zip_code = models.CharField(_("zip code"), max_length=5, default='92652')

    def __str__(self):
        return self.doctor_last_name
class UserDetail(models.Model):
    # This line is required. Links UserProfile to a User model instance.
    user = models.OneToOneField(User)

    GENDER_CHOICES = ((
        'Female',
        'female',
    ), (
        'Male',
        'male',
    ))
    # The additional attributes we wish to include.

    phone_number = models.CharField(max_length=14, null=True)
    address_1 = models.CharField(_("address"), max_length=128, blank=True)
    address_2 = models.CharField(_("address cont'd"),
                                 max_length=128,
                                 blank=True)
    city = models.CharField(_("city"), max_length=64, default="Fullerton")
    state = USStateField(_("state"), default="CA")

    #state = USStateField(choices = STATE_CHOICES, default="CA" )

    zip_code = models.CharField(_("zip code"), max_length=5, default='92614')
    insurance = models.CharField(max_length=50, null=True)
    date_of_birth = models.CharField(max_length=10, null=True)
    gender = models.CharField(max_length=50, choices=GENDER_CHOICES, null=True)

    def __str__(self):
        return self.user.username
示例#18
0
class Profile(models.Model):
    user = models.OneToOneField(User,
                                on_delete=models.CASCADE,
                                null=True,
                                blank=True)
    address = models.CharField(max_length=250, null=True, blank=True)
    city = models.CharField(max_length=50, null=True, blank=True)
    state = USStateField(null=True, blank=True)
    zipcode = USZipCodeField(null=True, blank=True)
    phone_number = PhoneField(null=True, blank=True)
    phone_type = models.CharField(max_length=10,
                                  choices=PHONE_TYPE_CHOICES,
                                  default='MOBILE')
    birth_date = models.DateField(auto_now=False,
                                  auto_now_add=False,
                                  null=True,
                                  blank=True)
    gender = models.CharField(max_length=10,
                              choices=GENDER_CHOICES,
                              default='MALE')
    passport_number = models.IntegerField(null=True, blank=True)
    passport_expiration = models.DateField(auto_now=False,
                                           auto_now_add=False,
                                           null=True,
                                           blank=True)
    newsletter = models.BooleanField(default=True)
示例#19
0
class Venue(models.Model):
    title = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    state = USStateField()
    zipcode = USZipCodeField(blank=True)
    slug = models.SlugField(blank=True, null=True, max_length=255)
    phone = PhoneNumberField(blank=True)
    url = models.URLField(blank=True)
    email = models.EmailField(blank=True)
    description = models.TextField(blank=True)
    keywords = models.CharField(blank=True, max_length=255)
    point = models.PointField(blank=True, null=True)
    objects = models.GeoManager()

    def save(self, *args, **kwargs):
        if not self.slug:
            candidate_slug = slugify(self.title)[0:255]
            if self.__class__.objects.filter(slug=candidate_slug).exists():
                candidate_slug_counter = 1
                while True:
                    if not self.__class__.objects.filter(
                            slug="%s-%s" %
                        (candidate_slug, candidate_slug_counter)).exists():
                        break
                    candidate_slug_counter += 1

            self.slug = candidate_slug
        if self.address and not self.point:
            self.point = Point(**get_point(', '.join(
                [self.address, self.city, self.state, self.zipcode])))
        return super(Venue, self).save(*args, **kwargs)

    def __unicode__(self):
        return self.title
示例#20
0
class LegacyUser(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    middle_name = models.CharField(max_length=50, null=True, blank=True)
    email = models.EmailField(max_length=254)
    address = models.CharField(max_length=250, null=True, blank=True)
    city = models.CharField(max_length=50, null=True, blank=True)
    state = USStateField(null=True, blank=True)
    zipcode = USZipCodeField(null=True, blank=True)
    phone_number = PhoneField(null=True, blank=True)
    phone_type = models.CharField(max_length=10,
                                  choices=PHONE_TYPE_CHOICES,
                                  default='MOBILE')
    birth_date = models.DateField(auto_now=False,
                                  auto_now_add=False,
                                  null=True,
                                  blank=True)
    gender = models.CharField(max_length=10,
                              choices=GENDER_CHOICES,
                              default='MALE')
    passport_number = models.IntegerField(null=True, blank=True)
    passport_expiration = models.DateField(auto_now=False,
                                           auto_now_add=False,
                                           null=True,
                                           blank=True)
    newsletter = models.BooleanField(default=True)
示例#21
0
class School(models.Model):
    name = models.TextField()
    slug = models.SlugField(max_length=256, unique=True)
    url = models.URLField(unique=True)
    milestones_url = models.URLField()
    rolling = models.BooleanField(default=False)
    city = models.CharField(max_length=128, null=True)
    state = USStateField(null=True)
    audit_notes = models.TextField(
        help_text="Notes to make performing audits easier",
        null=True,
        blank=True)
    # Using a regular FileField instead of ImageField to avoid bringing in Pillow.
    image = models.FileField(
        help_text="The school logo or seal at 400x400",
        upload_to=school_image_path,
        null=True,
        blank=True,
    )
    ipeds_id = models.CharField(
        unique=True,
        null=True,
        blank=True,
        max_length=8,
        help_text="The school's IPEDS ID from the Department of Education",
    )

    objects = SchoolManager()

    def __str__(self) -> str:
        return self.name
示例#22
0
class UserAddress(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=120)
    address = models.CharField(max_length=120)
    address2 = models.CharField(max_length=120, null=True, blank=True)
    city = models.CharField(max_length=120)
    country = models.CharField(max_length=120, default="USA")
    state = USStateField()
    zipcode = USZipCodeField()
    phone = PhoneNumberField()
    shipping = models.BooleanField(default=True)
    billing = models.BooleanField(default=True)
    timestamp = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.get_address()

    def get_address(self):
        return "{}, {}, {}, {}, {}, {}".format(self.name, self.address,
                                               self.city, self.state,
                                               self.country, self.zipcode)

    objects = UserAddressManager()

    class Meta:
        ordering = ['-updated', '-timestamp']
示例#23
0
class Person(models.Model):
    first_name = models.CharField(max_length=200)
    middle_name = models.CharField(max_length=200, null=True, blank=True)
    last_name = models.CharField(max_length=200)
    nick_name = models.CharField(max_length=200, null=True, blank=True)
    facebook_full_name = models.CharField(max_length=200,
                                          null=True,
                                          blank=True)
    facebook_link = models.URLField(max_length=200, null=True, blank=True)
    linkedin_link = models.URLField(max_length=200, null=True, blank=True)
    phone_number = PhoneNumberField(null=True, blank=True, default=8052845564)
    email = models.EmailField(null=True, blank=True)
    date_of_birth = models.DateField()
    RACE = (('W', 'White'), ('AA', 'African American'), ('A', 'Asian'),
            ('AI', 'American Indian'))
    race = models.CharField(max_length=2, choices=RACE)
    GENDER = (('M', 'Male'), ('F', 'Female'))
    gender = models.CharField(max_length=1, choices=GENDER)
    address = models.CharField(max_length=200)
    state = USStateField()
    city = models.CharField(max_length=50)
    zipcode = USZipCodeField()
    country = CountryField(default='US')

    def __str__(self):
        return "{0} {1} {2}".format(self.first_name, self.middle_name,
                                    self.last_name)
示例#24
0
class location(models.Model):
    city = models.CharField(max_length=255, null=True, blank=True, default="")
    state = USStateField(choices=STATE_CHOICES, null=True, blank=True)
    zipcode = models.CharField(max_length=255,
                               null=True,
                               blank=True,
                               default='')
    geocode = models.CharField(max_length=255,
                               null=True,
                               blank=True,
                               default='')
    status = models.CharField(max_length=255,
                              null=True,
                              blank=True,
                              choices=WATER_STATUS,
                              default="info")
    keywords = models.CharField(max_length=255,
                                null=True,
                                blank=True,
                                default='')
    created = models.DateTimeField(null=True, auto_now_add=True)

    def save(self, *args, **kwargs):

        geolocator = Nominatim()
        geoc = geolocator.geocode("%s %s" % (self.city, self.state.lower()),
                                  timeout=10)
        self.geocode = 'longitude=%s, latitude=%s, radius=5' % (geoc.latitude,
                                                                geoc.longitude)
        return super(location, self).save(*args, **kwargs)

        def __unicode__(self):
            return '%s,%s' % (self.city, self.state)
示例#25
0
class Employer(models.Model):
    name = models.CharField(max_length=250)
    location = models.ForeignKey(Location, null=True)
    state = USStateField(null=True)

    def __str__(self):
        return self.name
示例#26
0
class StumpUser(AbstractUser):
    # password: use default implementation from superclass
    # last_login: use default implementation from superclass
    # username: use default implementation from superclass
    # first_name: use default implementation from superclass
    # last_name: use default implementation from superclass
    email = models.EmailField(
        _('email address'),
        unique=True,
        error_messages={
            'unique': _("A user with that email already exists."),
        })
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['username']
    # is_staff: use default implementation from superclass
    # is_active: use default implementation from superclass
    # date_joined: use default implementation from superclass

    objects = StumpUserManager()

    # Stump voter specific fields
    language = models.CharField(max_length=10,
                                choices=settings.LANGUAGES,
                                default=settings.LANGUAGE_CODE)
    address = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    state = USStateField(choices=STATE_CHOICES)
    zip_code = USZipCodeField()
    latitude = models.FloatField(blank=True, null=True)
    longitude = models.FloatField(blank=True, null=True)
示例#27
0
class Educator(models.Model):
    """ An educator has to fill out this form before they can download vouchers
    for their students. """

    ORG_CHOICES = (('S', 'School'), ('O', 'Qualified organization'))

    name = models.CharField(_("Educator's full name"), max_length=128)
    work_email = models.CharField(_("Work email address"),
                                  max_length=128,
                                  null=True)
    organization_name = models.CharField(_("School or organization name"),
                                         max_length=128)
    org_or_school = models.CharField(_(""), max_length=1, choices=ORG_CHOICES)
    address_line_1 = models.CharField(_("Address line 1"), max_length=128)
    address_line_2 = models.CharField(_("Address line 2"),
                                      max_length=128,
                                      null=True,
                                      blank=True)
    city = models.CharField(_("City"), max_length=50)
    state = USStateField(_("State"), blank=False, null=False)
    zipcode = USZipCodeField(_("Zip"))
    num_students = models.IntegerField(
        _("Number of students"),
        validators=[
            MaxValueValidator(
                50, _('You can only print up to 50 passes at a time.')),
            MinValueValidator(1, _('You can not print less than one pass.'))
        ],
        help_text="Number of students for which you are requesting vouchers")
示例#28
0
class Agency(WhoAndWhenBase):
    """A government or NGO organization which manages ``Opportunities``.
    """
    id = models.IntegerField(primary_key=True, verbose_name=_('id'))
    name = models.CharField(
        max_length=255,
        unique=True,
        verbose_name=_('name'))
    mission = models.TextField(blank=True, verbose_name=_('mission'))
    phone = models.CharField(
        blank=True,
        max_length=255,
        verbose_name=_('phone'))
    fax = models.CharField(blank=True, max_length=255, verbose_name=_('fax'))
    email = models.EmailField(blank=True, verbose_name=_('email'))
    address = models.TextField(blank=True, verbose_name=_('address'))
    municipality = models.CharField(
        blank=True,
        max_length=255,
        verbose_name=_('municipality'))
    state = USStateField(blank=True)
    postal_code = USZipCodeField(blank=True)  # zip is a global function
    web = models.URLField(max_length=255, blank=True, verbose_name=_('web'))

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = _('Agency')
        verbose_name_plural = _('Agencies')
示例#29
0
class Address(models.Model):
    event = models.OneToOneField(Event, related_name="event_address")
    street_number = models.IntegerField(null=True)
    street = models.CharField(max_length=255, default='')
    city = models.CharField(max_length=255, default='')
    state = USStateField(default='')
    zipcode = USZipCodeField(default='')
示例#30
0
class Store(models.Model):
    name = models.CharField(max_length=50)
    city = models.CharField(max_length=50, blank=True, default="")
    state = USStateField(blank=True)

    def __unicode__(self):
        return self.name