From 87983a0aa712ac4a93e558507dfcf3337faa65d0 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 17 Jun 2015 09:03:32 -0400 Subject: [PATCH] WIP webapp: two changes to make work with Django 1.6: 1. Forms no longer allow and pass keywords to models. So, we catch the keyword (save_cache) set it to the instance, and use that. 2. In templates, apparently not able to pass form.model.item. Will need to be able to get access to it in render(). --- data/templates/view_person_detail.html | 2 +- gramps/webapp/grampsdb/forms.py | 3 +++ gramps/webapp/grampsdb/models.py | 17 +++-------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/data/templates/view_person_detail.html b/data/templates/view_person_detail.html index 7ca6a692b..6c28f5227 100644 --- a/data/templates/view_person_detail.html +++ b/data/templates/view_person_detail.html @@ -63,7 +63,7 @@ {{personform.gender_type.label}}: - {% render personform.gender_type user action None "/person/?search=gender%%3D%s" personform.model.gender_type %} + {% render personform.gender_type user action None "/person/?search=gender%%3D%s" "personform.model.gender_type" %} {{personform.gramps_id.label}}: {% render personform.gramps_id user action %} {{personform.tags.label}}: diff --git a/gramps/webapp/grampsdb/forms.py b/gramps/webapp/grampsdb/forms.py index 93e007141..2f0798b05 100644 --- a/gramps/webapp/grampsdb/forms.py +++ b/gramps/webapp/grampsdb/forms.py @@ -41,6 +41,9 @@ class PersonForm(forms.ModelForm): exclude = ["death", "birth", "handle", "birth_ref_index", "death_ref_index", "families", "parent_families", "cache"] + def save(self, *args, **kwargs): + self.instance.save_cache_q = kwargs.pop("save_cache", True) + return super().save(*args, **kwargs) class NameForm(forms.ModelForm): class Meta: diff --git a/gramps/webapp/grampsdb/models.py b/gramps/webapp/grampsdb/models.py index d92cdd70f..d870ca5bd 100644 --- a/gramps/webapp/grampsdb/models.py +++ b/gramps/webapp/grampsdb/models.py @@ -451,11 +451,7 @@ class Tag(models.Model): models.Model.save(self) def save(self, *args, **kwargs): - save_cache = True - if "save_cache" in kwargs: - save_cache = kwargs["save_cache"] - del kwargs["save_cache"] - if save_cache: + if self.save_cache_q: self.cache = self.make_cache() models.Model.save(self, *args, **kwargs) # save to db @@ -539,11 +535,7 @@ class PrimaryObject(models.Model): models.Model.save(self) def save(self, *args, **kwargs): - save_cache = True - if "save_cache" in kwargs: - save_cache = kwargs["save_cache"] - del kwargs["save_cache"] - if save_cache: + if self.save_cache_q: self.cache = self.make_cache() models.Model.save(self, *args, **kwargs) # save to db @@ -601,10 +593,7 @@ class Person(PrimaryObject): def save(self, *args, **kwargs): from gramps.webapp.utils import probably_alive - if "save_cache" in kwargs: - compute_probably_alive = kwargs["save_cache"] - else: - compute_probably_alive = True + compute_probably_alive = self.save_cache_q PrimaryObject.save(self, *args, **kwargs) # expensive! only do this if also saving cache if compute_probably_alive: