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

changed floor and room 'numbers' to character fields with appropriate regex...

changed floor and room 'numbers' to character fields with appropriate regex validation to support Liberty
parent 12f9bf2f
......@@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function
from django.db import models
from django.core.urlresolvers import reverse
from django.utils.text import slugify
from django.core.validators import RegexValidator
# third party imports
from model_utils.models import TimeStampedModel
from randomslugfield import RandomSlugField
......@@ -81,7 +82,8 @@ class Building(TimeStampedModel):
class Floor(TimeStampedModel):
building = models.ForeignKey('Building')
number = models.IntegerField()
number = models.CharField(max_length=1, # Mason doesn't like tall buildings
slug = RandomSlugField(length=6)
......@@ -117,13 +119,21 @@ class Floor(TimeStampedModel):
class Room(TimeStampedModel):
number = models.IntegerField()
number = models.CharField(max_length=5,
floor = models.ForeignKey('Floor')
slug = RandomSlugField(length=6)
room_num = AutoSlugField(populate_from='number',) # unique_with='floor')
def get_wing(self):
if self.number[0].isalpha():
return self.number[0]
return None
def get_absolute_url(self):
return reverse('detail_room', kwargs={
'floor': self.floor.floor_num,
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