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().
This commit is contained in:
parent
11f294160d
commit
87983a0aa7
@ -63,7 +63,7 @@
|
||||
<tr><td id="rowspace"></td></tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">{{personform.gender_type.label}}:</td>
|
||||
<td class="ColumnValue" id="data">{% render personform.gender_type user action None "/person/?search=gender%%3D%s" personform.model.gender_type %}</td>
|
||||
<td class="ColumnValue" id="data">{% render personform.gender_type user action None "/person/?search=gender%%3D%s" "personform.model.gender_type" %}</td>
|
||||
<td class="ColumnAttribute">{{personform.gramps_id.label}}:</td>
|
||||
<td class="ColumnValue" id="data">{% render personform.gramps_id user action %}</td>
|
||||
<td class="ColumnAttribute">{{personform.tags.label}}:</td>
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user