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

added method to see if Student should be able to change floor

parent 8894f89e
......@@ -4,6 +4,7 @@ import hashlib
from datetime import date
# core django imports
from django.db import models
from django.utils import timezone
from model_utils.models import TimeStampedModel
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
......@@ -127,6 +128,8 @@ class Student(TimeStampedModel):
room = models.ForeignKey(Room, null=True, blank=True)
major = models.ForeignKey('Major', null=True, blank=True)
times_changed_room = models.IntegerField(default=0)
current_year =
graduating_year = models.IntegerField(default=current_year, blank=True)
......@@ -160,6 +163,23 @@ class Student(TimeStampedModel):
return "magic"
def can_change_floor(self):
# part of TimeStampedModel
now =
created = self.created
# could make this more formal with dateutil, but...
days = (now - created).days
half_years = days / float(30 * 6)
# we want you to be able to change your room at most
# twice in a six month period before blocking you
if (self.times_changed_room / half_years) <= 2:
return True
return False
def get_floor(self):
floor =
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