All primary objects can edit, view, create, add, save, add_to, and delete

svn: r19663
This commit is contained in:
Doug Blank 2012-05-26 18:48:20 +00:00
parent 7035384369
commit 0ba29c2d8b
23 changed files with 746 additions and 553 deletions

View File

@ -15,55 +15,140 @@
{% include "detail_breadcrumb.html" %}
<h3>{{source.title|escape}}</h3>
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 2 cols {% endcomment %}
<tbody>
<tr>
<td class="ColumnAttribute">Title:</td>
<td class="ColumnValue" id="data">{{source.title|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Author:</td>
<td class="ColumnValue" id="data">{{source.author|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{source.gramps_id|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Abbreviation:</td>
<td class="ColumnValue" id="data">{{source.abbrev|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Public information:</td>
<td class="ColumnValue" id="data">{{source.pubinfo|escape}}</td>
</tr>
</tbody>
</table>
</div>
</div>
{% if citationform.errors or sourceform.errors %}
<hr>
<p id="error">The following fields have errors. Please correct and try again.</p>
<div id="error">{{citationform.errors}}</div>
<div id="error">{{sourceform.errors}}</div>
<hr>
{% endif %}
<form method="post">{% csrf_token %}
<!-- Tabs -->
<h2>Citation information</h2>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-notes">Notes</a></li>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-general">General</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-gallery">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-data">Data</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-repositories">Repositories</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-notes">
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-general">
<table class="infolist" style="width:90%;">
<tr>
<td class="ColumnAttribute">{{citationform.text.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render citationform.text user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{citationform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data"> {% render citationform.gramps_id user action %}</td>
<td class="ColumnAttribute">{{citationform.private.label}}:</td>
<td class="ColumnValue" id="data"> {% render citationform.private user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{citationform.page.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render citationform.page user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{citationform.confidence.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render citationform.confidence user action %}</td>
</tr>
</table>
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
{% note_table citation user action "/note/add/citation/%s" citation.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-data">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-repositories">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
</div>
</div>
<p>Note: Any changes in the shared citation information will be reflected
in the citation itself, for all items that reference the citation.
</p>
<hr>
<h2>Shared source information</h2>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-shared-general">General</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-notes">Notes</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-gallery">Gallery</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-repositories">Repositories</a></li>
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-references">References</a></li>
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-shared-general">
<table class="infolist" style="width:90%;">
<tr>
<td class="ColumnAttribute">{{sourceform.title.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render sourceform.title user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{sourceform.author.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render sourceform.author user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{sourceform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data"> {% render sourceform.gramps_id user action %}</td>
<td class="ColumnAttribute">{{sourceform.private.label}}:</td>
<td class="ColumnValue" id="data"> {% render sourceform.private user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{sourceform.abbrev.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render sourceform.abbrev user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{sourceform.pubinfo.label}}:</td>
<td class="ColumnValue" id="data" colspan="3"> {% render sourceform.pubinfo user action %}</td>
</tr>
</table>
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-notes">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-gallery">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-data">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-repositories">
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-references">
</div>
</div>
<p>Note: Any changes in the shared source information will be reflected
in the source itself, for all items that reference the source.
</p>
<hr>
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Back to Citation" "/citation/%s" citation.handle %}
<input type="hidden" name="action" value="save"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/citation/" %}
<input type="hidden" name="action" value="create"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Back to Citations" "/citation" %}
{% make_button "Add Citation" "/citation/add" %}
{% make_button "Edit Citation" "/citation/%s/edit" citation.handle %}
{% make_button "Delete Citation" "/citation/%s/delete" citation.handle %}
{% endifequal %}
{% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

View File

@ -93,26 +93,26 @@
</ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events">
<!-- Events -->
{% event_table person user action "/person/%s/event" person.handle %}
{% event_table person user action "/event/add/person/%s" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names">
{% name_table person user action "/person/%s/name" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-citations">
{% citation_table person user action "/person/%s/citation" person.handle %}
{% citation_table person user action "/citation/add/person/%s" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
{% attribute_table person user action "/person/%s/attribute" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-addresses">
{% address_table person user action "/person/%s/address" person.handle %}
{% address_table person user action "/place/add/person/%s" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom
ui-tabs-hide" id="tab-notes">
{% note_table person user action "/person/%s/note" person.handle %}
{% note_table person user action "/note/add/person/%s" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
{% gallery_table person user action "/person/%s/gallery" person.handle %}
{% gallery_table person user action "/media/add/person/%s" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-internet">
{% internet_table person user action "/person/%s/internet" person.handle %}
@ -124,7 +124,7 @@
{% lds_table person user action "/person/%s/lds" person.handle %}
</div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
{% reference_table person user action "/person/%s/reference" person.handle %}
{% reference_table person user action "/reference/add/person/%s" person.handle %}
</div>
</div>

View File

@ -17,21 +17,29 @@
<div id="summaryarea">
<table class="infolist" style="width:90%;">
<trbody>
{% if placeform.errors %}
<hr>
<p id="error">The following fields have errors. Please correct and try again.</p>
<div id="error">{{placeform.errors}}</div>
<hr>
{% endif %}
<form method="post">{% csrf_token %}
<tr>
<td class="ColumnAttribute">Place Name:</td>
<td class="Columnvalue" id="data" colpan="3"> {{place.title|escape}}</td>
<td class="ColumnAttribute">{{placeform.title.label}}:</td>
<td class="Columnvalue" id="data" colpan="3"> {% render placeform.title user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">Latitude:</td>
<td class="ColumnValue" id="data">{{place.latitude|escape}}</td>
<td class="ColumnAttribute">Longitude:</td>
<td class="ColumnValue" id="data">{{place.longitude|escape}}</td>
<td class="ColumnAttribute">{{placeform.lat.label}}:</td>
<td class="ColumnValue" id="data">{% render placeform.lat user action %}</td>
<td class="ColumnAttribute">{{placeform.long.label}}:</td>
<td class="ColumnValue" id="data">{% render placeform.long user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{place.gramps_id|escape}}</td>
<td class="ColumnAttribute">Private:</td>
<td class="ColumnValue" id="data">{{place.private}}
<td class="ColumnAttribute">{{placeform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{% render placeform.gramps_id user action %}</td>
<td class="ColumnAttribute">{{placeform.private.label}}:</td>
<td class="ColumnValue" id="data">{% render placeform.private user action %}</td>
</tr>
</table>
@ -64,5 +72,26 @@
</div>
</div>
</div>
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Back to Place" "/place/%s" place.handle %}
<input type="hidden" name="action" value="save"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/place/" %}
<input type="hidden" name="action" value="create"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Back to Places" "/place" %}
{% make_button "Add Place" "/place/add" %}
{% make_button "Edit Place" "/place/%s/edit" place.handle %}
{% make_button "Delete Place" "/place/%s/delete" place.handle %}
{% endifequal %}
{% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

View File

@ -17,17 +17,27 @@
<div id="summaryarea">
<table class="infolist" style="width:90%;">
<trbody>
{% if repositoryform.errors %}
<hr>
<p id="error">The following fields have errors. Please correct and try again.</p>
<div id="error">{{repositoryform.errors}}</div>
<hr>
{% endif %}
<form method="post">{% csrf_token %}
<tr>
<td class="ColumnAttribute">Name:</td>
<td class="ColumnValue" id="data" colspan="5">{{repository.name}} </td>
<td class="ColumnAttribute">{{repositoryform.name.label}}:</td>
<td class="ColumnValue" id="data" colspan="5">{% render repositoryform.name user action %} </td>
</tr>
<tr>
<td class="ColumnAttribute">Type:</td>
<td class="ColumnValue" id="data">{{repository.repository_type}}</td>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{repository.gramps_id}}</td>
<td class="ColumnAttribute" >Private:</td>
<td class="ColumnValue" id="data">{{repository.private}}</td>
<td class="ColumnAttribute">{{repositoryform.repository_type.label}}:</td>
<td class="ColumnValue" id="data" colspan="3">{% render repositoryform.repository_type user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">{{repositoryform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{% render repositoryform.gramps_id user action %}</td>
<td class="ColumnAttribute" >{{repositoryform.private.label}}:</td>
<td class="ColumnValue" id="data">{% render repositoryform.private user action %}</td>
</tr>
</table>
@ -50,6 +60,25 @@
</div>
</div>
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Back to Repository" "/repository/%s" repository.handle %}
<input type="hidden" name="action" value="save"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/repository/" %}
<input type="hidden" name="action" value="create"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Back to Repositories" "/repository" %}
{% make_button "Add Repository" "/repository/add" %}
{% make_button "Edit Repository" "/repository/%s/edit" repository.handle %}
{% make_button "Delete Repository" "/repository/%s/delete" repository.handle %}
{% endifequal %}
{% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

View File

@ -19,25 +19,28 @@
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 2 cols {% endcomment %}
<tbody>
{% if sourceform.errors %}
<hr>
<p id="error">The following fields have errors. Please correct and try again.</p>
<div id="error">{{sourceform.errors}}</div>
<hr>
{% endif %}
<form method="post">{% csrf_token %}
<tr>
<td class="ColumnAttribute">Title:</td>
<td class="ColumnValue" id="data">{{source.title|escape}}</td>
<td class="ColumnAttribute">{{sourceform.title.label}}:</td>
<td class="ColumnValue" id="data">{% render sourceform.title user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">Author:</td>
<td class="ColumnValue" id="data">{{source.author|escape}}</td>
<td class="ColumnAttribute">{{sourceform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{% render sourceform.gramps_id user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{source.gramps_id|escape}}</td>
<td class="ColumnAttribute">{{sourceform.abbrev.label}}:</td>
<td class="ColumnValue" id="data">{% render sourceform.abbrev user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">Abbreviation:</td>
<td class="ColumnValue" id="data">{{source.abbrev|escape}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Public information:</td>
<td class="ColumnValue" id="data">{{source.pubinfo|escape}}</td>
<td class="ColumnAttribute">{{sourceform.pubinfo.label}}:</td>
<td class="ColumnValue" id="data">{% render sourceform.pubinfo user action %}</td>
</tr>
</tbody>
</table>
@ -66,4 +69,24 @@
</div>
</div>
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Back to Source" "/source/%s" source.handle %}
<input type="hidden" name="action" value="save"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/source/" %}
<input type="hidden" name="action" value="create"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Back to Sources" "/source" %}
{% make_button "Add Source" "/source/add" %}
{% make_button "Edit Source" "/source/%s/edit" source.handle %}
{% make_button "Delete Source" "/source/%s/delete" source.handle %}
{% endifequal %}
{% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

View File

@ -17,19 +17,25 @@
<div id="summaryarea">
<table class="infolist" style="width:90%;">
<trbody>
{% if tagform.errors %}
<hr>
<p id="error">The following fields have errors. Please correct and try again.</p>
<div id="error">{{tagform.errors}}</div>
<hr>
{% endif %}
<form method="post">{% csrf_token %}
<tr>
<td class="ColumnAttribute">Name:</td>
<td class="ColumnValue" id="data" colspan="5">{{tag.name}} </td>
<td class="ColumnAttribute">{{tagform.name.label}}:</td>
<td class="ColumnValue" id="data" colspan="5">{% render tagform.name user action %} </td>
</tr>
<tr>
<td class="ColumnAttribute">Type:</td>
<td class="ColumnValue" id="data">{{tag.repository_type}}</td>
<td class="ColumnAttribute">Color:</td>
<td class="ColumnValue" id="data">{{tag.color}}</td>
<td class="ColumnAttribute" >Private:</td>
<td class="ColumnValue" id="data">{{tag.private}}</td>
<td class="ColumnAttribute" >Priority:</td>
<td class="ColumnValue" id="data">{{tag.priority}}</td>
<td class="ColumnAttribute">{{tagform.color.label}}:</td>
<td class="ColumnValue" id="data">{% render tagform.color user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute" >{{tagform.priority.label}}:</td>
<td class="ColumnValue" id="data">{% render tagform.priority user action %}</td>
</tr>
</table>
@ -52,6 +58,25 @@
</div>
</div>
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Back to Tag" "/tag/%s" tag.handle %}
<input type="hidden" name="action" value="save"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/tag/" %}
<input type="hidden" name="action" value="create"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Back to Tags" "/tag" %}
{% make_button "Add Tag" "/tag/add" %}
{% make_button "Edit Tag" "/tag/%s/edit" tag.handle %}
{% make_button "Delete Tag" "/tag/%s/delete" tag.handle %}
{% endifequal %}
{% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

View File

@ -219,8 +219,7 @@ CREATE TABLE "auth_user" (
"last_login" datetime NOT NULL,
"date_joined" datetime NOT NULL
);
INSERT INTO "auth_user" VALUES(1,'admin','','','bugs@gramps-project.org','sha1$27271$3bf37b85204e28ce39a5ab19505306cf2925e997',1,1,1,'2012-05-24 18:13:26.243285','2012-05-24 18:11:18.576187');
INSERT INTO "auth_user" VALUES(2,'admin1','','','','sha1$a1880$d61d1cb0467158d6ee8c765af6c5d897b518aeca',0,1,0,'2012-05-24 18:13:52','2012-05-24 18:13:52');
INSERT INTO "auth_user" VALUES(1,'admin','','','bugs@gramps-project.org','sha1$61e84$9f92d64496a8785f9a398a1e1a2e9bc9bdc6f3b0',1,1,1,'2012-05-26 14:00:59.964988','2012-05-26 14:00:59.964988');
CREATE TABLE "auth_message" (
"id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL REFERENCES "auth_user" ("id"),
@ -297,10 +296,6 @@ CREATE TABLE "django_session" (
"session_data" text NOT NULL,
"expire_date" datetime NOT NULL
);
INSERT INTO "django_session" VALUES('8928553c90d43632f58fcff353176faa','MmU1MjliMDM2NzcyODdjNmJlOTgzMGFiYzc2MjFkMmViYWFiOTIzMjqAAn1xAShVEl9hdXRoX3Vz
ZXJfYmFja2VuZHECVSlkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZGVsQmFja2VuZHED
VQ1fYXV0aF91c2VyX2lkcQRLAXUu
','2012-06-07 18:13:26.602244');
CREATE TABLE "django_site" (
"id" integer NOT NULL PRIMARY KEY,
"domain" varchar(100) NOT NULL,
@ -317,15 +312,12 @@ CREATE TABLE "django_admin_log" (
"action_flag" smallint unsigned NOT NULL,
"change_message" text NOT NULL
);
INSERT INTO "django_admin_log" VALUES(1,'2012-05-24 18:13:52.236486',1,3,'2','admin1',1,'');
INSERT INTO "django_admin_log" VALUES(2,'2012-05-24 18:14:06.532544',1,3,'2','admin1',2,'No fields changed.');
CREATE TABLE "grampsdb_profile" (
"id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"),
"css_theme" varchar(40) NOT NULL
);
INSERT INTO "grampsdb_profile" VALUES(1,1,'Web_Mainz.css');
INSERT INTO "grampsdb_profile" VALUES(2,2,'Web_Mainz.css');
CREATE TABLE "grampsdb_nametype" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(40) NOT NULL,
@ -624,7 +616,7 @@ CREATE TABLE "grampsdb_config" (
);
INSERT INTO "grampsdb_config" VALUES(1,'sitename','site name of family tree','str','Gramps-Connect');
INSERT INTO "grampsdb_config" VALUES(2,'db_version','database scheme version','str','0.5.1');
INSERT INTO "grampsdb_config" VALUES(3,'db_created','database creation date/time','str','2012-05-24 18:10');
INSERT INTO "grampsdb_config" VALUES(3,'db_created','database creation date/time','str','2012-05-26 14:00');
CREATE TABLE "grampsdb_tag" (
"id" integer NOT NULL PRIMARY KEY,
"handle" varchar(19) NOT NULL UNIQUE,
@ -633,8 +625,8 @@ CREATE TABLE "grampsdb_tag" (
"last_changed" datetime,
"last_changed_by" text,
"name" text NOT NULL,
"color" varchar(13) NOT NULL,
"priority" integer NOT NULL
"color" varchar(13),
"priority" integer
);
CREATE TABLE "grampsdb_person_families" (
"id" integer NOT NULL PRIMARY KEY,
@ -712,8 +704,8 @@ CREATE TABLE "grampsdb_citation" (
"last_changed_by" text,
"private" bool NOT NULL,
"cache" text,
"confidence" integer NOT NULL,
"page" varchar(50) NOT NULL,
"confidence" integer,
"page" varchar(50),
"source_id" integer
);
CREATE TABLE "grampsdb_source" (
@ -725,10 +717,10 @@ CREATE TABLE "grampsdb_source" (
"last_changed_by" text,
"private" bool NOT NULL,
"cache" text,
"title" varchar(50) NOT NULL,
"author" varchar(50) NOT NULL,
"pubinfo" varchar(50) NOT NULL,
"abbrev" varchar(50) NOT NULL
"title" varchar(50),
"author" varchar(50),
"pubinfo" varchar(50),
"abbrev" varchar(50)
);
CREATE TABLE "grampsdb_event" (
"calendar" integer NOT NULL,

View File

@ -199,3 +199,73 @@ class MediaForm(forms.ModelForm):
path = forms.CharField(label="Path",
required=False,
widget=TextInput(attrs={'size':'70'}))
class CitationForm(forms.ModelForm):
class Meta:
model = Citation
exclude = ["handle", "sortval", "month1", "year1", "day1",
"newyear", "calendar", "modifier", "quality"]
def clean(self):
from webapp.utils import dp
data = super(CitationForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
msg = u"Invalid date format"
self._errors["date"] = self.error_class([msg])
del data["text"]
return data
def save(self, commit=True):
from webapp.utils import dp
from webapp.libdjango import DjangoInterface
dji = DjangoInterface()
model = super(CitationForm, self).save(commit=False)
dobj = dp(self.cleaned_data['text'])
dji.add_date(model, dobj.serialize())
if commit:
model.save()
return model
text = forms.CharField(label="Date",
required=False,
widget=TextInput(attrs={'size':'70'}))
class SourceForm(forms.ModelForm):
class Meta:
model = Source
exclude = ["handle"]
class PlaceForm(forms.ModelForm):
class Meta:
model = Place
exclude = ["handle"]
title = forms.CharField(label="Title",
required=False,
widget=TextInput(attrs={'size':'70'}))
long = forms.CharField(label="Longitude",
required=False,
widget=TextInput(attrs={'size':'70'}))
lat = forms.CharField(label="Latitude",
required=False,
widget=TextInput(attrs={'size':'70'}))
class RepositoryForm(forms.ModelForm):
class Meta:
model = Repository
exclude = ["handle"]
name = forms.CharField(label="Name",
required=False,
widget=TextInput(attrs={'size':'70'}))
class TagForm(forms.ModelForm):
class Meta:
model = Tag
exclude = ["handle"]
name = forms.CharField(label="Name",
required=False,
widget=TextInput(attrs={'size':'70'}))

View File

@ -391,8 +391,8 @@ class Tag(models.Model):
last_changed_by = models.TextField(blank=True, null=True)
name = models.TextField('name')
color = models.CharField(max_length=13) # "#000000000000" # Black
priority = models.IntegerField('priority', blank=False)
color = models.CharField(max_length=13, blank=True, null=True) # "#000000000000" # Black
priority = models.IntegerField('priority', blank=True, null=True)
def __unicode__(self):
return str(self.name)
@ -492,8 +492,8 @@ class Family(PrimaryObject):
return str("%s and %s" % (father, mother))
class Citation(DateObject, PrimaryObject):
confidence = models.IntegerField(blank=True)
page = models.CharField(max_length=50, blank=True)
confidence = models.IntegerField(blank=True, null=True)
page = models.CharField("Volume/Page", max_length=50, blank=True, null=True)
source = models.ForeignKey('Source', null=True, blank=True)
references = generic.GenericRelation('CitationRef', related_name="refs",
content_type_field="object_type",
@ -506,10 +506,10 @@ class Citation(DateObject, PrimaryObject):
# .datamap_set
class Source(PrimaryObject):
title = models.CharField(max_length=50, blank=True)
author = models.CharField(max_length=50, blank=True)
pubinfo = models.CharField(max_length=50, blank=True)
abbrev = models.CharField(max_length=50, blank=True)
title = models.CharField(max_length=50, blank=True, null=True)
author = models.CharField(max_length=50, blank=True, null=True)
pubinfo = models.CharField("Pub. info.", max_length=50, blank=True, null=True)
abbrev = models.CharField("Abbreviation", max_length=50, blank=True, null=True)
# Other keys here:
# .datamap_set
@ -523,7 +523,7 @@ class Event(DateObject, PrimaryObject):
object_id_field="object_id")
class Repository(PrimaryObject):
repository_type = models.ForeignKey('RepositoryType')
repository_type = models.ForeignKey('RepositoryType', verbose_name="Type")
name = models.TextField(blank=True)
#addresses = models.ManyToManyField('Address', null=True, blank=True)
references = generic.GenericRelation('RepositoryRef', related_name="refs",

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean
from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Citation
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -34,95 +34,82 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_citation(request, context, handle, action): # view, edit, save
def process_citation(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
context["tview"] = _("Citation")
context["tviews"] = _("Citations")
context["action"] = "view"
context["object"] = Citation()
view_template = "view_citation_detail.html"
return render_to_response(view_template, context)
if request.user.is_authenticated():
if action in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
person = pf.save()
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False?
check_preferred(name, person)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
return redirect("/person/%s" % person.handle)
else:
# need to edit again
if handle:
action = "edit"
else:
action = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
context["action"] = action
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle
if handle == "add":
action = "add"
if request.POST.has_key("action"):
action = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if action == "add":
source = Source()
sourceform = SourceForm(instance=source)
sourceform.model = source
citation = Citation(source=source)
citationform = CitationForm(instance=citation)
citationform.model = citation
elif action in ["view", "edit"]:
citation = Citation.objects.get(handle=handle)
citationform = CitationForm(instance=citation)
citationform.model = citation
source = citation.source
sourceform = SourceForm(instance=source)
sourceform.model = source
elif action == "save":
citation = Citation.objects.get(handle=handle)
citationform = CitationForm(request.POST, instance=citation)
citationform.model = citation
if citationform.is_valid():
update_last_changed(citation, request.user.username)
citation = citationform.save()
dji.rebuild_cache(citation)
action = "view"
else:
action = "edit"
elif action == "create":
source = Source(handle=create_id())
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
citation = Citation(handle=create_id(), source=source)
citationform = CitationForm(request.POST, instance=citation)
citationform.model = citation
if citationform.is_valid() and sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
citation.source = source
update_last_changed(citation, request.user.username)
citation = citationform.save()
dji.rebuild_cache(source)
dji.rebuild_cache(citation)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_citation_ref(obj, citation.handle)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"
elif action == "delete":
citation = Citation.objects.get(handle=handle)
citation.delete()
return redirect("/citation/")
else:
raise Exception("Unhandled action: '%s'" % action)
context["citationform"] = citationform
context["sourceform"] = sourceform
context["object"] = citation
context["citation"] = citation
context["source"] = source
context["action"] = action
return render_to_response(view_template, context)

View File

@ -37,7 +37,7 @@ dji = DjangoInterface()
dd = displayer.display
dp = parser.parse
def process_event(request, context, handle, action): # view, edit, save
def process_event(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
@ -79,6 +79,12 @@ def process_event(request, context, handle, action): # view, edit, save
update_last_changed(event, request.user.username)
event = eventform.save()
dji.rebuild_cache(event)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_event_ref_default(obj, event)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"

View File

@ -35,7 +35,7 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_family(request, context, handle, action): # view, edit, save
def process_family(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
@ -79,6 +79,12 @@ def process_family(request, context, handle, action): # view, edit, save
update_last_changed(family, request.user.username)
family = familyform.save()
dji.rebuild_cache(family)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_family_ref(obj, family.handle)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"

View File

@ -34,7 +34,7 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_media(request, context, handle, action): # view, edit, save
def process_media(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
@ -76,6 +76,12 @@ def process_media(request, context, handle, action): # view, edit, save
update_last_changed(media, request.user.username)
media = mediaform.save()
dji.rebuild_cache(media)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_media_ref_default(obj, media)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"

View File

@ -34,7 +34,7 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_note(request, context, handle, action): # view, edit, save
def process_note(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
@ -76,6 +76,12 @@ def process_note(request, context, handle, action): # view, edit, save
update_last_changed(note, request.user.username)
note = noteform.save()
dji.rebuild_cache(note)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_note_ref(obj, note)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"

View File

@ -151,8 +151,6 @@ def process_surname(request, handle, order, sorder, action="view"):
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif action == "create":
import pdb; pdb.set_trace()
surnames = name.surname_set.all().order_by("order")
sorder = 1
for surname in surnames:
@ -333,7 +331,7 @@ def process_name(request, handle, order, action="view"):
view_template = "view_name_detail.html"
return render_to_response(view_template, context)
def process_person(request, context, handle, action): # view, edit, save
def process_person(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
@ -392,6 +390,12 @@ def process_person(request, context, handle, action): # view, edit, save
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_person_ref_default(obj, person)
return redirect("/%s/%s" % (item, handle))
return redirect("/person/%s" % person.handle)
else:
# need to edit again

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean
from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Place
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -34,95 +34,67 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_place(request, context, handle, action): # view, edit, save
def process_place(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
context["tview"] = _("Place")
context["tviews"] = _("Places")
context["action"] = "view"
context["object"] = Place()
view_template = "view_place_detail.html"
if handle == "add":
action = "add"
if request.POST.has_key("action"):
action = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if action == "add":
place = Place()
placeform = PlaceForm(instance=place)
placeform.model = place
elif action in ["view", "edit"]:
place = Place.objects.get(handle=handle)
placeform = PlaceForm(instance=place)
placeform.model = place
elif action == "save":
place = Place.objects.get(handle=handle)
placeform = PlaceForm(request.POST, instance=place)
placeform.model = place
if placeform.is_valid():
update_last_changed(place, request.user.username)
place = placeform.save()
dji.rebuild_cache(place)
action = "view"
else:
action = "edit"
elif action == "create":
place = Place(handle=create_id())
placeform = PlaceForm(request.POST, instance=place)
placeform.model = place
if placeform.is_valid():
update_last_changed(place, request.user.username)
place = placeform.save()
dji.rebuild_cache(place)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_place_ref(obj, place.handle)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"
elif action == "delete":
place = Place.objects.get(handle=handle)
place.delete()
return redirect("/place/")
else:
raise Exception("Unhandled action: '%s'" % action)
context["placeform"] = placeform
context["object"] = place
context["place"] = place
context["action"] = action
return render_to_response(view_template, context)
if request.user.is_authenticated():
if action in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
person = pf.save()
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False?
check_preferred(name, person)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
return redirect("/person/%s" % person.handle)
else:
# need to edit again
if handle:
action = "edit"
else:
action = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
context["action"] = action
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean
from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Repository
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -34,95 +34,68 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_repository(request, context, handle, action): # view, edit, save
def process_repository(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
context["tview"] = _("Repository")
context["tviews"] = _("Repositories")
context["action"] = "view"
context["object"] = Repository()
view_template = "view_repository_detail.html"
return render_to_response(view_template, context)
if request.user.is_authenticated():
if action in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
person = pf.save()
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False?
check_preferred(name, person)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
return redirect("/person/%s" % person.handle)
else:
# need to edit again
if handle:
action = "edit"
else:
action = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
context["action"] = action
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle
if handle == "add":
action = "add"
if request.POST.has_key("action"):
action = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if action == "add":
repository = Repository()
repositoryform = RepositoryForm(instance=repository)
repositoryform.model = repository
elif action in ["view", "edit"]:
repository = Repository.objects.get(handle=handle)
repositoryform = RepositoryForm(instance=repository)
repositoryform.model = repository
elif action == "save":
repository = Repository.objects.get(handle=handle)
repositoryform = RepositoryForm(request.POST, instance=repository)
repositoryform.model = repository
if repositoryform.is_valid():
update_last_changed(repository, request.user.username)
repository = repositoryform.save()
dji.rebuild_cache(repository)
action = "view"
else:
action = "edit"
elif action == "create":
repository = Repository(handle=create_id())
repositoryform = RepositoryForm(request.POST, instance=repository)
repositoryform.model = repository
if repositoryform.is_valid():
update_last_changed(repository, request.user.username)
repository = repositoryform.save()
dji.rebuild_cache(repository)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_repository_ref(obj, repository)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"
elif action == "delete":
repository = Repository.objects.get(handle=handle)
repository.delete()
return redirect("/repository/")
else:
raise Exception("Unhandled action: '%s'" % action)
context["repositoryform"] = repositoryform
context["object"] = repository
context["repository"] = repository
context["action"] = action
return render_to_response(view_template, context)

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean
from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Source
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -34,96 +34,66 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_source(request, context, handle, action): # view, edit, save
def process_source(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
context["tview"] = _("Source")
context["tviews"] = _("Sources")
context["action"] = "view"
context["object"] = Source()
view_template = "view_source_detail.html"
if handle == "add":
action = "add"
if request.POST.has_key("action"):
action = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if action == "add":
source = Source()
sourceform = SourceForm(instance=source)
sourceform.model = source
elif action in ["view", "edit"]:
source = Source.objects.get(handle=handle)
sourceform = SourceForm(instance=source)
sourceform.model = source
elif action == "save":
source = Source.objects.get(handle=handle)
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
if sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
dji.rebuild_cache(source)
action = "view"
else:
action = "edit"
elif action == "create":
source = Source(handle=create_id())
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
if sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
dji.rebuild_cache(source)
if add_to:
raise Exception("Cannot add reference")
action = "view"
else:
action = "add"
elif action == "delete":
source = Source.objects.get(handle=handle)
source.delete()
return redirect("/source/")
else:
raise Exception("Unhandled action: '%s'" % action)
context["sourceform"] = sourceform
context["object"] = source
context["source"] = source
context["action"] = action
return render_to_response(view_template, context)
if request.user.is_authenticated():
if action in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
person = pf.save()
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False?
check_preferred(name, person)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
return redirect("/person/%s" % person.handle)
else:
# need to edit again
if handle:
action = "edit"
else:
action = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
context["action"] = action
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean
from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Tag
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -34,96 +34,65 @@ from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_tag(request, context, handle, action): # view, edit, save
def process_tag(request, context, handle, action, add_to=None): # view, edit, save
"""
Process action on person. Can return a redirect.
"""
context["tview"] = _("Tag")
context["tviews"] = _("Tags")
context["action"] = "view"
context["object"] = Tag()
view_template = "view_tag_detail.html"
return render_to_response(view_template, context)
if handle == "add":
action = "add"
if request.POST.has_key("action"):
action = request.POST.get("action")
if request.user.is_authenticated():
if action in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
person = pf.save()
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False?
check_preferred(name, person)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
# FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
return redirect("/person/%s" % person.handle)
else:
# need to edit again
if handle:
action = "edit"
else:
action = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
# Handle: edit, view, add, create, save, delete
if action == "add":
tag = Tag()
tagform = TagForm(instance=tag)
tagform.model = tag
elif action in ["view", "edit"]:
tag = Tag.objects.get(handle=handle)
tagform = TagForm(instance=tag)
tagform.model = tag
elif action == "save":
tag = Tag.objects.get(handle=handle)
tagform = TagForm(request.POST, instance=tag)
tagform.model = tag
if tagform.is_valid():
update_last_changed(tag, request.user.username)
tag = tagform.save()
action = "view"
else:
action = "edit"
elif action == "create":
tag = Tag(handle=create_id())
tagform = TagForm(request.POST, instance=tag)
tagform.model = tag
if tagform.is_valid():
update_last_changed(tag, request.user.username)
tag = tagform.save()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_tag_ref_default(obj, tag)
return redirect("/%s/%s" % (item, handle))
action = "view"
else:
action = "add"
elif action == "delete":
tag = Tag.objects.get(handle=handle)
tag.delete()
return redirect("/tag/")
else:
raise Exception("Unhandled action: '%s'" % action)
context["tagform"] = tagform
context["object"] = tag
context["tag"] = tag
context["action"] = action
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle
return render_to_response(view_template, context)

View File

@ -536,7 +536,14 @@ def check_access(request, context, obj, action):
else: # outside viewer
return not obj.private
def action(request, view, handle, action):
def add_to(request, view, item, handle):
"""
Add a new <view> referenced from <item>.
"""
# /view/add/person/handle
return action(request, view, handle, "add", (item, handle))
def action(request, view, handle, action, add_to=None):
"""
View a particular object given /object/handle (implied view),
/object/handle/action, or /object/add.
@ -559,7 +566,7 @@ def action(request, view, handle, action):
if not check_access(request, context, obj, action):
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_event_detail.html'
rd = process_event(request, context, handle, action)
rd = process_event(request, context, handle, action, add_to)
elif view == "family":
if action not in ["add", "create"]:
try:
@ -567,7 +574,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_family_detail.html'
rd = process_family(request, context, handle, action)
rd = process_family(request, context, handle, action, add_to)
elif view == "media":
if action not in ["add", "create"]:
try:
@ -575,7 +582,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_media_detail.html'
rd = process_media(request, context, handle, action)
rd = process_media(request, context, handle, action, add_to)
elif view == "note":
if action not in ["add", "create"]:
try:
@ -583,7 +590,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_note_detail.html'
rd = process_note(request, context, handle, action)
rd = process_note(request, context, handle, action, add_to)
elif view == "person":
if action not in ["add", "create"]:
try:
@ -591,7 +598,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_person_detail.html'
rd = process_person(request, context, handle, action)
rd = process_person(request, context, handle, action, add_to)
elif view == "place":
if action not in ["add", "create"]:
try:
@ -599,7 +606,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_place_detail.html'
rd = process_place(request, context, handle, action)
rd = process_place(request, context, handle, action, add_to)
elif view == "repository":
if action not in ["add", "create"]:
try:
@ -607,7 +614,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_repository_detail.html'
rd = process_repository(request, context, handle, action)
rd = process_repository(request, context, handle, action, add_to)
elif view == "citation":
if action not in ["add", "create"]:
try:
@ -615,7 +622,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_citation_detail.html'
rd = process_citation(request, context, handle, action)
rd = process_citation(request, context, handle, action, add_to)
elif view == "source":
if action not in ["add", "create"]:
try:
@ -623,7 +630,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_source_detail.html'
rd = process_source(request, context, handle, action)
rd = process_source(request, context, handle, action, add_to)
elif view == "tag":
if action not in ["add", "create"]:
try:
@ -631,7 +638,7 @@ def action(request, view, handle, action):
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_tag_detail.html'
rd = process_tag(request, context, handle, action)
rd = process_tag(request, context, handle, action, add_to)
elif view == "report":
if action not in ["add", "create"]:
try:

View File

@ -146,10 +146,10 @@ class DjangoInterface(object):
raise AttributeError("no such model: '%s'" % name)
def get_model(self, name):
if hasattr(models, name):
return getattr(models, name)
if hasattr(models, name.title()):
return getattr(models, name.title())
else:
raise AttributeError("no such model: '%s'" % name)
raise AttributeError("no such model: '%s'" % name.title())
# -----------------------------------------------
# Get methods to retrieve list data from the tables
@ -714,6 +714,15 @@ class DjangoInterface(object):
## Export reference objects:
def add_person_ref_default(self, obj, person, private=False, desc=None):
count = person.references.count()
person_ref = models.PersonRef(referenced_by=obj,
ref_object=person,
private=private,
order=count + 1,
description=desc)
person_ref.save()
def add_person_ref(self, obj, person_ref_data):
(private,
citation_list,
@ -745,6 +754,20 @@ class DjangoInterface(object):
order=count + 1)
note_ref.save()
def add_media_ref_default(self, obj, media, private=False, role=None):
count = media.references.count()
if not role:
role = (0,0,0,0)
media_ref = models.MediaRef(referenced_by=obj,
ref_object=media,
x1=role[0],
y1=role[1],
x2=role[2],
y2=role[3],
private=private,
order=count + 1)
media_ref.save()
def add_media_ref(self, obj, media_ref_data):
(private, citation_list, note_list, attribute_list,
ref, role) = media_ref_data
@ -838,6 +861,15 @@ class DjangoInterface(object):
self.add_citation_list(child_ref, citation_list)
self.add_note_list(child_ref, note_list)
def add_event_ref_default(self, obj, event, private=False, role=models.EventRoleType._DEFAULT):
count = models.EventRef.objects.filter(object_id=obj.id,object_type=obj).count()
event_ref = models.EventRef(private=private,
referenced_by=obj,
ref_object=event,
order=count + 1,
role_type = models.get_type(models.EventRoleType, role))
event_ref.save()
def add_event_ref(self, obj, event_data):
(private, note_list, attribute_list, ref, role) = event_data
try:

View File

@ -68,13 +68,15 @@ urlpatterns += patterns('',
(r'^browse/$', browse_page),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', logout_page),
(r'^(?P<view>(\w+))/$', view_list), # /object/
(r'^(?P<view>(\w+))/$', view_list), # /view/
(r'^(?P<view>(\w+))/add$', action,
{"handle": None, "action": "add"}), # /object/add
{"handle": None, "action": "add"}), # /view/add
(r'^(?P<view>(\w+))/add/(?P<item>(\w+))/(?P<handle>(\w+))$',
add_to), # /view/add/item/handle
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/$', action,
{"action": "view"}), # /object/handle/
{"action": "view"}), # /view/handle/
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/(?P<action>(\w+))$',
action), # /object/handle/action
action), # /view/handle/action
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))$', process_name),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/(?P<action>(\w+))$', process_name),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/surname/(?P<sorder>(\w+))$', process_surname),

View File

@ -385,7 +385,7 @@ def note_table(obj, user, action, url=None, *args):
note_ref.ref_object.text[:50])
retval += table.get_html()
if user.is_superuser and url and action == "view":
retval += make_button(_("Add note"), (url + "/add") % args)
retval += make_button(_("Add note"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval