Commit bba0b3da authored by Ben Waters's avatar Ben Waters
Browse files

cbv's are done need to finish api

parent 14656fc4
......@@ -140,7 +140,7 @@ INSTALLED_APPS = (
ANONYMOUS_USER_ID = -1
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # this is default
'guardian.backends.ObjectPermissionBackend',
#'guardian.backends.ObjectPermissionBackend',
)
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
......
from django.conf.urls import patterns, include, url
from django.contrib.sites.models import Site
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'whats_open.views.home', name='home'),
......@@ -15,6 +14,6 @@ urlpatterns = patterns('',
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'', include('website.urls')),
url(r'', include('whats_open_site.urls')),
)
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'),
)
from django.contrib import admin
from website.models import Facility, Schedule, OpenTime
class OpenTimeInline(admin.TabularInline):
model = OpenTime
fk_name = 'schedule'
class FacilityAdmin(GuardedModelAdmin):
from .models import Facility, Schedule, OpenTime
class OpenTimeAdmin(admin.ModelAdmin):
pass
class FacilityAdmin(admin.ModelAdmin):
pass
class ScheduleAdmin(admin.ModelAdmin):
inlines = [OpenTimeInline, ]
pass
admin.site.register(Facility, FacilityAdmin)
admin.site.register(Schedule, ScheduleAdmin)
admin.site.register(OpenTime, OpenTimeAdmin)
from website.models import Facility
from models import Facility
import re
def export_data():
......
......@@ -8,10 +8,11 @@ class Category(TimeStampedModel):
name = models.CharField(max_length=100)
class Facility(TimeStampedModel):
"""Represents a dining location on campus."""
"""Represents a facility location on campus."""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100)
owners = models.ManyToManyField(User)
category = models.ForeignKey('Category')
slug = AutoSlugField(populate_from='name',unique=True)
on_campus = models.BooleanField(default=True)
location = models.CharField(max_length=100, null=True, blank=True)
......@@ -85,10 +86,20 @@ class OpenTime(TimeStampedModel):
"""Represents a period time when a Facility is open"""
id = models.AutoField(primary_key=True)
schedule = models.ForeignKey('Schedule', related_name='open_times')
start_day = models.IntegerField() # 0-6, Monday == 0
start_time = models.TimeField()
end_day = models.IntegerField() # 0-6, Monday == 0
end_time = models.TimeField()
monday_start = models.TimeField()
monday_end = models.TimeField()
tuesday_start = models.TimeField()
tuesday_end = models.TimeField()
wednesday_start = models.TimeField()
wednesday_end = models.TimeField()
thursday_start = models.TimeField()
thursday_end = models.TimeField()
friday_start = models.TimeField()
friday_end = models.TimeField()
saturday_start = models.TimeField()
saturday_end = models.TimeField()
sunday_start = models.TimeField()
sunday_end = models.TimeField()
def isOpenNow(self):
"""Return true if the current time is this OpenTime's range"""
......
from django.conf.urls import patterns, url
from . import views
from .views import FacilityListView, FacilityCategoryListView, FacilityStatusListView, FacilityDetailView, ScheduleDetailView, OpenTimeDetailView
from rest_framework.routers import DefaultRouter
#router = DefaultRouter()
urlpatterns = patterns('whats_open_sites.views',
urlpatterns = patterns('whats_open_site.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>/$', 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>/$', FaciltiesListView.as_view(), name-'facilities-list-by-status'),
url(r'^facilities/$', FacilityListView.as_view(), name='faciliites-list'),
url(r'^facilities/(?P<category>)/$', FacilityCategoryListView.as_view(), name='facilities-list-by-cat'),
url(r'^facilities/(?P<slug>)/$', FacilityDetailView.as_view(), name='facilities-detail'),
url(r'^facilities/(?P<on_campus>)/$', FacilityStatusListView.as_view(), name='facilities-list-by-status'),
#schedules urls
url(r'^schedule/(?P<id>/$', ScheduleDetailView.as_view(), name='schedule-detail'),
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'),
url(r'^open-time/(?P<id>)/$', OpenTimeDetailView.as_view(), name='open-time-detail'),
)
......@@ -4,7 +4,7 @@ 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 .models import Facility, OpenTime, Category, Schedule
from .api import export_data
from .serializers import CategorySerializer, FacilitySerializer, ScheduleSerializer, OpenTimeSerializer
......@@ -16,12 +16,21 @@ import hashlib
import json
class FacilitiesListView(ListView):
class FacilityListView(ListView):
model = Facility
queryset = Facility.objects.all()
class FacilityCategoryListView(ListView):
model = Facility
def get_queryset(self):
return Facility.objects.filter(category=self.kwargs['category'])
class FacilitiesDetailView(DetailView):
class FacilityStatusListView(ListView):
model = Facility
def get_queryset(self):
return Facility.objects.filter(on_campus=self.kwargs['on_campus'])
class FacilityDetailView(DetailView):
model = Facility
class ScheduleDetailView(DetailView):
......
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