Commit 0b8b9b62 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added __contains__ to Room, Floor, and Building for Students

parent 215124c3
......@@ -56,6 +56,15 @@ class Building(TimeStampedModel):
def __unicode__(self): # __unicode__ on Python 2
return unicode(self.name)
def __contains__(self, student):
try:
if student.room.floor.building == self:
return True
else:
return False
except:
return False
class Meta:
ordering = ['name']
......@@ -78,6 +87,15 @@ class Floor(TimeStampedModel):
def __str__(self): # __unicode__ on Python 2
return self.building.__str__()+" "+self.number.__str__()
def __contains__(self, student):
try:
if student.room.floor == self:
return True
else:
return False
except:
return False
class Meta:
ordering = ['building', 'number']
......@@ -101,6 +119,15 @@ class Room(TimeStampedModel):
def __str__(self): # __unicode__ on Python 2
return self.floor.building.__str__()+" "+self.number.__str__()
def __contains__(self, student):
try:
if student.room == self:
return True
else:
return False
except:
return False
class Meta:
ordering = ['number']
......
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