Exemple #1
0
class ActiveEdu(m.Model):
    name = f.CharField(max_length=100, null=True, default=None, blank=False)
    domain = f.CharField(max_length=50, null=True, default=None, blank=False)
    url = f.URLField(max_length=500, null=True, default=None, blank=False)
    active = f.BooleanField(default=True)

    class Meta:
        db_table = "university"

    def __unicode__(self):
        return self.name
class FooterLink(m.DataModel):
    item_name = f.CharField(max_length=50, default=None, null=True, blank=False)
    item_link = f.CharField(max_length=150, default=None, null=True, blank=False)
    item_created = f.DateTimeField(default=None, null=True, blank=True, auto_now_add=True)
    item_active = f.BooleanField(default=False, blank=True)
    item_sort_order = f.IntegerField(default=0, null=True, blank=True, unique=True)
    item_requires_login = f.BooleanField(default=False, blank=True)
    item_requires_anon = f.BooleanField(default=False, blank=True)
    item_visible_lg = f.BooleanField(default=True, blank=True)
    item_visible_md = f.BooleanField(default=True, blank=True)
    item_visible_sm = f.BooleanField(default=True, blank=True)
    item_visible_xs = f.BooleanField(default=True, blank=True)

    class Meta:
        db_table = "MB_FOOTER_LINK"
        verbose_name = "Footer Link"
        verbose_name_plural = "Footer Links"
class MenuItem(m.Model):
    item_name = f.CharField(max_length=50, default=None, null=True, blank=False)
    item_link = f.CharField(max_length=150, default=None, null=True, blank=False)
    item_created = f.DateTimeField(default=None, null=True, blank=True, auto_now_add=True)
    item_active = f.BooleanField(default=False, blank=True)
    item_sort_order = f.IntegerField(default=0, null=True, blank=True)
    item_parent = f.IntegerField(default=0, null=True, blank=True)
    item_slug = f.CharField(max_length=20, default=None, null=True, blank=True)
    item_requires_login = f.BooleanField(default=False, blank=True)
    item_requires_anon = f.BooleanField(default=False, blank=True)
    item_glyph = f.CharField(max_length=100, default=None, null=True, blank=True)
    item_visible_lg = f.BooleanField(default=True, blank=True)
    item_visible_md = f.BooleanField(default=True, blank=True)
    item_visible_sm = f.BooleanField(default=True, blank=True)
    item_visible_xs = f.BooleanField(default=True, blank=True)

    class Meta:
        db_table = "MB_MENU_ITEM"
        verbose_name = "Menu Item"
        verbose_name_plural = "Menu Items"

    def __unicode__(self):
        return self.item_name
Exemple #4
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)
Exemple #5
0
class Trip(PlanItModel):
    name = f.CharField(max_length=100, null=True, default=None, blank=False)
    descr = f.TextField(max_length=1000, null=True, default=None, blank=True)
    start_loc = m.ForeignKey(Location,
                             null=True,
                             blank=True,
                             default=None,
                             related_name='starting_locations',
                             on_delete=m.CASCADE)
    arrive_loc = m.ForeignKey(Location,
                              null=True,
                              blank=True,
                              default=None,
                              related_name='arriving_locations',
                              on_delete=m.CASCADE)
    return_loc = m.ForeignKey(Location,
                              null=True,
                              blank=True,
                              default=None,
                              related_name='ending_locations',
                              on_delete=m.CASCADE)
    return_home = f.BooleanField(default=True, blank=True)
    start_dt = f.DateTimeField(null=True, blank=False, default=None)
    arrive_dt = f.DateTimeField(null=True, blank=False, default=None)
    return_dt = f.DateTimeField(null=True, blank=False, default=None)
    current_members = f.IntegerField(default=0, blank=True, null=True)
    requested_members = f.IntegerField(default=0, blank=True, null=True)
    open = f.BooleanField(default=False, blank=True, db_column='is_open')

    objects = TripManager()

    class Meta:
        db_table = "trip"

    def add_gas_car(self, user, gas, car, accepted=False):
        p = TripParty()
        p.gas = gas
        p.car = car
        p.trip = self
        p.user = user
        p.accepted = accepted
        p.save()
        self.party.add(p)
        self.save()
        return p

    def add_to_party(self, user, accepted=False):
        p = TripParty()
        p.trip = self
        p.user = user
        p.accepted = accepted
        p.save()
        self.party.add(p)
        self.save()
        return p

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        if self.get_open_seats() == 0:
            self.open = False
        super(PlanItModel, self).save(*args, **kwargs)

    def get_current_members(self):
        return (self.party.filter(accepted=True).count() +
                self.current_members) - 1

    def get_open_seats(self):
        # print "test:"
        # print int(self.requested_members) % 2
        return (int(self.requested_members) -
                self.party.filter(accepted=True).count()) + 1