示例#1
0
class UserProfile(models.Model):
    """
    A user profile model for maintaining default
    delivery information and order history
    """
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    default_name = models.CharField(max_length=30, null=True, blank=True)
    default_phone_number = models.CharField(max_length=20,
                                            null=True,
                                            blank=True)
    default_street_address1 = models.CharField(max_length=80,
                                               null=True,
                                               blank=True)
    default_street_address2 = models.CharField(max_length=80,
                                               null=True,
                                               blank=True)
    default_city = models.CharField(max_length=40, null=True, blank=True)
    default_state = USStateField(max_length=9, null=True, blank=True)
    default_postcode = models.CharField(max_length=20, null=True, blank=True)
    default_country = CountryField(blank_label='Country',
                                   null=True,
                                   blank=True)

    def __str__(self):
        return self.user.username
示例#2
0
class Address(models.Model):
    label = models.CharField(max_length=200)
    street_address = models.CharField(max_length=200)
    city = models.CharField(max_length=20)
    state = USStateField(default="OH")
    zip_code = models.IntegerField()

    def __str__(self):
        return self.label
class Contact(models.Model):
    campaign = models.ForeignKey(Campaign, related_name='contacts')
    bioguide_id = models.CharField(max_length=16)
    title = models.CharField(max_length=8)
    first_name = models.CharField(max_length=32)
    last_name = models.CharField(max_length=64)
    nickname = models.CharField(max_length=32, blank=True)
    gender = models.CharField(max_length=1)
    state = USStateField()
    party = models.CharField(max_length=1)
    phone = models.CharField(max_length=16)

    position = models.CharField(max_length=1, choices=POSITIONS, default='?')
    call_goal = models.IntegerField(default=0)

    class Meta:
        ordering = ('last_name','first_name')
        unique_together = ('campaign','bioguide_id')

    def __unicode__(self):
        return u"%s %s" % (self.first_name, self.last_name)

    @models.permalink
    def get_absolute_url(self):
        return ('citizendialer3000.views.contact_detail', (self.campaign.slug, self.bioguide_id))

    def full_name(self):
        return u"%s %s" % (
            self.nickname or self.first_name,
            self.last_name,
        )

    def bio_name(self):
        return u"%s. %s %s (%s-%s)" % (
            self.title,
            self.nickname or self.first_name,
            self.last_name,
            self.party,
            self.state,
        )

    def as_dict(self):
        return {
            'campaign': self.campaign_id,
            'bioguide_id': self.bioguide_id,
            'title': self.title,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'nickname': self.nickname,
            'gender': self.gender,
            'state': self.state,
            'party': self.party,
            'phone': self.phone,
            'full_name': self.full_name(),
            'bio_name': self.bio_name(),
        }
示例#4
0
class Address(models.Model):
    agent = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
    address = models.CharField(_("address"), max_length=128, default="")
    city = models.CharField(_("city"), max_length=64, default="")
    state = USStateField(_("state"), default="")
    zip_code = models.CharField(_("zip code"), max_length=5, default="")

    def __str__(self):
        return self.address

    class Meta:
        db_table = "Address"
示例#5
0
class Address(models.Model):
    contact = models.ForeignKey(Contact)
    street = models.CharField(max_length="50")
    city = models.CharField(max_length="40")
    state = USStateField()
    zip = models.CharField(max_length="10")
    type = models.CharField(max_length="20", choices=ADR_TYPES)
    public_visible = models.BooleanField(default=False)
    contact_visible = models.BooleanField(default=False)

    def __unicode__(self):
        return '%s %s: %s %s, %s' % (self.contact.first_name,
                                     self.contact.last_name, self.street,
                                     self.city, self.state)
示例#6
0
class UsLocation(models.Model):
    label = models.CharField(max_length=200, default="New location")
    address_1 = models.CharField(_("address"), max_length=128)
    address_2 = models.CharField(_("address cont'd"),
                                 max_length=128,
                                 blank=True)
    room = models.CharField(_('room'), max_length=50, blank=True)

    city = models.CharField(_("city"), max_length=64, default="Tea")
    state = USStateField(_("state"), default="SD")
    zip_code = models.CharField(_("zip code"), max_length=5, default="57064")

    def __str__(self):
        return self.label
