Commit edc2e08b authored by Daniel W Bond's avatar Daniel W Bond
Browse files

floor now optional field for student

parent e35b7f8c
...@@ -88,7 +88,7 @@ class Student(TimeStampedModel): ...@@ -88,7 +88,7 @@ class Student(TimeStampedModel):
privacy = models.CharField(max_length=100, choices=PRIVACY_CHOICES, default=FLOOR) privacy = models.CharField(max_length=100, choices=PRIVACY_CHOICES, default=FLOOR)
room = models.ForeignKey(Room) room = models.ForeignKey(Room, null=True, blank=True)
clas = models.ForeignKey(Class) clas = models.ForeignKey(Class)
major = models.ForeignKey('Major') major = models.ForeignKey('Major')
...@@ -99,12 +99,18 @@ class Student(TimeStampedModel): ...@@ -99,12 +99,18 @@ class Student(TimeStampedModel):
objects = StudentManager() objects = StudentManager()
def get_floor(self): def get_floor(self):
floor = self.room.floor try:
return floor floor = self.room.floor
return floor
except AttributeError:
return None
def get_building(self): def get_building(self):
building = self.room.floor.building try:
return building building = self.room.floor.building
return building
except AttributeError:
return None
def profile_image_url(self): def profile_image_url(self):
fb_uid = SocialAccount.objects.filter(user=self.user.id, provider='facebook') fb_uid = SocialAccount.objects.filter(user=self.user.id, provider='facebook')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment