diff --git a/.travis.yml b/.travis.yml index 6549b875..89843308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ install: "pip install -r requirements.txt" before_script: - cd .. - - wget https://storage.googleapis.com/appengine-sdks/deprecated/195/google_appengine_1.9.5.zip -nv - - unzip -q google_appengine_1.9.5.zip + - wget https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.90.zip -nv + - unzip -q google_appengine_1.9.90.zip - export SDK_LOCATION="$(pwd)/google_appengine" - cd $TRAVIS_BUILD_DIR - git fetch --tags diff --git a/app.yaml.template b/app.yaml.template index 4dfff04b..35054755 100644 --- a/app.yaml.template +++ b/app.yaml.template @@ -26,6 +26,8 @@ handlers: libraries: - name: django - version: "1.3" + version: "1.11" - name: numpy version: "1.6.1" +- name: ssl + version: "latest" diff --git a/app/views.py b/app/views.py index 5a3bae60..9809784a 100644 --- a/app/views.py +++ b/app/views.py @@ -1,17 +1,12 @@ from django.http import HttpResponse, Http404 from django.shortcuts import render_to_response, redirect from django.template.loader import render_to_string -from django.utils import simplejson from django import forms -import django from google.appengine.api import users from google.appengine.runtime import DeadlineExceededError -import sympy -from logic.utils import Eval from logic.logic import SymPyGamma, mathjax_latex -from logic.resultsets import get_card, find_result_set import settings import models @@ -127,6 +122,7 @@ ]), ] + class MobileTextInput(forms.widgets.TextInput): def render(self, name, value, attrs=None): if attrs is None: @@ -135,9 +131,11 @@ def render(self, name, value, attrs=None): attrs['autocapitalize'] = 'off' return super(MobileTextInput, self).render(name, value, attrs) + class SearchForm(forms.Form): i = forms.CharField(required=False, widget=MobileTextInput()) + def authenticate(view): def _wrapper(request, **kwargs): user = users.get_current_user() @@ -157,6 +155,7 @@ def _wrapper(request, **kwargs): return template, params return _wrapper + def app_version(view): def _wrapper(request, **kwargs): result = view(request, **kwargs) @@ -173,6 +172,7 @@ def _wrapper(request, **kwargs): return result return _wrapper + @app_version @authenticate def index(request, user): @@ -279,19 +279,19 @@ def eval_card(request, card_name): except ValueError as e: return HttpResponse(json.dumps({ 'error': e.message - }), mimetype="application/json") + }), content_type="application/json") except DeadlineExceededError: return HttpResponse(json.dumps({ 'error': 'Computation timed out.' - }), mimetype="application/json") + }), content_type="application/json") except: trace = traceback.format_exc(5) return HttpResponse(json.dumps({ 'error': ('There was an error in Gamma. For reference' 'the last five traceback entries are: ' + trace) - }), mimetype="application/json") + }), content_type="application/json") - return HttpResponse(json.dumps(result), mimetype="application/json") + return HttpResponse(json.dumps(result), content_type="application/json") def get_card_info(request, card_name): g, variable, expression, _ = _process_card(request, card_name) @@ -301,19 +301,19 @@ def get_card_info(request, card_name): except ValueError as e: return HttpResponse(json.dumps({ 'error': e.message - }), mimetype="application/json") + }), content_type="application/json") except DeadlineExceededError: return HttpResponse(json.dumps({ 'error': 'Computation timed out.' - }), mimetype="application/json") + }), content_type="application/json") except: trace = traceback.format_exc(5) return HttpResponse(json.dumps({ 'error': ('There was an error in Gamma. For reference' 'the last five traceback entries are: ' + trace) - }), mimetype="application/json") + }), content_type="application/json") - return HttpResponse(json.dumps(result), mimetype="application/json") + return HttpResponse(json.dumps(result), content_type="application/json") def get_card_full(request, card_name): g, variable, expression, parameters = _process_card(request, card_name) @@ -339,10 +339,10 @@ def get_card_full(request, card_name): 'error': e.message }, 'input': expression - }), mimetype="text/html") + }), content_type="text/html") except DeadlineExceededError: return HttpResponse('Computation timed out.', - mimetype="text/html") + content_type="text/html") except: trace = traceback.format_exc(5) return HttpResponse(render_to_string('card.html', { @@ -352,14 +352,15 @@ def get_card_full(request, card_name): 'error': trace }, 'input': expression - }), mimetype="text/html") + }), content_type="text/html") - response = HttpResponse(html, mimetype="text/html") + response = HttpResponse(html, content_type="text/html") response['Access-Control-Allow-Origin'] = '*' response['Access-Control-Allow-Headers'] = 'Content-Type, X-Requested-With' return response + def remove_query(request, qid): user = users.get_current_user() @@ -381,12 +382,14 @@ def remove_query(request, qid): 'message': 'Not logged in or invalid user.' } - return HttpResponse(json.dumps(response), mimetype='application/json') + return HttpResponse(json.dumps(response), content_type='application/json') + @app_version def view_404(request): return ("404.html", {}) + @app_version def view_500(request): return ("500.html", {}) diff --git a/main.py b/main.py index 890b0d7b..5fd3bb28 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ # Must set this env var *before* importing any part of Django os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' -import django.core.handlers.wsgi +from django.core.wsgi import get_wsgi_application + +application = get_wsgi_application() -application = django.core.handlers.wsgi.WSGIHandler() diff --git a/requirements.txt b/requirements.txt index c434f65c..b7d6a044 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -django==1.3 +django==1.11 numpy==1.6.1 diff --git a/settings.py b/settings.py index 5d7fda3e..78c5a6ad 100644 --- a/settings.py +++ b/settings.py @@ -2,7 +2,7 @@ # root_dir points to this directory (that contains settings.py): import os -root_dir = os.path.dirname(os.path.abspath(__file__)) +ROOT_DIR = os.path.abspath(os.path.dirname(__file__)) DEBUG = False TEMPLATE_DEBUG = DEBUG @@ -54,13 +54,6 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '4v-c#usznhix_^np%w)4yr@dlit*4^47u@uph3xr2gh@7(&z$u' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', -) - MIDDLEWARE_CLASSES = ( 'google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware', 'django.middleware.common.CommonMiddleware', @@ -70,9 +63,27 @@ ROOT_URLCONF = 'urls' -TEMPLATE_DIRS = ( - root_dir + "/templates", -) +TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(ROOT_DIR, 'templates')], + 'OPTIONS': { + 'loaders': [ + ('django.template.loaders.cached.Loader', [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ]), + ], + }, +}] + + +ALLOWED_HOSTS = [ + '127.0.0.1', + 'localhost', + '.sympygamma.com', + '.sympy.org', + '.appspot.com' +] INSTALLED_APPS = ( #'django.contrib.auth', diff --git a/templates/base.html b/templates/base.html index c08cb729..8f6722c9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -64,7 +64,7 @@