示例#7
0
class Company(models.Model):

    name = models.CharField(max_length=100, blank=True)
    url = models.CharField(max_length=255, primary_key=True)
    city = models.CharField(max_length=10, blank=True)
    state = USStateField(_("state"), default=" ")
    zipcode = models.CharField(_("zip code"), max_length=5, default=" ") 
    owner_email = models.EmailField(blank=True)
    owner_Name = models.CharField(max_length=100, blank=True)
    industry = models.CharField(max_length=100, blank = True)
    datetime = models.CharField(max_length=100, blank = True)
    class Meta:
        unique_together = (('name', 'url'),)
    def __str__(self):
        return self.name
示例#8
0
class Address(models.Model):
    contact = models.ForeignKey(Contact,
                                related_name='addresses',
                                on_delete=models.CASCADE)
    street = models.CharField(max_length=50)
    city = models.CharField(max_length=40)
    state = USStateField()
    zip = models.CharField(max_length=10)
    type = models.CharField(max_length=20, choices=ADR_TYPES)
    public_visible = models.BooleanField(default=False)
    contact_visible = models.BooleanField(default=False)

    def __unicode__(self):
        return '%s %s: %s %s, %s' % (self.contact.first_name,
                                     self.contact.last_name, self.street,
                                     self.city, self.state)
示例#9
0
class Incident(TimeStampedModel):
    """
    A single incident, with one or more victims.
    People will be attached to this model.
    """
    # TODO Date/Time fields
    public = models.BooleanField(default=False)
    datetime = models.DateTimeField()

    address = models.CharField("Street Address", max_length=255, blank=True)
    city = models.CharField(max_length=255, blank=True)
    state = USStateField(default=DEFAULT_STATE)
    point = models.PointField(blank=True, null=True)

    description = models.TextField(blank=True)

    # TODO boundaries

    objects = IncidentManager()

    class Meta:
        get_latest_by = "datetime"
        ordering = ('-datetime',)

    def __unicode__(self):
        if self.address:
            return u"%s %s" % (self.datetime.strftime(DATE_FORMAT), self.location)
        else:
            return u"%s %s" % (self.datetime.strftime(DATE_FORMAT), self.city)

    @property
    def location(self):
        if self.address:
            return "%s, %s, %s" % (self.address, self.city, self.state)

    def geocode(self, reset=False):
        if not self.location:
            return
        
        if not self.point or reset:
            try:
                place, (lat, lng) = list(g.geocode(self.location, exactly_one=False))[0]
                log.debug('Geocode: %s (%f, %f)', place, lat, lng)
                return Point(lng, lat)
            except Exception, e: # no results, should log this
                log.warning('Geocode failed for %s: %s', self.location, str(e))
        else:
示例#10
0
文件: models.py 项目: outhack/site_v1
class Consumer(models.Model):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female'),
    )
    ssn = EncryptedTextField()
    first_name = models.CharField(max_length=32)
    last_name = models.CharField(max_length=32)
    date_of_birth = models.DateTimeField('date of birth')
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
    address1 =  models.CharField(("address1"), max_length=128)
    address2 =  models.CharField(("address2"), max_length=128, blank=True)
    city = models.CharField(("city"), max_length=64)
    state = USStateField(("state"))
    zip_code = models.CharField(("zip code"), max_length=5)
    def __unicode__(self):
        return (self.last_name+" "+self.first_name)
示例#11
0
class Address(models.Model):
    user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)

    address = models.CharField(_("address"), max_length=128)

    city = models.CharField(_("city"), max_length=64, default="College Station")
    state = USStateField(_('state'), default="TX")
    zip_code = models.CharField(_('zip code'), max_length=5, default="77840")
    country = CountryField(_("country"), default='US')

    latitude = models.FloatField(_("latitude"), blank=True, null=True)
    longitude = models.FloatField(_("longitude"), blank=True, null=True)

    def __str__(self):
        return "{} lives in {}, {}, {}, {}, {}".format(
                self.user.username,
                self.address,
                self.city,
                self.state,
                self.zip_code,
                self.country
            )
示例#12
0
class Location(PlanItModel):
    name = f.CharField(max_length=100, null=True, default=None, blank=False)
    address_1 = f.CharField(default=None,
                            blank=True,
                            null=True,
                            max_length=100)
    address_2 = f.CharField(default=None,
                            blank=True,
                            null=True,
                            max_length=100)
    address_city = f.CharField(default=None,
                               blank=True,
                               null=True,
                               max_length=100)
    address_state = USStateField(default=None, blank=True, null=True)
    address_postal = m.CharField(default=None,
                                 blank=True,
                                 null=True,
                                 max_length=50)
    address_country = CountryField(default=None, blank=True, null=True)

    def __unicode__(self):
        return str(self.id)
