class Department(models.Model): objects = QuerySet.as_manager() org = models.ForeignKey(Organization, on_delete=models.CASCADE) list_order = models.IntegerField(null=True, blank=True) name = models.CharField(max_length=50, null=True, blank=True) bldg = models.ForeignKey(Building, on_delete=models.CASCADE) room = models.CharField(max_length=50, null=True, blank=True) phone = models.CharField(max_length=50, null=True, blank=True) fax = models.CharField(max_length=50, null=True, blank=True) primary_comment = models.TextField(null=True, blank=True) secondary_comment = models.TextField(null=True, blank=True) last_updated = models.DateTimeField(null=True, blank=True) import_id = models.IntegerField(null=True, blank=True) keywords = fields.GenericRelation(Keyword) active = models.BooleanField(default=True) unit = models.ForeignKey(Unit, related_name='teledata_departments', blank=True, null=True, on_delete=models.SET_NULL) def __unicode__(self): return self.name def __str__(self): return self.name
class Staff(models.Model): objects = QuerySet.as_manager() alpha = models.BooleanField(default=True, null=False, blank=False) last_name = models.CharField(max_length=25, null=False, blank=False) suffix = models.CharField(max_length=3, null=True, blank=True) name_title = models.CharField(max_length=10, null=True, blank=True) first_name = models.CharField(max_length=14, null=False, blank=False) employee_id = models.CharField(max_length=8, null=True, blank=True) middle = models.CharField(max_length=15, null=True, blank=True) dept = models.ForeignKey(Department, on_delete=models.CASCADE) job_position = models.CharField(max_length=100, null=True, blank=True) bldg = models.ForeignKey(Building, on_delete=models.CASCADE) room = models.CharField(max_length=255, null=True, blank=True) phone = models.CharField(max_length=255, null=True, blank=True) email = models.EmailField(max_length=100, null=True, blank=True) email_machine = models.CharField(max_length=255, null=True, blank=True) postal = models.CharField(max_length=10, null=True, blank=True) last_updated = models.DateTimeField(null=True, blank=True) cellphone = models.CharField(max_length=50, null=True, blank=True) keywords = fields.GenericRelation(Keyword) import_id = models.IntegerField(null=True, blank=True) active = models.BooleanField(default=True) @property def full_name_formatted(self): retval = self.last_name if self.suffix: retval += ' {0}'.format(self.suffix) retval += ',' if self.name_title: retval += ' {0}'.format(self.name_title) retval += ' {0}'.format(self.first_name) if self.middle: retval += ' {0}'.format(self.middle) return retval @property def name(self): return '{0} {1}'.format(self.first_name, self.last_name) @property def sort_name(self): return '{0} {1}'.format(self.last_name, self.first_name) def __unicode__(self): return self.name def __str__(self): return self.name
class Building(models.Model): objects = QuerySet.as_manager() name = models.CharField(max_length=255, null=True, blank=True) description = models.CharField(max_length=255, null=True, blank=True) abbr = models.CharField(max_length=255, null=True, blank=True) import_id = models.IntegerField(null=True, blank=True) def __unicode__(self): return self.name def __str__(self): return self.name
def get_queryset(self): return QuerySet(self.model)