From 7903b16c1cfa93e2683e140019afabdd86a6f34a Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 16 Sep 2007 22:48:06 -0400 Subject: BROKEN, started work on symbols + vars interface --- equations/models.py | 2 + equations/templates/equations/variable_detail.html | 2 +- equations/views.py | 16 +- templates/go.html | 171 +++++++++++++++++++-- urls.py | 5 +- 5 files changed, 174 insertions(+), 22 deletions(-) diff --git a/equations/models.py b/equations/models.py index 6791eb2..d011181 100644 --- a/equations/models.py +++ b/equations/models.py @@ -33,6 +33,8 @@ class Symbol(models.Model): self.render = self.renderdir + "%s.png" % self.id super(Symbol, self).save() +dispatcher.connect(update_render, signal=signals.pre_save, sender=Symbol) + def update_generic_variable(sender, instance, signal, *args, **kwargs): """Checks if there is a generic variable associated with this symbol; create one if there isn't""" diff --git a/equations/templates/equations/variable_detail.html b/equations/templates/equations/variable_detail.html index 6488de2..05c432f 100644 --- a/equations/templates/equations/variable_detail.html +++ b/equations/templates/equations/variable_detail.html @@ -14,7 +14,7 @@ Reference: {{ object.reference }} {% endif %} - Raw LaTeX:
{{ object.latex }}
+ Raw LaTeX:
{{ object.latex }}
{% if object.unicode %} Unicode:{{ object.unicode }} {% endif %} diff --git a/equations/views.py b/equations/views.py index 9ef1081..41309c1 100644 --- a/equations/views.py +++ b/equations/views.py @@ -2,11 +2,11 @@ from django.core import serializers from models import Equation, Variable, Symbol from django.http import HttpResponse -def all_vars(request): +def all_variables(request): data = serializers.serialize("json", Variable.objects.all()) return HttpResponse(data, mimetype="text/javascript") -def all_symbs(request): +def all_symbols(request): data = serializers.serialize("json", Symbol.objects.all()) return HttpResponse(data, mimetype="text/javascript") @@ -27,3 +27,15 @@ def equs_by_vars(request, whichvars): data = serializers.serialize("json", returnables) return HttpResponse(data, mimetype="text/javascript") + + +def vars_by_symbs(request, which_symbols): + vars = which_symbols.split(',') + if len(vars) < 1 or which_symbols == '': + return HttpResponse('[]', mimetype="text/javascript") + if vars[-1] == '/' or vars[-1] == '': + vars = vars[:-1] + returnables = Variable.objects.filter(symbol=vars[0]) + + data = serializers.serialize("json", returnables) + return HttpResponse(data, mimetype="text/javascript") diff --git a/templates/go.html b/templates/go.html index 98a2ddb..2617037 100644 --- a/templates/go.html +++ b/templates/go.html @@ -5,32 +5,157 @@ {% endblock %} diff --git a/urls.py b/urls.py index 1e2f0de..91b32dd 100644 --- a/urls.py +++ b/urls.py @@ -25,6 +25,7 @@ urlpatterns += patterns('django.views.generic.list_detail', ) urlpatterns += patterns('equator.equations.views', (r'^json/equs_by_vars/(?P[\d\,]*)/?$', 'equs_by_vars'), - (r'^json/all_vars/$', 'all_vars'), - (r'^json/all_symbs/$', 'all_symbs'), + (r'^json/vars_by_symbs/(?P[\d\,]*)/?$', 'vars_by_symbs'), + (r'^json/all_variables/$', 'all_variables'), + (r'^json/all_symbols/$', 'all_symbols'), ) -- cgit v1.2.3