class Order(models.Model):
    order_number = models.CharField(max_length=32, null=False, editable=False)
    user_profile = models.ForeignKey(UserProfile,
                                     on_delete=models.SET_NULL,
                                     null=True,
                                     blank=True,
                                     related_name='orders')
    full_name = models.CharField(max_length=50, null=False, blank=False)
    email = models.EmailField(max_length=254, null=False, blank=False)
    phone_number = models.CharField(max_length=20, null=False, blank=False)
    country = CountryField(blank_label='Country *', null=False, blank=False)
    postal_code = models.CharField(max_length=5, null=False, blank=False)
    state = USStateField(max_length=9, null=False, blank=False)
    city = models.CharField(max_length=40, null=False, blank=False)
    street_address1 = models.CharField(max_length=80, null=False, blank=False)
    street_address2 = models.CharField(max_length=80, null=True, blank=True)
    date = models.DateTimeField(auto_now_add=True)
    delivery_cost = models.DecimalField(max_digits=6,
                                        decimal_places=2,
                                        null=False,
                                        default=0)
    order_total = models.DecimalField(max_digits=10,
                                      decimal_places=2,
                                      null=False,
                                      default=0)
    grand_total = models.DecimalField(max_digits=10,
                                      decimal_places=2,
                                      null=False,
                                      default=0)
    original_bag = models.TextField(null=False, blank=False, default='')
    stripe_pid = models.CharField(max_length=254,
                                  null=False,
                                  blank=False,
                                  default='')

    def _generate_order_number(self):
        """
        Generate a random, unique order number using UUID
        """
        return uuid.uuid4().hex.upper()

    def update_total(self):
        """
        Update grand total each time a line item is added,
        accounting for delivery costs.
        """
        self.order_total = self.lineitems.aggregate(
            Sum('lineitem_total'))['lineitem_total__sum'] or 0
        self.delivery_cost = self.order_total * settings.STANDARD_DELIVERY_PERCENTAGE / 100
        self.grand_total = self.order_total + self.delivery_cost
        self.save()

    def save(self, *args, **kwargs):
        """
        Override the original save method to set the order number
        if it hasn't been set already.
        """
        if not self.order_number:
            self.order_number = self._generate_order_number()
        super().save(*args, **kwargs)

    def __str__(self):
        return self.order_number
