Commit 45239b98 authored by David Haynes's avatar David Haynes
Browse files

Merge branch 'upgrade-django' of git.gmu.edu:srct/whats-open into upgrade-django

parents a2911286 51cce9cb
# This file is here because many Platforms as a Service look for Django==1.8.5
# requirements.txt in the root directory of a project. djangorestframework==3.3.0
-r requirements/production.txt gunicorn==19.3.0
wheel==0.24.0
Django>=1.6,<1.7
South==1.0
argparse
distribute
wsgiref
djangorestframework>=2.3
# Local development dependencies go here
-r test.txt
django-debug-toolbar==1.2.1
Sphinx==1.2.2
# Pro-tip: Try not to put anything here. There should be no dependency in
# production that isn't in development.
-r base.txt
gunicorn>=19.0,<20.0
\ No newline at end of file
# Test dependencies go here.
-r base.txt
coverage
var facilities = []; var facilities = JSON.parse(localStorage['facilities'] || "[]" );
function correct_grid_overflow(){ function correct_grid_overflow(){
// This function ensures that all text inside the grid-boxes display nicely on one line. // This function ensures that all text inside the grid-boxes display nicely on one line.
...@@ -138,10 +138,16 @@ function update_grid(facilities) { ...@@ -138,10 +138,16 @@ function update_grid(facilities) {
}); });
} }
$.ajax({ $(function() {
url: '/api/facilities/.json',
}).done(function (data) { update_grid(facilities);
construct_grid(facilities);
$.ajax({
url: '/api/facilities/?format=json',
}).done(function (data) {
facilities = data; facilities = data;
localStorage['facilities'] = JSON.stringify(facilities);
update_grid(facilities); update_grid(facilities);
construct_grid(facilities); construct_grid(facilities);
// Every second, check and see if it is necessary to update the grid. // Every second, check and see if it is necessary to update the grid.
...@@ -160,4 +166,38 @@ $.ajax({ ...@@ -160,4 +166,38 @@ $.ajax({
$(window).on('resize', function(){ $(window).on('resize', function(){
correct_grid_overflow(); correct_grid_overflow();
}); });
//-------------------------------------------------------------------------
//-- FROM typeAhead.js
//-------------------------------------------------------------------------
//collecting list of facility names from server data
var rest_names = [];
for (var i = 0; i < data.length; i++) {
rest_names.push(data[i].name);
};
// For doumentation on jQuery's autocomplete: (api.jqueryui.com/autocomplete)
$("#searchBar").autocomplete({
source: rest_names,
//making it so the search result list doesn't physically appear
messages: {
noResults: '',
results: function(){}
},
minLength: 0,
response: function(event, ui) {
//ui.content array contains all names that are returned from the search
results = $.map(ui.content, function(r) { return r.value; });
filtered = $.grep(facilities, function (r, idx) {
return ($.inArray(r.name, results) != -1);
});
construct_grid(filtered);
// To prevent the page width from extending
$('.ui-autocomplete').remove();
}
});
});
}); });
$.ajax({
url: '/api/facilities/.json',
}).done(function (data) {
//collecting list of facility names from server data
var rest_names = [];
for (var i = 0; i < data.length; i++) {
rest_names.push(data[i].name);
};
// For doumentation on jQuery's autocomplete: (api.jqueryui.com/autocomplete)
$("#searchBar").autocomplete({
source: rest_names,
//making it so the search result list doesn't physically appear
messages: {
noResults: '',
results: function(){}
},
minLength: 0,
response: function(event, ui) {
//ui.content array contains all names that are returned from the search
results = $.map(ui.content, function(r) { return r.value; });
filtered = $.grep(facilities, function (r, idx) {
return ($.inArray(r.name, results) != -1);
});
construct_grid(filtered);
// To prevent the page width from extending
$('.ui-autocomplete').remove();
}
});
});
{% load staticfiles %}
{% block about %} {% block about %}
<div class="row about-content"> <div class="row about-content">
<div class="col-md-10 col-md-offset-1"> <div class="col-md-10 col-md-offset-1">
...@@ -12,10 +13,10 @@ ...@@ -12,10 +13,10 @@
<div class="col-md-10 col-md-offset-1" id="about-column"> <div class="col-md-10 col-md-offset-1" id="about-column">
<div class="row"> <div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-1 grid-box"> <div class="col-sm-6 col-md-4 col-md-offset-1 grid-box">
<div class="restaurant opened">Open</div> <div class="facility opened">Open</div>
</div> </div>
<div class="col-sm-6 col-md-4 col-md-offset-2 grid-box"> <div class="col-sm-6 col-md-4 col-md-offset-2 grid-box">
<div class="restaurant closed">Closed</div> <div class="facility closed">Closed</div>
</div> </div>
</div> </div>
</div> </div>
......
{% load staticfiles %} {% load staticfiles %}<!DOCTYPE html>
<!DOCTYPE html>
<html> <html>
{% block head %} {% block head %}
<head> <head>
......
{% load staticfiles %}
{% block footer %} {% block footer %}
<div id="footer"> <div id="footer">
<div class="footer-row"> <div class="footer-row">
......
{% load staticfiles %}
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description=" content="What's Open is a dynamic web application that lets you easily find out which on-campus locations are currently available. It's a simple alternative to searching for Mason's campus hours and filtering though them to figure out which ones are open."> <meta name="description=" content="What's Open is a dynamic web application that lets you easily find out which on-campus locations are currently available. It's a simple alternative to searching for Mason's campus hours and filtering though them to figure out which ones are open.">
...@@ -9,7 +10,6 @@ ...@@ -9,7 +10,6 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script> <script src="{% static "js/bootstrap.min.js" %}"></script>
<script src="{% static "js/grid.js" %}"></script> <script src="{% static "js/grid.js" %}"></script>
<script src="{% static "js/typeAhead.js" %}"></script>
<script src="{% static "js/info.js" %}"></script> <script src="{% static "js/info.js" %}"></script>
<script src="{% static "js/about.js" %}"></script> <script src="{% static "js/about.js" %}"></script>
{% block title %} {% block title %}
......
{% load staticfiles %}
{% block nav %} {% block nav %}
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header"> <div class="navbar-header">
......
...@@ -4,22 +4,25 @@ from website.models import Category, Facility, Schedule, OpenTime ...@@ -4,22 +4,25 @@ from website.models import Category, Facility, Schedule, OpenTime
class CategorySerializer(serializers.ModelSerializer): class CategorySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Category model = Category
fields = '__all__'
class OpenTimeSerializer(serializers.ModelSerializer): class OpenTimeSerializer(serializers.ModelSerializer):
schedule = serializers.RelatedField(many=False)
class Meta: class Meta:
model = OpenTime model = OpenTime
fields = '__all__'
class ScheduleSerializer(serializers.ModelSerializer): class ScheduleSerializer(serializers.ModelSerializer):
open_times = OpenTimeSerializer(many=True) open_times = OpenTimeSerializer(many=True, read_only=True)
class Meta: class Meta:
model = Schedule model = Schedule
fields = ( 'id', 'open_times', 'last_modified', 'name', 'valid_start', 'valid_end' )
class FacilitySerializer(serializers.ModelSerializer): class FacilitySerializer(serializers.HyperlinkedModelSerializer):
category = serializers.RelatedField(many=False) category = CategorySerializer(many=False, read_only=True)
main_schedule = serializers.RelatedField(many=False) main_schedule = ScheduleSerializer(many=False, read_only=True)
special_schedules = serializers.RelatedField(many=True) special_schedules = ScheduleSerializer(many=True, read_only=True)
class Meta: class Meta:
model = Facility model = Facility
fields = ( 'id', 'category', 'main_schedule', 'special_schedules', 'location', 'last_modified', 'name' )
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from website.views import * from website.views import *
from rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from django.conf.urls.static import static
from whats_open.settings import local as settings_local
router = DefaultRouter() router = DefaultRouter()
router.register(r'categories', CategoryViewSet) router.register(r'categories', CategoryViewSet)
...@@ -11,4 +13,4 @@ router.register(r'opentimes', OpenTimeViewSet) ...@@ -11,4 +13,4 @@ router.register(r'opentimes', OpenTimeViewSet)
urlpatterns = patterns('website.views', urlpatterns = patterns('website.views',
url(r'^api/', include(router.urls)), url(r'^api/', include(router.urls)),
url(r'^$', 'facility_grid', name='facility_grid'), url(r'^$', 'facility_grid', name='facility_grid'),
) ) + static(settings_local.STATIC_URL, document_root=settings_local.STATIC_ROOT)
...@@ -28,7 +28,7 @@ class FacilityViewSet(viewsets.ReadOnlyModelViewSet): ...@@ -28,7 +28,7 @@ class FacilityViewSet(viewsets.ReadOnlyModelViewSet):
def get_queryset(self): def get_queryset(self):
queryset = Facility.objects.all() queryset = Facility.objects.all()
open_now = self.request.QUERY_PARAMS.get('open', None) open_now = self.request.query_params.get('open', None)
if open_now is not None: if open_now is not None:
results = [] results = []
for fac in queryset: for fac in queryset:
......
...@@ -215,7 +215,6 @@ DJANGO_APPS = ( ...@@ -215,7 +215,6 @@ DJANGO_APPS = (
# Apps specific for this project go here. # Apps specific for this project go here.
LOCAL_APPS = ( LOCAL_APPS = (
'south',
'website', 'website',
'rest_framework', 'rest_framework',
) )
......
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