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 id="rowspace"></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="ColumnAttribute">{{personform.gender_type.label}}:</td>
|
<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="ColumnAttribute">{{personform.gramps_id.label}}:</td>
|
||||||
<td class="ColumnValue" id="data">{% render personform.gramps_id user action %}</td>
|
<td class="ColumnValue" id="data">{% render personform.gramps_id user action %}</td>
|
||||||
<td class="ColumnAttribute">{{personform.tags.label}}:</td>
|
<td class="ColumnAttribute">{{personform.tags.label}}:</td>
|
||||||
|
@ -41,6 +41,9 @@ class PersonForm(forms.ModelForm):
|
|||||||
exclude = ["death", "birth", "handle", "birth_ref_index",
|
exclude = ["death", "birth", "handle", "birth_ref_index",
|
||||||
"death_ref_index", "families", "parent_families",
|
"death_ref_index", "families", "parent_families",
|
||||||
"cache"]
|
"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 NameForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -451,11 +451,7 @@ class Tag(models.Model):
|
|||||||
models.Model.save(self)
|
models.Model.save(self)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
save_cache = True
|
if self.save_cache_q:
|
||||||
if "save_cache" in kwargs:
|
|
||||||
save_cache = kwargs["save_cache"]
|
|
||||||
del kwargs["save_cache"]
|
|
||||||
if save_cache:
|
|
||||||
self.cache = self.make_cache()
|
self.cache = self.make_cache()
|
||||||
models.Model.save(self, *args, **kwargs) # save to db
|
models.Model.save(self, *args, **kwargs) # save to db
|
||||||
|
|
||||||
@ -539,11 +535,7 @@ class PrimaryObject(models.Model):
|
|||||||
models.Model.save(self)
|
models.Model.save(self)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
save_cache = True
|
if self.save_cache_q:
|
||||||
if "save_cache" in kwargs:
|
|
||||||
save_cache = kwargs["save_cache"]
|
|
||||||
del kwargs["save_cache"]
|
|
||||||
if save_cache:
|
|
||||||
self.cache = self.make_cache()
|
self.cache = self.make_cache()
|
||||||
models.Model.save(self, *args, **kwargs) # save to db
|
models.Model.save(self, *args, **kwargs) # save to db
|
||||||
|
|
||||||
@ -601,10 +593,7 @@ class Person(PrimaryObject):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
from gramps.webapp.utils import probably_alive
|
from gramps.webapp.utils import probably_alive
|
||||||
if "save_cache" in kwargs:
|
compute_probably_alive = self.save_cache_q
|
||||||
compute_probably_alive = kwargs["save_cache"]
|
|
||||||
else:
|
|
||||||
compute_probably_alive = True
|
|
||||||
PrimaryObject.save(self, *args, **kwargs)
|
PrimaryObject.save(self, *args, **kwargs)
|
||||||
# expensive! only do this if also saving cache
|
# expensive! only do this if also saving cache
|
||||||
if compute_probably_alive:
|
if compute_probably_alive:
|
||||||
|
Loading…
Reference in New Issue
Block a user