示例#14
0
class Survey(models.Model):
    # Page 1
    age = models.IntegerField('How old are you?', max_length=3)
    state = USStateField('What state do you live in?')
    zipcode = models.CharField('In which zip code do you live?', max_length=10)
    sexual_orientation = models.CharField(
        'What best describes your sexual orientation?',
        max_length=30,
        choices=SEXUAL_ORIENTATION_CHOICES)
    sexual_orientation_other = models.CharField(
        'If you chose other for your sexual orientation, please provide it here',
        max_length=30,
        blank=True,
        null=True)
    gender_identity = models.CharField('What is your current gender identity?',
                                       max_length=40,
                                       choices=GENDER_CHOICES)
    gender_identity_other = models.CharField(
        'If you selected other for your gender identity, please provide it here.',
        max_length=40,
        blank=True,
        null=True)
    gender_assigned = models.CharField(
        'What sex were you assigned at birth, meaning on your original birth certificate?',
        max_length=20,
        choices=GENDER_CHOICES_ASSIGNED)
    ethnicity = models.CharField(
        'What best describes your racial/ethnic background?',
        help_text='(please check all that apply)',
        max_length=40,
        choices=ETHNICITY_CHOICES)
    ethnicity_other = models.CharField(
        'If you selected other for ethnicity, please provide it here.',
        max_length=40,
        blank=True,
        null=True)

    # Page 2 - The device
    current_body_shape_shoulders = models.IntegerField(max_length=3)
    current_body_shape_waist = models.IntegerField(max_length=3)
    current_body_shape_hips = models.IntegerField(max_length=3)

    ideal_body_shape_shoulders = models.IntegerField(max_length=3)
    ideal_body_shape_waist = models.IntegerField(max_length=3)
    ideal_body_shape_hips = models.IntegerField(max_length=3)

    # Page 3
    exercise_stay_health = models.CharField(
        'I exercise to stay healthy and prevent health problems.',
        max_length=1,
        choices=PAGE_THREE_CHOICE_SET)
    exercise_lose_weight = models.CharField('I exercise to lose weight.',
                                            max_length=1,
                                            choices=PAGE_THREE_CHOICE_SET)
    exercise_improve_appearance = models.CharField(
        'I exercise to improve my appearance.',
        max_length=1,
        choices=PAGE_THREE_CHOICE_SET)
    exercise_energize = models.CharField('I exercise because it energizes me.',
                                         max_length=1,
                                         choices=PAGE_THREE_CHOICE_SET)
    exercise_sport = models.CharField(
        'I exercise to train for a sport or event.',
        max_length=1,
        choices=PAGE_THREE_CHOICE_SET)
    exercise_fun = models.CharField('I exercise because I find it fun.',
                                    max_length=1,
                                    choices=PAGE_THREE_CHOICE_SET)
    exercise_muscle = models.CharField(
        'I exercise to increase my muscle mass.',
        max_length=1,
        choices=PAGE_THREE_CHOICE_SET)
    exercise_not = models.CharField('I do not exercise.',
                                    max_length=1,
                                    choices=PAGE_THREE_CHOICE_SET)

    exercise_other_reasons = models.TextField(
        'If you have any other reasons for exercising, please list them below:',
        null=True,
        blank=True)

    # Page 4
    strenuous_activity_type = models.CharField(
        'Strenuous activity (heart beats rapidly) Ex: biking fast, aerobics, running, basketball, swimming laps, rollerblading',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_EXERCISE_TYPE)
    moderate_activity_type = models.CharField(
        'Moderate exercise (not exhausting) Ex: walking quickly, easy biking, volleyball, yoga',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_EXERCISE_TYPE)
    strength_activity_type = models.CharField(
        'Exercise to Strengthen or tone your muscles. Ex: push-ups, sit-ups, weight lifting / training',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_EXERCISE_TYPE)

    strenuous_activity_days = models.CharField(
        'Strenuous activity (heart beats rapidly) Ex: biking fast, aerobics, running, basketball, swimming laps, rollerblading',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_DAYS)
    moderate_activity_days = models.CharField(
        'Moderate exercise (not exhausting) Ex: walking quickly, easy biking, volleyball, yoga',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_DAYS)
    strength_activity_days = models.CharField(
        'Exercise to Strengthen or tone your muscles. Ex: push-ups, sit-ups, weight lifting / training',
        max_length=1,
        choices=PAGE_FOUR_CHOICE_SET_DAYS)

    # Page 5
    self_esteem = models.CharField('Overall, I have high self-esteem.',
                                   max_length=1,
                                   choices=PAGE_FIVE_CHOICE_SET)
    time_to_exercise = models.CharField(
        'I do not have enough time to exercise.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_enjoyable = models.CharField('I do not find exercise enjoyable.',
                                          max_length=1,
                                          choices=PAGE_FIVE_CHOICE_SET)
    exercise_risk_age = models.CharField(
        'I\'m getting older so exercise can be risky.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_poor_health = models.CharField(
        'I have poor health so exercise can be risky.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_lack_skills = models.CharField(
        'I do not get enough exercise because I have never learned the skills for any sport.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_lack_funds = models.CharField(
        'I think it\'s too expensive to include physical activity in my life. You have to take a class or join a club or buy the right equipment.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_intimidation = models.CharField(
        'I feel intimidated about going to a gym or fitness club. I worry I won\'t know what I\'m doing and/or that others will judge me.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_encouragement = models.CharField(
        'I feel I don\'t have enough encouragement, companionship, or support from friends and family to exercise.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_get_enough = models.CharField(
        'I feel that I do get enough exercise.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    low_self_esteem = models.CharField('Overall, I have low self-esteem.',
                                       max_length=1,
                                       choices=PAGE_FIVE_CHOICE_SET)
    exercise_lack_access = models.CharField(
        'I do not have access to places to exercise.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_safety_concern = models.CharField(
        'I do not feel safe or comfortable in the fitness spaces available to me.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_inconvenient = models.CharField(
        'I find it inconvenient to exercise.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_goals = models.CharField(
        'I have difficulty setting exercise goals, monitoring progress, and rewarding my own progress towards those goals.',
        max_length=1,
        choices=PAGE_FIVE_CHOICE_SET)
    exercise_lgbtq_friendly = models.CharField(
        'Do you feel like you have access to an LGBTQ-friendly exercise environment? This could be a fitness center, classes, a park, a sports team, etc.',
        max_length=25,
        choices=PAGE_FIVE_CHOICE_SET_YNNS)
    exercise_space_friendly = models.TextField(
        'How do you know if an exercise space is LGBTQ friendly? For example, do you notice signage, staff, or other people exercising?',
        max_length=400)
    improve_lgbtq_spaces = models.TextField(
        'What could spaces or activities do to become more friendly and welcoming to the LGBTQ community?',
        max_length=400)