#from django.db import models from django.utils.translation import gettext_lazy as _ import django.contrib.auth.models as auth from django.conf import settings from django.dispatch import dispatcher #from django.db.models import signals #from signals import update_render from appengine_django.models import BaseModel from google.appengine.ext import db class Symbol(BaseModel): name = db.StringProperty(_("Name")) latex = db.TextProperty(_("Raw LaTeX")) unicode = db.TextProperty(_("Unicode Representation")) #renderdir = "symbolrenders/" #render = models.ImageField(_("Rendered Image"), #upload_to=renderdir, editable=False) class Meta: get_latest_by = 'name' class Admin: ordering = ['name'] def _get_pk_val(self): return self.key().id() def __str__(self): return self.name def get_absolute_url(self): return "/symbol/%s/" % self.id def get_admin_url(self): return "/admin/symbols/%s/" % self.id class Variable(BaseModel): name = db.StringProperty(_("Name")) latex = db.TextProperty(_("Raw LaTeX")) unicode = db.TextProperty(_("Unicode Representation")) description = db.TextProperty(_("Description")) reference = db.TextProperty(_("Reference URL")) symbol = db.ReferenceProperty(Symbol) isgeneric = db.BooleanProperty(_("Is Generic?"), default=False) class Meta: get_latest_by = 'name' class Admin: ordering = ['name'] def _get_pk_val(self): return self.key().id() def __str__(self): return self.name def get_absolute_url(self): return "/variable/%s/" % self.id def get_admin_url(self): return "/admin/variables/%s/" % self.id class Equation(BaseModel): name = db.StringProperty(_("Name")) latex = db.TextProperty(_("Raw LaTeX")) unicode = db.TextProperty(_("Unicode Representation")) description = db.TextProperty(_("Description")) created = db.DateTimeProperty(_("Created"), auto_now_add=True) updated = db.DateTimeProperty(_("Last Updated"), auto_now_add=True) #owner = models.ForeignKey(auth.User, verbose_name=_("Owner")) variables = db.ListProperty(db.Key, verbose_name="Variables") reference = db.TextProperty(_("Reference URL")) class Meta: get_latest_by = 'created' class Admin: ordering = ['created'] def _get_pk_val(self): return self.key().id() def __str__(self): return self.name def get_absolute_url(self): return "/equation/%s/" % self.id def get_admin_url(self): return "/admin/equations/%s/" % self.id def update_variables(self): """Updates the variables field with all Variable objects found in the LaTeX representation.""" pass # TODO: write #signals.post_save.connect(update_render, sender=Equation) #dispatcher.connect(update_render, signal=signals.post_save, sender=Equation) #from django.contrib import admin #admin.site.register(Symbol) #admin.site.register(Variable) #admin.site.register(Equation)