Commit 6d3d532b authored by Tyler Hallada's avatar Tyler Hallada
Browse files

Adding last modified fields on models.

parent 5d6833ab
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Schedule.last_modified'
db.add_column('website_schedule', 'last_modified',
self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2013, 1, 28, 0, 0), blank=True),
keep_default=False)
# Adding field 'OpenTime.last_modified'
db.add_column('website_opentime', 'last_modified',
self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2013, 1, 28, 0, 0), blank=True),
keep_default=False)
# Adding field 'Restaurant.last_modified'
db.add_column('website_restaurant', 'last_modified',
self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2013, 1, 28, 0, 0), blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Schedule.last_modified'
db.delete_column('website_schedule', 'last_modified')
# Deleting field 'OpenTime.last_modified'
db.delete_column('website_opentime', 'last_modified')
# Deleting field 'Restaurant.last_modified'
db.delete_column('website_restaurant', 'last_modified')
models = {
'website.opentime': {
'Meta': {'object_name': 'OpenTime'},
'end_day': ('django.db.models.fields.IntegerField', [], {}),
'end_time': ('django.db.models.fields.TimeField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'open_times'", 'to': "orm['website.Schedule']"}),
'start_day': ('django.db.models.fields.IntegerField', [], {}),
'start_time': ('django.db.models.fields.TimeField', [], {})
},
'website.restaurant': {
'Meta': {'object_name': 'Restaurant'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'main_schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'restaurant_main'", 'to': "orm['website.Schedule']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'special_schedules': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'restaurant_special'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['website.Schedule']"})
},
'website.schedule': {
'Meta': {'object_name': 'Schedule'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'valid_end': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'valid_start': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'})
}
}
complete_apps = ['website']
\ No newline at end of file
......@@ -9,6 +9,7 @@ class Restaurant(models.Model):
related_name='restaurant_main')
special_schedules = models.ManyToManyField('Schedule',
related_name='restaurant_special', null=True, blank=True)
last_modified = models.DateTimeField('Last Modified', auto_now=True)
def isOpen(self):
"""
......@@ -44,8 +45,11 @@ class Schedule(models.Model):
"""
name = models.CharField(max_length=100)
# inclusive:
valid_start = models.DateField(null=True, blank=True)
valid_end = models.DateField(null=True, blank=True)
valid_start = models.DateField('Start Date', null=True, blank=True,
help_text='Date that this schedule goes into effect')
valid_end = models.DateField('End Date', null=True, blank=True,
help_text='Last day that this schedule is in effect')
last_modified = models.DateTimeField('Last Modified', auto_now=True)
def isOpenNow(self):
"""Return true if this schedule is open right now."""
......@@ -65,6 +69,7 @@ class OpenTime(models.Model):
start_time = models.TimeField()
end_day = models.IntegerField() # 0-6, Monday == 0
end_time = models.TimeField()
last_modified = models.DateTimeField('Last Modified', auto_now=True)
def isOpenNow(self):
"""Return true if the current time is this OpenTime's range"""
......
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