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
# requirements.txt in the root directory of a project.
-r requirements/production.txt
Django==1.8.5
djangorestframework==3.3.0
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(){
// This function ensures that all text inside the grid-boxes display nicely on one line.
......@@ -138,26 +138,66 @@ function update_grid(facilities) {
});
}
$.ajax({
url: '/api/facilities/.json',
}).done(function (data) {
facilities = data;
update_grid(facilities);
construct_grid(facilities);
// Every second, check and see if it is necessary to update the grid.
var last_updated = new Date();
setInterval(function(){
now = new Date();
// If the hour has changed, it the half hour has changed
// or it has been over a half hour (180000 milliseconds) since the last update.
if (last_updated.getHours() != now.getHours() ||
(last_updated.getMinutes() < 30 && now.getMinutes() >= 30) || now - last_updated > 1800000){
update_grid(facilities);
construct_grid(facilities);
last_updated = new Date();
}
}, 1000);
$(window).on('resize', function(){
correct_grid_overflow();
$(function() {
update_grid(facilities);
construct_grid(facilities);
$.ajax({
url: '/api/facilities/?format=json',
}).done(function (data) {
facilities = data;
localStorage['facilities'] = JSON.stringify(facilities);
update_grid(facilities);
construct_grid(facilities);
// Every second, check and see if it is necessary to update the grid.
var last_updated = new Date();
setInterval(function(){
now = new Date();
// If the hour has changed, it the half hour has changed
// or it has been over a half hour (180000 milliseconds) since the last update.
if (last_updated.getHours() != now.getHours() ||
(last_updated.getMinutes() < 30 && now.getMinutes() >= 30) || now - last_updated > 1800000){
update_grid(facilities);
construct_grid(facilities);
last_updated = new Date();
}
}, 1000);
$(window).on('resize', function(){
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 %}
<div class="row about-content">
<div class="col-md-10 col-md-offset-1">
......@@ -12,10 +13,10 @@
<div class="col-md-10 col-md-offset-1" id="about-column">
<div class="row">
<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 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>
......
{% load staticfiles %}
<!DOCTYPE html>
{% load staticfiles %}<!DOCTYPE html>
<html>
{% block head %}
<head>
......
{% load staticfiles %}
{% block footer %}
<div id="footer">
<div class="footer-row">
......
{% load staticfiles %}
<meta charset="utf-8">
<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.">
......@@ -9,7 +10,6 @@
<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/grid.js" %}"></script>
<script src="{% static "js/typeAhead.js" %}"></script>
<script src="{% static "js/info.js" %}"></script>
<script src="{% static "js/about.js" %}"></script>
{% block title %}
......
{% load staticfiles %}
{% block nav %}
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
......
......@@ -4,22 +4,25 @@ from website.models import Category, Facility, Schedule, OpenTime
class CategorySerializer(serializers.ModelSerializer):
class Meta:
model = Category
fields = '__all__'
class OpenTimeSerializer(serializers.ModelSerializer):
schedule = serializers.RelatedField(many=False)
class Meta:
model = OpenTime
fields = '__all__'
class ScheduleSerializer(serializers.ModelSerializer):
open_times = OpenTimeSerializer(many=True)
open_times = OpenTimeSerializer(many=True, read_only=True)
class Meta:
model = Schedule
fields = ( 'id', 'open_times', 'last_modified', 'name', 'valid_start', 'valid_end' )
class FacilitySerializer(serializers.ModelSerializer):
category = serializers.RelatedField(many=False)
main_schedule = serializers.RelatedField(many=False)
special_schedules = serializers.RelatedField(many=True)
class FacilitySerializer(serializers.HyperlinkedModelSerializer):
category = CategorySerializer(many=False, read_only=True)
main_schedule = ScheduleSerializer(many=False, read_only=True)
special_schedules = ScheduleSerializer(many=True, read_only=True)
class Meta:
model = Facility
fields = ( 'id', 'category', 'main_schedule', 'special_schedules', 'location', 'last_modified', 'name' )
from django.conf.urls import patterns, include, url
from website.views import *
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.register(r'categories', CategoryViewSet)
......@@ -11,4 +13,4 @@ router.register(r'opentimes', OpenTimeViewSet)
urlpatterns = patterns('website.views',
url(r'^api/', include(router.urls)),
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):
def get_queryset(self):
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:
results = []
for fac in queryset:
......
......@@ -215,7 +215,6 @@ DJANGO_APPS = (
# Apps specific for this project go here.
LOCAL_APPS = (
'south',
'website',
'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