- © 2013 SymPy Development Team. This project is + © 2013-2020 SymPy Development Team. This project is open-source: SymPy Gamma on Github.

diff --git a/urls.py b/urls.py index 97c79d3e..305fbaf6 100644 --- a/urls.py +++ b/urls.py @@ -1,4 +1,6 @@ -from django.conf.urls.defaults import * +from django.conf.urls import url + +from app import views # Uncomment the next two lines to enable the admin: # from django.contrib import admin @@ -7,23 +9,22 @@ import os.path p = os.path.join(os.path.dirname(__file__), 'media/') -urlpatterns = patterns( - '', +urlpatterns = [ # Example: # (r'^notebook/', include('notebook.foo.urls')), - (r'^$', 'app.views.index'), + url(r'^$', views.index), - (r'^input/', 'app.views.input'), - (r'^about/$', 'app.views.about'), - (r'^random', 'app.views.random_example'), + url(r'^input/', views.input), + url(r'^about/$', views.about), + url(r'^random', views.random_example), - (r'user/remove/(?P.*)$', 'app.views.remove_query'), + url(r'user/remove/(?P.*)$', views.remove_query), - (r'card/(?P\w*)$', 'app.views.eval_card'), + url(r'card/(?P\w*)$', views.eval_card), - (r'card_info/(?P\w*)$', 'app.views.get_card_info'), + url(r'card_info/(?P\w*)$', views.get_card_info), - (r'card_full/(?P\w*)$', 'app.views.get_card_full') + url(r'card_full/(?P\w*)$', views.get_card_full) # Uncomment the admin/doc line below and add 'django.contrib.admindocs' @@ -32,7 +33,7 @@ # Uncomment the next line to enable the admin: # (r'^admin/(.*)', admin.site.root), -) +] -handler404 = 'app.views.view_404' -handler500 = 'app.views.view_500' +handler404 = views.view_404 +handler500 = views.view_500