Commit 8038b40c authored by Daniel W Bond's avatar Daniel W Bond
Browse files

this was more confusing than I thought it would be

parent c8c192cc
...@@ -128,7 +128,7 @@ class Student(TimeStampedModel): ...@@ -128,7 +128,7 @@ class Student(TimeStampedModel):
room = models.ForeignKey(Room, null=True, blank=True) room = models.ForeignKey(Room, null=True, blank=True)
major = models.ForeignKey('Major', null=True, blank=True) major = models.ForeignKey('Major', null=True, blank=True)
times_changed_room = models.IntegerField(default=0) times_changed_room = models.PositiveIntegerField(default=0)
current_year = date.today().year current_year = date.today().year
graduating_year = models.IntegerField(default=current_year, blank=True) graduating_year = models.IntegerField(default=current_year, blank=True)
...@@ -163,7 +163,7 @@ class Student(TimeStampedModel): ...@@ -163,7 +163,7 @@ class Student(TimeStampedModel):
else: else:
return "magic" return "magic"
def can_change_floor(self): def recent_changes(self):
# part of TimeStampedModel # part of TimeStampedModel
now = timezone.now() now = timezone.now()
created = self.created created = self.created
...@@ -171,14 +171,10 @@ class Student(TimeStampedModel): ...@@ -171,14 +171,10 @@ class Student(TimeStampedModel):
# could make this more formal with dateutil, but... # could make this more formal with dateutil, but...
days = (now - created).days days = (now - created).days
half_years = days / float(30 * 6) # must be int-- floor function
third_years = (days / (30 * 4)) + 1
# we want you to be able to change your room at most return (self.times_changed_room / third_years)
# twice in a six month period before blocking you
if (self.times_changed_room / half_years) <= 2:
return True
else:
return False
def get_floor(self): def get_floor(self):
try: try:
......
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