Commit 09d202f9 authored by Ben Waters's avatar Ben Waters
Browse files

Added Time Stamped Model

parent b7174125
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.db import models from django.db import models
from model_utils.models import TimeStampedModel
import datetime import datetime
class Category(TimeStampedModel):
class BaseModel(models.Model):
last_modified = models.DateTimeField('Last Modified', auto_now=True)
class Category(BaseModel):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
class Facility(BaseModel): class Facility(TimeStampedModel):
"""Represents a dining location on campus.""" """Represents a dining location on campus."""
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
category = models.ForeignKey('Category', related_name="facilities", null=True, blank=True) category = models.ForeignKey('Category', related_name="facilities", null=True, blank=True)
...@@ -50,7 +47,7 @@ class Facility(BaseModel): ...@@ -50,7 +47,7 @@ class Facility(BaseModel):
return self.name return self.name
class Schedule(BaseModel): class Schedule(TimeStampedModel):
""" """
Contains opening and closing times for each day in a week. Contains opening and closing times for each day in a week.
...@@ -79,7 +76,7 @@ class Schedule(BaseModel): ...@@ -79,7 +76,7 @@ class Schedule(BaseModel):
return self.name return self.name
class OpenTime(BaseModel): class OpenTime(TimeStampedModel):
"""Represents a period time when a Facility is open""" """Represents a period time when a Facility is open"""
schedule = models.ForeignKey('Schedule', related_name='open_times') schedule = models.ForeignKey('Schedule', related_name='open_times')
start_day = models.IntegerField() # 0-6, Monday == 0 start_day = models.IntegerField() # 0-6, Monday == 0
......
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