Commit 14656fc4 authored by Ben Waters's avatar Ben Waters
Browse files

testing cbv's

parent aa7d21a1
......@@ -133,12 +133,8 @@ INSTALLED_APPS = (
'django.contrib.admindocs',
'south',
'rest_framework',
<<<<<<< HEAD
'whats-open-site',
=======
'guardian',
'website',
>>>>>>> eb3014873211749b338992b8cac80d87309c23e8
'whats_open_site',
#'guardian',
)
ANONYMOUS_USER_ID = -1
......
from django.conf.urls import patterns, url
from . import views
from rest_framework.routers import DefaultRouter
#router = DefaultRouter()
urlpatterns = patterns('whats_open_sites.views',
url(r'^(?:ajax|api)/schedule/', 'ajax_schedule_data', name='schedule_data'),
url(r'^$', 'facility_grid', name='facility_grid'),
#facilities open urls
url(r'^facilities/$', FacilitiesListView.as_view(), name='faciliites-list'),
url(r'^facilities/(?P<category>/$', ),
url(r'^facilities/(?P<slug>/$', FacilitiesDetailView.as_view(), name='facilities-detail'),
url(r'^facilities/(?P<on_campus>/$', ),
#schedules urls
url(r'^schedule/(?P<id>/$', ScheduleDetailView.as_view(), name='schedule-detail'),
#opentime urls
url(r'^open-time/(?P<id>/$', OpenTimeDetailView.as_view(), name='open-time-detail'),
)
# -*- 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 model 'BaseModel'
db.create_table('website_basemodel', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
))
db.send_create_signal('website', ['BaseModel'])
# Adding model 'Facility'
db.create_table('website_facility', (
('basemodel_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['website.BaseModel'], unique=True, primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
('main_schedule', self.gf('django.db.models.fields.related.ForeignKey')(related_name='facility_main', to=orm['website.Schedule'])),
))
db.send_create_signal('website', ['Facility'])
# Adding M2M table for field special_schedules on 'Facility'
db.create_table('website_facility_special_schedules', (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('facility', models.ForeignKey(orm['website.facility'], null=False)),
('schedule', models.ForeignKey(orm['website.schedule'], null=False))
))
db.create_unique('website_facility_special_schedules', ['facility_id', 'schedule_id'])
# Adding model 'Schedule'
db.create_table('website_schedule', (
('basemodel_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['website.BaseModel'], unique=True, primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
('valid_start', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
('valid_end', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
))
db.send_create_signal('website', ['Schedule'])
# Adding model 'OpenTime'
db.create_table('website_opentime', (
('basemodel_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['website.BaseModel'], unique=True, primary_key=True)),
('schedule', self.gf('django.db.models.fields.related.ForeignKey')(related_name='open_times', to=orm['website.Schedule'])),
('start_day', self.gf('django.db.models.fields.IntegerField')()),
('start_time', self.gf('django.db.models.fields.TimeField')()),
('end_day', self.gf('django.db.models.fields.IntegerField')()),
('end_time', self.gf('django.db.models.fields.TimeField')()),
))
db.send_create_signal('website', ['OpenTime'])
def backwards(self, orm):
# Deleting model 'BaseModel'
db.delete_table('website_basemodel')
# Deleting model 'Facility'
db.delete_table('website_facility')
# Removing M2M table for field special_schedules on 'Facility'
db.delete_table('website_facility_special_schedules')
# Deleting model 'Schedule'
db.delete_table('website_schedule')
# Deleting model 'OpenTime'
db.delete_table('website_opentime')
models = {
'website.basemodel': {
'Meta': {'object_name': 'BaseModel'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'website.opentime': {
'Meta': {'object_name': 'OpenTime', '_ormbases': ['website.BaseModel']},
'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'end_day': ('django.db.models.fields.IntegerField', [], {}),
'end_time': ('django.db.models.fields.TimeField', [], {}),
'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.facility': {
'Meta': {'object_name': 'Facility', '_ormbases': ['website.BaseModel']},
'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'main_schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'facility_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': "'facility_special'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['website.Schedule']"})
},
'website.schedule': {
'Meta': {'object_name': 'Schedule', '_ormbases': ['website.BaseModel']},
'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['website.BaseModel']", 'unique': 'True', 'primary_key': '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']
# -*- 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 'Facility.location'
db.add_column(u'website_facility', 'location',
self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Facility.location'
db.delete_column(u'website_facility', 'location')
models = {
u'website.basemodel': {
'Meta': {'object_name': 'BaseModel'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
u'website.opentime': {
'Meta': {'object_name': 'OpenTime', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'end_day': ('django.db.models.fields.IntegerField', [], {}),
'end_time': ('django.db.models.fields.TimeField', [], {}),
'schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'open_times'", 'to': u"orm['website.Schedule']"}),
'start_day': ('django.db.models.fields.IntegerField', [], {}),
'start_time': ('django.db.models.fields.TimeField', [], {})
},
u'website.facility': {
'Meta': {'object_name': 'Facility', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'main_schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'facility_main'", 'to': u"orm['website.Schedule']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'special_schedules': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'facility_special'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['website.Schedule']"})
},
u'website.schedule': {
'Meta': {'object_name': 'Schedule', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': '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']
# -*- 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 'Restaurant.location'
db.add_column(u'website_restaurant', 'location',
self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Restaurant.location'
db.delete_column(u'website_restaurant', 'location')
models = {
u'website.basemodel': {
'Meta': {'object_name': 'BaseModel'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
u'website.opentime': {
'Meta': {'object_name': 'OpenTime', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'end_day': ('django.db.models.fields.IntegerField', [], {}),
'end_time': ('django.db.models.fields.TimeField', [], {}),
'schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'open_times'", 'to': u"orm['website.Schedule']"}),
'start_day': ('django.db.models.fields.IntegerField', [], {}),
'start_time': ('django.db.models.fields.TimeField', [], {})
},
u'website.restaurant': {
'Meta': {'object_name': 'Restaurant', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'main_schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'restaurant_main'", 'to': u"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': u"orm['website.Schedule']"})
},
u'website.schedule': {
'Meta': {'object_name': 'Schedule', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': '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
# -*- 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 model 'Category'
db.create_table(u'website_category', (
(u'basemodel_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['website.BaseModel'], unique=True, primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
))
db.send_create_signal(u'website', ['Category'])
# Adding field 'Facility.category'
db.add_column(u'website_facility', 'category',
self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='facilities', null=True, to=orm['website.Category']),
keep_default=False)
def backwards(self, orm):
# Deleting model 'Category'
db.delete_table(u'website_category')
# Deleting field 'Facility.category'
db.delete_column(u'website_facility', 'category_id')
models = {
u'website.basemodel': {
'Meta': {'object_name': 'BaseModel'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
u'website.category': {
'Meta': {'object_name': 'Category', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'website.facility': {
'Meta': {'ordering': "['name']", 'object_name': 'Facility', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'category': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'facilities'", 'null': 'True', 'to': u"orm['website.Category']"}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'main_schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'facility_main'", 'to': u"orm['website.Schedule']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'special_schedules': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'facility_special'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['website.Schedule']"})
},
u'website.opentime': {
'Meta': {'object_name': 'OpenTime', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': 'True'}),
'end_day': ('django.db.models.fields.IntegerField', [], {}),
'end_time': ('django.db.models.fields.TimeField', [], {}),
'schedule': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'open_times'", 'to': u"orm['website.Schedule']"}),
'start_day': ('django.db.models.fields.IntegerField', [], {}),
'start_time': ('django.db.models.fields.TimeField', [], {})
},
u'website.schedule': {
'Meta': {'ordering': "['name']", 'object_name': 'Schedule', '_ormbases': [u'website.BaseModel']},
u'basemodel_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['website.BaseModel']", 'unique': 'True', 'primary_key': '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
......@@ -11,11 +11,16 @@ urlpatterns = patterns('whats_open_sites.views',
url(r'^(?:ajax|api)/schedule/', 'ajax_schedule_data', name='schedule_data'),
url(r'^$', 'facility_grid', name='facility_grid'),
#facilities open urls
url(r'^facilities/$', FacilitiesListView.as_view(), name='faciliites-list'),
url(r'^facilities/(?P<category>/$', ),
url(r'^facilities/(?P<category>/$', FacilitiesListView.as_view(), name='facilities-list-by-cat'),
url(r'^facilities/(?P<slug>/$', FacilitiesDetailView.as_view(), name='facilities-detail'),
url(r'^facilities/(?P<on_campus>/$', ),
url(r'^facilities/(?P<on_campus>/$', FaciltiesListView.as_view(), name-'facilities-list-by-status'),
#schedules urls
url(r'^schedule/(?P<id>/$', ScheduleDetailView.as_view(), name='schedule-detail'),
#opentime urls
url(r'^open-time/(?P<id>/$', OpenTimeDetailView.as_view(), name='open-time-detail'),
)
......@@ -2,6 +2,7 @@ from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.views.decorators.http import condition
from django.views.generic import ListView, DetailView
from .models import Facility, OpenTime, BaseModel
from .api import export_data
......@@ -15,10 +16,24 @@ import hashlib
import json
class ListFacilites(ListView):
class FacilitiesListView(ListView):
model = Facility
def get_queryset(self):
category = self.kwargs['category']
return Facility.objects.filter(category=self.kwargs['category'])
class FacilitiesDetailView(DetailView):
model = Facility
class ScheduleDetailView(DetailView):
model = Schedule
class OpenTimeDetailView(DetailView):
model = OpenTime
"""
class CategoryListView(ListView):
model = Categories
"""
def facility_grid(request):
"""Display the facilities in a grid. Main page."""
......
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