Exemple #1
0
class Event(models.Model):
    name = models.CharField(max_length=60)
    date_time = models.DateTimeField()
    location = models.CharField(max_length=200)
    zipcode = models.IntegerField()
    creator = models.ForeignKey(User)
    admin_keys = djtbx_fields.ListField()
    library_keys = djtbx_fields.ListField()

    def has_library(self, library_id):
        if library_id in self.library_keys:
            return True
        return False
Exemple #2
0
class Country(models.Model):
    class Translation(translation.Translation):
        name      = models.CharField(max_length=64, unique=True)
        full_name = models.CharField(max_length=64)

    currency        = fields.EmbeddedModelField(Currency, null=True)
    capital         = fields.EmbeddedModelField('City', null=True)   
    idc             = models.PositiveIntegerField(null=True) # Iternational Dialing Code
    iso_2           = models.CharField(max_length=2, null=True)
    iso_3           = models.CharField(max_length=3, null=True)
    iso_number      = models.PositiveIntegerField(null=True)
    tld             = models.CharField(max_length=7, null=True)
    geo             = fields.ListField(models.FloatField(), null=True)
    population      = models.PositiveIntegerField(null=True)
    continent       = fields.EmbeddedModelField(Continent, null=True)

    @property
    def calling_code(self):
        return '00%d' % self.idc
    
    def __unicode__(self):
        if hasattr(settings, 'MAX_COUNTRY_NAME_LENGTH'):
            if len(self.name) > settings.MAX_COUNTRY_NAME_LENGTH:
                return self.name[:settings.MAX_COUNTRY_NAME_LENGTH] + '...'
        return unicode(self.name)
Exemple #3
0
class Course(models.Model):
    title = models.CharField(max_length=200)
    section = models.CharField(max_length=10)
    number = models.CharField(max_length=10)
    description = tinymce_models.HTMLField()
    semester = models.ForeignKey(Semester)
    faculty = fields.ListField(fields.ForeignKey(User, related_name='faculty'))
    private = models.BooleanField(default=False, blank=True)
    members = fields.ListField(fields.ForeignKey(User, related_name='members'))

    def __unicode__(self):
        return "%s: %s %s" % (self.title, self.semester.name,
                              self.semester.year)

    class Admin:
        js = (
            'tiny_mce/tiny_mce.js',
            '/appmedia/admin/js/textareas.js',
        ),
Exemple #4
0
class State(models.Model):
    class Translation(translation.Translation):
        name = models.CharField(max_length=64)

    capital     = fields.EmbeddedModelField('City', null=True)
    country     = fields.EmbeddedModelField(Country, null=True)
    geo         = fields.ListField(models.FloatField(), null=True)
    code        = models.CharField(max_length=2)

    def __unicode__(self):
        return unicode(self.name)
Exemple #5
0
class AssignmentSubmission(models.Model):
    users = fields.ListField(fields.ForeignKey(User,
                                               related_name='submitters'))
    assignment = models.ForeignKey(Assignment)
    link = models.URLField(blank=True)
    file = models.FileField(upload_to='photos/%Y/%m/%d', blank=True)
    notes = models.TextField(blank=True)

    def __unicode__(self):
        if self.link:
            return self.link
        elif self.file:
            return self.file.name
Exemple #6
0
class City(models.Model):
    class Translation(translation.Translation):
        name = models.CharField(max_length=64)

    country     = fields.EmbeddedModelField(Country, null=True)
    state       = fields.EmbeddedModelField('State', null=True)
    population  = models.PositiveIntegerField(null=True)
    geo         = fields.ListField(models.FloatField(), null=True)

    objects = MongoDBManager()

    def __unicode__(self):
        return unicode(self.name)
Exemple #7
0
class UserProfile(models.Model):
    user = models.ForeignKey(User)

    is_dj = models.BooleanField(default=False)
    streetaddress = models.TextField(default="")
    city = models.TextField(default="")
    zipcode = models.IntegerField(default=0)
    associated_events = djtbx_fields.ListField()

    def get_display_name(self):
        if self.user.first_name and self.user.last_name:
            return "%s %s" % (self.user.first_name, self.user.last_name)
        return self.user.username
Exemple #8
0
class Library(models.Model):
    name = models.CharField(max_length=60)
    owner = models.ForeignKey(User)
    song_keys = djtbx_fields.ListField()
    song_count = models.IntegerField()

    def add_song(self, key):
        self.song_keys.append(key)
        self.song_count += 1

    def get_songs(self):
        return list(Song.objects.filter(id__in=self.song_keys))

    def str_id(self):
        return str(self.id)