Commit 259677f9 authored by Daniel Bond's avatar Daniel Bond
Browse files

Set up first restaurant object

parent 5ae7cb7b
No preview for this file type
# -*- 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.name'
db.add_column('website_schedule', 'name',
self.gf('django.db.models.fields.CharField')(default='Southside Schedule', max_length=100),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Schedule.name'
db.delete_column('website_schedule', 'name')
models = {
'website.restaurant': {
'Meta': {'object_name': 'Restaurant'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'mainSchedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'restaurant_main'", 'to': "orm['website.Schedule']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'specialSchedules': ('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'},
'dateValidEnd': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'dateValidStart': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'friClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'friOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'monClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'monOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'satClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'satOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'sunClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'sunOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'thuClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'thuOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'tueClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'tueOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'wedClose': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
'wedOpen': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'})
}
}
complete_apps = ['website']
\ No newline at end of file
...@@ -3,9 +3,10 @@ from django.db import models ...@@ -3,9 +3,10 @@ from django.db import models
class Restaurant(models.Model): class Restaurant(models.Model):
name = models.CharField(max_length = 100) name = models.CharField(max_length = 100)
mainSchedule = models.ForeignKey('Schedule', related_name = 'restaurant_main') mainSchedule = models.ForeignKey('Schedule', related_name = 'restaurant_main')
specialSchedules = models.ManyToManyField('Schedule', related_name = 'restaurant_special') specialSchedules = models.ManyToManyField('Schedule', related_name = 'restaurant_special', null = True, blank = True)
class Schedule(models.Model): class Schedule(models.Model):
name = models.CharField(max_length = 100)
dateValidStart = models.DateField(null = True, blank = True) dateValidStart = models.DateField(null = True, blank = True)
dateValidEnd = models.DateField(null = True, blank = True) dateValidEnd = models.DateField(null = True, blank = True)
monOpen = models.TimeField(null = True, blank = True) monOpen = models.TimeField(null = True, blank = True)
......
from django.conf.urls import patterns, include, url
urlpatterns = patterns('website.views',
url(r'^$', 'alpha', name = 'alpha'),
)
# Create your views here. from website.models import Restaurant, Schedule
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.conf import settings
def alpha (request):
restaurants = Restaurant.objects.all()
#pass to django template
return render_to_response('alpha.html', {'restaurants':restaurants})
# Django settings for whats_open project. # Django settings for whats_open project.
import os
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
...@@ -102,10 +103,10 @@ ROOT_URLCONF = 'whats_open.urls' ...@@ -102,10 +103,10 @@ ROOT_URLCONF = 'whats_open.urls'
# Python dotted path to the WSGI application used by Django's runserver. # Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'whats_open.wsgi.application' WSGI_APPLICATION = 'whats_open.wsgi.application'
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". os.path.join(PROJECT_PATH, 'templates'),
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
) )
INSTALLED_APPS = ( INSTALLED_APPS = (
......
{% extends 'base.html' %}
{% block content %}
<ul>
{% for restaurant in restaurants %}
<li>
{{ restaurant.name }}
</li>
{% empty %}
I love to suck cock :-O c===3
(There aren't any restaurants)
{% endfor %}
</ul>
{% endblock %}
<html>
<head>
<title>
What's Open
</title>
</head>
<body>
{% block content%}
{% endblock %}
</body>
</html>
...@@ -14,4 +14,7 @@ urlpatterns = patterns('', ...@@ -14,4 +14,7 @@ urlpatterns = patterns('',
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'', include('website.urls')),
) )
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