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" %} {% include "detail_breadcrumb.html" %}
<h3>{{source.title|escape}}</h3> {% if citationform.errors or sourceform.errors %}
<div id="summaryarea"> <hr>
<table class="infolist" style="width:90%;"> {% comment %} 2 cols {% endcomment %} <p id="error">The following fields have errors. Please correct and try again.</p>
<tbody> <div id="error">{{citationform.errors}}</div>
<tr> <div id="error">{{sourceform.errors}}</div>
<td class="ColumnAttribute">Title:</td> <hr>
<td class="ColumnValue" id="data">{{source.title|escape}}</td> {% endif %}
</tr> <form method="post">{% csrf_token %}
<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>
<!-- Tabs --> <!-- Tabs -->
<h2>Citation information</h2>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs"> <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"> <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-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-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> <li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
</ul> </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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery"> <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
</div> </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-data"> <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-data">
</div> </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 class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
</div> </div>
</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 %} {% endblock %}

View File

@@ -93,26 +93,26 @@
</ul> </ul>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events"> <div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events">
<!-- 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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names"> <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 %} {% name_table person user action "/person/%s/name" person.handle %}
</div> </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-citations"> <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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes"> <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 %} {% attribute_table person user action "/person/%s/attribute" person.handle %}
</div> </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-addresses"> <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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom <div class="ui-tabs-panel ui-widget-content ui-corner-bottom
ui-tabs-hide" id="tab-notes"> 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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery"> <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>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-internet"> <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 %} {% internet_table person user action "/person/%s/internet" person.handle %}
@@ -124,7 +124,7 @@
{% lds_table person user action "/person/%s/lds" person.handle %} {% lds_table person user action "/person/%s/lds" person.handle %}
</div> </div>
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references"> <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>
</div> </div>

View File

@@ -17,21 +17,29 @@
<div id="summaryarea"> <div id="summaryarea">
<table class="infolist" style="width:90%;"> <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> <tr>
<td class="ColumnAttribute">Place Name:</td> <td class="ColumnAttribute">{{placeform.title.label}}:</td>
<td class="Columnvalue" id="data" colpan="3"> {{place.title|escape}}</td> <td class="Columnvalue" id="data" colpan="3"> {% render placeform.title user action %}</td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">Latitude:</td> <td class="ColumnAttribute">{{placeform.lat.label}}:</td>
<td class="ColumnValue" id="data">{{place.latitude|escape}}</td> <td class="ColumnValue" id="data">{% render placeform.lat user action %}</td>
<td class="ColumnAttribute">Longitude:</td> <td class="ColumnAttribute">{{placeform.long.label}}:</td>
<td class="ColumnValue" id="data">{{place.longitude|escape}}</td> <td class="ColumnValue" id="data">{% render placeform.long user action %}</td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">ID:</td> <td class="ColumnAttribute">{{placeform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{{place.gramps_id|escape}}</td> <td class="ColumnValue" id="data">{% render placeform.gramps_id user action %}</td>
<td class="ColumnAttribute">Private:</td> <td class="ColumnAttribute">{{placeform.private.label}}:</td>
<td class="ColumnValue" id="data">{{place.private}} <td class="ColumnValue" id="data">{% render placeform.private user action %}</td>
</tr> </tr>
</table> </table>
@@ -64,5 +72,26 @@
</div> </div>
</div> </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 %} {% endblock %}

View File

@@ -17,17 +17,27 @@
<div id="summaryarea"> <div id="summaryarea">
<table class="infolist" style="width:90%;"> <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> <tr>
<td class="ColumnAttribute">Name:</td> <td class="ColumnAttribute">{{repositoryform.name.label}}:</td>
<td class="ColumnValue" id="data" colspan="5">{{repository.name}} </td> <td class="ColumnValue" id="data" colspan="5">{% render repositoryform.name user action %} </td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">Type:</td> <td class="ColumnAttribute">{{repositoryform.repository_type.label}}:</td>
<td class="ColumnValue" id="data">{{repository.repository_type}}</td> <td class="ColumnValue" id="data" colspan="3">{% render repositoryform.repository_type user action %}</td>
<td class="ColumnAttribute">ID:</td> </tr>
<td class="ColumnValue" id="data">{{repository.gramps_id}}</td> <tr>
<td class="ColumnAttribute" >Private:</td> <td class="ColumnAttribute">{{repositoryform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{{repository.private}}</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> </tr>
</table> </table>
@@ -50,6 +60,25 @@
</div> </div>
</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 %} {% endblock %}

View File

@@ -19,25 +19,28 @@
<div id="summaryarea"> <div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 2 cols {% endcomment %} <table class="infolist" style="width:90%;"> {% comment %} 2 cols {% endcomment %}
<tbody> <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> <tr>
<td class="ColumnAttribute">Title:</td> <td class="ColumnAttribute">{{sourceform.title.label}}:</td>
<td class="ColumnValue" id="data">{{source.title|escape}}</td> <td class="ColumnValue" id="data">{% render sourceform.title user action %}</td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">Author:</td> <td class="ColumnAttribute">{{sourceform.gramps_id.label}}:</td>
<td class="ColumnValue" id="data">{{source.author|escape}}</td> <td class="ColumnValue" id="data">{% render sourceform.gramps_id user action %}</td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">ID:</td> <td class="ColumnAttribute">{{sourceform.abbrev.label}}:</td>
<td class="ColumnValue" id="data">{{source.gramps_id|escape}}</td> <td class="ColumnValue" id="data">{% render sourceform.abbrev user action %}</td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">Abbreviation:</td> <td class="ColumnAttribute">{{sourceform.pubinfo.label}}:</td>
<td class="ColumnValue" id="data">{{source.abbrev|escape}}</td> <td class="ColumnValue" id="data">{% render sourceform.pubinfo user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute">Public information:</td>
<td class="ColumnValue" id="data">{{source.pubinfo|escape}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -66,4 +69,24 @@
</div> </div>
</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 %} {% endblock %}

View File

@@ -17,19 +17,25 @@
<div id="summaryarea"> <div id="summaryarea">
<table class="infolist" style="width:90%;"> <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> <tr>
<td class="ColumnAttribute">Name:</td> <td class="ColumnAttribute">{{tagform.name.label}}:</td>
<td class="ColumnValue" id="data" colspan="5">{{tag.name}} </td> <td class="ColumnValue" id="data" colspan="5">{% render tagform.name user action %} </td>
</tr> </tr>
<tr> <tr>
<td class="ColumnAttribute">Type:</td> <td class="ColumnAttribute">{{tagform.color.label}}:</td>
<td class="ColumnValue" id="data">{{tag.repository_type}}</td> <td class="ColumnValue" id="data">{% render tagform.color user action %}</td>
<td class="ColumnAttribute">Color:</td> </tr>
<td class="ColumnValue" id="data">{{tag.color}}</td> <tr>
<td class="ColumnAttribute" >Private:</td> <td class="ColumnAttribute" >{{tagform.priority.label}}:</td>
<td class="ColumnValue" id="data">{{tag.private}}</td> <td class="ColumnValue" id="data">{% render tagform.priority user action %}</td>
<td class="ColumnAttribute" >Priority:</td>
<td class="ColumnValue" id="data">{{tag.priority}}</td>
</tr> </tr>
</table> </table>
@@ -52,6 +58,25 @@
</div> </div>
</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 %} {% endblock %}

View File

@@ -219,8 +219,7 @@ CREATE TABLE "auth_user" (
"last_login" datetime NOT NULL, "last_login" datetime NOT NULL,
"date_joined" 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(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');
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');
CREATE TABLE "auth_message" ( CREATE TABLE "auth_message" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL REFERENCES "auth_user" ("id"), "user_id" integer NOT NULL REFERENCES "auth_user" ("id"),
@@ -297,10 +296,6 @@ CREATE TABLE "django_session" (
"session_data" text NOT NULL, "session_data" text NOT NULL,
"expire_date" datetime 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" ( CREATE TABLE "django_site" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
"domain" varchar(100) NOT NULL, "domain" varchar(100) NOT NULL,
@@ -317,15 +312,12 @@ CREATE TABLE "django_admin_log" (
"action_flag" smallint unsigned NOT NULL, "action_flag" smallint unsigned NOT NULL,
"change_message" text 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" ( CREATE TABLE "grampsdb_profile" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"), "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"),
"css_theme" varchar(40) NOT NULL "css_theme" varchar(40) NOT NULL
); );
INSERT INTO "grampsdb_profile" VALUES(1,1,'Web_Mainz.css'); INSERT INTO "grampsdb_profile" VALUES(1,1,'Web_Mainz.css');
INSERT INTO "grampsdb_profile" VALUES(2,2,'Web_Mainz.css');
CREATE TABLE "grampsdb_nametype" ( CREATE TABLE "grampsdb_nametype" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
"name" varchar(40) NOT NULL, "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(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(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" ( CREATE TABLE "grampsdb_tag" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
"handle" varchar(19) NOT NULL UNIQUE, "handle" varchar(19) NOT NULL UNIQUE,
@@ -633,8 +625,8 @@ CREATE TABLE "grampsdb_tag" (
"last_changed" datetime, "last_changed" datetime,
"last_changed_by" text, "last_changed_by" text,
"name" text NOT NULL, "name" text NOT NULL,
"color" varchar(13) NOT NULL, "color" varchar(13),
"priority" integer NOT NULL "priority" integer
); );
CREATE TABLE "grampsdb_person_families" ( CREATE TABLE "grampsdb_person_families" (
"id" integer NOT NULL PRIMARY KEY, "id" integer NOT NULL PRIMARY KEY,
@@ -712,8 +704,8 @@ CREATE TABLE "grampsdb_citation" (
"last_changed_by" text, "last_changed_by" text,
"private" bool NOT NULL, "private" bool NOT NULL,
"cache" text, "cache" text,
"confidence" integer NOT NULL, "confidence" integer,
"page" varchar(50) NOT NULL, "page" varchar(50),
"source_id" integer "source_id" integer
); );
CREATE TABLE "grampsdb_source" ( CREATE TABLE "grampsdb_source" (
@@ -725,10 +717,10 @@ CREATE TABLE "grampsdb_source" (
"last_changed_by" text, "last_changed_by" text,
"private" bool NOT NULL, "private" bool NOT NULL,
"cache" text, "cache" text,
"title" varchar(50) NOT NULL, "title" varchar(50),
"author" varchar(50) NOT NULL, "author" varchar(50),
"pubinfo" varchar(50) NOT NULL, "pubinfo" varchar(50),
"abbrev" varchar(50) NOT NULL "abbrev" varchar(50)
); );
CREATE TABLE "grampsdb_event" ( CREATE TABLE "grampsdb_event" (
"calendar" integer NOT NULL, "calendar" integer NOT NULL,

View File

@@ -199,3 +199,73 @@ class MediaForm(forms.ModelForm):
path = forms.CharField(label="Path", path = forms.CharField(label="Path",
required=False, required=False,
widget=TextInput(attrs={'size':'70'})) 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) last_changed_by = models.TextField(blank=True, null=True)
name = models.TextField('name') name = models.TextField('name')
color = models.CharField(max_length=13) # "#000000000000" # Black color = models.CharField(max_length=13, blank=True, null=True) # "#000000000000" # Black
priority = models.IntegerField('priority', blank=False) priority = models.IntegerField('priority', blank=True, null=True)
def __unicode__(self): def __unicode__(self):
return str(self.name) return str(self.name)
@@ -492,8 +492,8 @@ class Family(PrimaryObject):
return str("%s and %s" % (father, mother)) return str("%s and %s" % (father, mother))
class Citation(DateObject, PrimaryObject): class Citation(DateObject, PrimaryObject):
confidence = models.IntegerField(blank=True) confidence = models.IntegerField(blank=True, null=True)
page = models.CharField(max_length=50, blank=True) page = models.CharField("Volume/Page", max_length=50, blank=True, null=True)
source = models.ForeignKey('Source', null=True, blank=True) source = models.ForeignKey('Source', null=True, blank=True)
references = generic.GenericRelation('CitationRef', related_name="refs", references = generic.GenericRelation('CitationRef', related_name="refs",
content_type_field="object_type", content_type_field="object_type",
@@ -506,10 +506,10 @@ class Citation(DateObject, PrimaryObject):
# .datamap_set # .datamap_set
class Source(PrimaryObject): class Source(PrimaryObject):
title = 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) author = models.CharField(max_length=50, blank=True, null=True)
pubinfo = models.CharField(max_length=50, blank=True) pubinfo = models.CharField("Pub. info.", max_length=50, blank=True, null=True)
abbrev = models.CharField(max_length=50, blank=True) abbrev = models.CharField("Abbreviation", max_length=50, blank=True, null=True)
# Other keys here: # Other keys here:
# .datamap_set # .datamap_set
@@ -523,7 +523,7 @@ class Event(DateObject, PrimaryObject):
object_id_field="object_id") object_id_field="object_id")
class Repository(PrimaryObject): class Repository(PrimaryObject):
repository_type = models.ForeignKey('RepositoryType') repository_type = models.ForeignKey('RepositoryType', verbose_name="Type")
name = models.TextField(blank=True) name = models.TextField(blank=True)
#addresses = models.ManyToManyField('Address', null=True, blank=True) #addresses = models.ManyToManyField('Address', null=True, blank=True)
references = generic.GenericRelation('RepositoryRef', related_name="refs", references = generic.GenericRelation('RepositoryRef', related_name="refs",

View File

@@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from webapp.utils import _, boolean from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Citation from webapp.grampsdb.models import Citation
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
@@ -34,95 +34,82 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. Process action on person. Can return a redirect.
""" """
context["tview"] = _("Citation") context["tview"] = _("Citation")
context["tviews"] = _("Citations") context["tviews"] = _("Citations")
context["action"] = "view" context["action"] = "view"
context["object"] = Citation()
view_template = "view_citation_detail.html" view_template = "view_citation_detail.html"
return render_to_response(view_template, context) if handle == "add":
if request.user.is_authenticated(): action = "add"
if action in ["edit", "view"]: if request.POST.has_key("action"):
pf, nf, sf, person = get_person_forms(handle, empty=False) action = request.POST.get("action")
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
# 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 dd = displayer.display
dp = parser.parse 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. 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) update_last_changed(event, request.user.username)
event = eventform.save() event = eventform.save()
dji.rebuild_cache(event) 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" action = "view"
else: else:
action = "add" action = "add"

View File

@@ -35,7 +35,7 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. 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) update_last_changed(family, request.user.username)
family = familyform.save() family = familyform.save()
dji.rebuild_cache(family) 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" action = "view"
else: else:
action = "add" action = "add"

View File

@@ -34,7 +34,7 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. 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) update_last_changed(media, request.user.username)
media = mediaform.save() media = mediaform.save()
dji.rebuild_cache(media) 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" action = "view"
else: else:
action = "add" action = "add"

View File

@@ -34,7 +34,7 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. 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) update_last_changed(note, request.user.username)
note = noteform.save() note = noteform.save()
dji.rebuild_cache(note) 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" action = "view"
else: else:
action = "add" 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])) name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
surname.prefix = make_empty(True, surname.prefix, " prefix ") surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif action == "create": elif action == "create":
import pdb; pdb.set_trace()
surnames = name.surname_set.all().order_by("order") surnames = name.surname_set.all().order_by("order")
sorder = 1 sorder = 1
for surname in surnames: for surname in surnames:
@@ -333,7 +331,7 @@ def process_name(request, handle, order, action="view"):
view_template = "view_name_detail.html" view_template = "view_name_detail.html"
return render_to_response(view_template, context) 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. 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 # FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person) dji.rebuild_cache(person)
# FIXME: update probably_alive # 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) return redirect("/person/%s" % person.handle)
else: else:
# need to edit again # need to edit again

View File

@@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from webapp.utils import _, boolean from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Place from webapp.grampsdb.models import Place
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
@@ -34,95 +34,67 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. Process action on person. Can return a redirect.
""" """
context["tview"] = _("Place") context["tview"] = _("Place")
context["tviews"] = _("Places") context["tviews"] = _("Places")
context["action"] = "view" context["action"] = "view"
context["object"] = Place()
view_template = "view_place_detail.html" 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) 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 """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from webapp.utils import _, boolean from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Repository from webapp.grampsdb.models import Repository
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
@@ -34,95 +34,68 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. Process action on person. Can return a redirect.
""" """
context["tview"] = _("Repository") context["tview"] = _("Repository")
context["tviews"] = _("Repositories") context["tviews"] = _("Repositories")
context["action"] = "view" context["action"] = "view"
context["object"] = Repository()
view_template = "view_repository_detail.html" view_template = "view_repository_detail.html"
return render_to_response(view_template, context) if handle == "add":
if request.user.is_authenticated(): action = "add"
if action in ["edit", "view"]: if request.POST.has_key("action"):
pf, nf, sf, person = get_person_forms(handle, empty=False) action = request.POST.get("action")
elif action == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True) # Handle: edit, view, add, create, save, delete
elif action == "delete": if action == "add":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True) repository = Repository()
person.delete() repositoryform = RepositoryForm(instance=repository)
return redirect("/person/") repositoryform.model = repository
elif action in ["save", "create"]: # could be create a new person elif action in ["view", "edit"]:
# look up old data, if any: repository = Repository.objects.get(handle=handle)
if handle: repositoryform = RepositoryForm(instance=repository)
person = Person.objects.get(handle=handle) repositoryform.model = repository
name = person.name_set.get(preferred=True) elif action == "save":
surname = name.surname_set.get(primary=True) repository = Repository.objects.get(handle=handle)
else: # create new item repositoryform = RepositoryForm(request.POST, instance=repository)
person = Person(handle=create_id()) repositoryform.model = repository
name = Name(person=person, preferred=True) if repositoryform.is_valid():
surname = Surname(name=name, primary=True, order=1) update_last_changed(repository, request.user.username)
surname = Surname(name=name, repository = repositoryform.save()
primary=True, dji.rebuild_cache(repository)
order=1, action = "view"
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0])) else:
# combine with user data: action = "edit"
pf = PersonForm(request.POST, instance=person) elif action == "create":
pf.model = person repository = Repository(handle=create_id())
nf = NameFormFromPerson(request.POST, instance=name) repositoryform = RepositoryForm(request.POST, instance=repository)
nf.model = name repositoryform.model = repository
sf = SurnameForm(request.POST, instance=surname) if repositoryform.is_valid():
# check if valid: update_last_changed(repository, request.user.username)
if nf.is_valid() and pf.is_valid() and sf.is_valid(): repository = repositoryform.save()
# name.preferred and surname.primary get set False in the above is_valid() dji.rebuild_cache(repository)
person = pf.save() if add_to:
# Process data: item, handle = add_to
name.person = person model = dji.get_model(item)
name = nf.save(commit=False) obj = model.objects.get(handle=handle)
# Manually set any data: dji.add_repository_ref(obj, repository)
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else "" return redirect("/%s/%s" % (item, handle))
name.preferred = True # FIXME: why is this False? action = "view"
check_preferred(name, person) else:
name.save() action = "add"
# Process data: elif action == "delete":
surname.name = name repository = Repository.objects.get(handle=handle)
surname = sf.save(commit=False) repository.delete()
# Manually set any data: return redirect("/repository/")
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else "" else:
surname.primary = True # FIXME: why is this False? raise Exception("Unhandled action: '%s'" % action)
surname.save()
# FIXME: last_saved, last_changed, last_changed_by context["repositoryform"] = repositoryform
dji.rebuild_cache(person) context["object"] = repository
# FIXME: update probably_alive context["repository"] = repository
return redirect("/person/%s" % person.handle) context["action"] = action
else:
# need to edit again return render_to_response(view_template, context)
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 """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from webapp.utils import _, boolean from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Source from webapp.grampsdb.models import Source
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
@@ -34,96 +34,66 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. Process action on person. Can return a redirect.
""" """
context["tview"] = _("Source") context["tview"] = _("Source")
context["tviews"] = _("Sources") context["tviews"] = _("Sources")
context["action"] = "view" context["action"] = "view"
context["object"] = Source()
view_template = "view_source_detail.html" 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) 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 """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from webapp.utils import _, boolean from webapp.utils import _, boolean, update_last_changed
from webapp.grampsdb.models import Tag from webapp.grampsdb.models import Tag
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
@@ -34,96 +34,65 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() 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. Process action on person. Can return a redirect.
""" """
context["tview"] = _("Tag") context["tview"] = _("Tag")
context["tviews"] = _("Tags") context["tviews"] = _("Tags")
context["action"] = "view" context["action"] = "view"
context["object"] = Tag()
view_template = "view_tag_detail.html" 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(): # Handle: edit, view, add, create, save, delete
if action in ["edit", "view"]: if action == "add":
pf, nf, sf, person = get_person_forms(handle, empty=False) tag = Tag()
elif action == "add": tagform = TagForm(instance=tag)
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True) tagform.model = tag
elif action == "delete": elif action in ["view", "edit"]:
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True) tag = Tag.objects.get(handle=handle)
person.delete() tagform = TagForm(instance=tag)
return redirect("/person/") tagform.model = tag
elif action in ["save", "create"]: # could be create a new person elif action == "save":
# look up old data, if any: tag = Tag.objects.get(handle=handle)
if handle: tagform = TagForm(request.POST, instance=tag)
person = Person.objects.get(handle=handle) tagform.model = tag
name = person.name_set.get(preferred=True) if tagform.is_valid():
surname = name.surname_set.get(primary=True) update_last_changed(tag, request.user.username)
else: # create new item tag = tagform.save()
person = Person(handle=create_id()) action = "view"
name = Name(person=person, preferred=True) else:
surname = Surname(name=name, primary=True, order=1) action = "edit"
surname = Surname(name=name, elif action == "create":
primary=True, tag = Tag(handle=create_id())
order=1, tagform = TagForm(request.POST, instance=tag)
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0])) tagform.model = tag
# combine with user data: if tagform.is_valid():
pf = PersonForm(request.POST, instance=person) update_last_changed(tag, request.user.username)
pf.model = person tag = tagform.save()
nf = NameFormFromPerson(request.POST, instance=name) if add_to:
nf.model = name item, handle = add_to
sf = SurnameForm(request.POST, instance=surname) model = dji.get_model(item)
# check if valid: obj = model.objects.get(handle=handle)
if nf.is_valid() and pf.is_valid() and sf.is_valid(): dji.add_tag_ref_default(obj, tag)
# name.preferred and surname.primary get set False in the above is_valid() return redirect("/%s/%s" % (item, handle))
person = pf.save() action = "view"
# Process data: else:
name.person = person action = "add"
name = nf.save(commit=False) elif action == "delete":
# Manually set any data: tag = Tag.objects.get(handle=handle)
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else "" tag.delete()
name.preferred = True # FIXME: why is this False? return redirect("/tag/")
check_preferred(name, person) else:
name.save() raise Exception("Unhandled action: '%s'" % action)
# Process data:
surname.name = name context["tagform"] = tagform
surname = sf.save(commit=False) context["object"] = tag
# Manually set any data: context["tag"] = tag
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["action"] = action
context["view"] = "person"
context["tview"] = _("Person") return render_to_response(view_template, context)
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

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

View File

@@ -146,10 +146,10 @@ class DjangoInterface(object):
raise AttributeError("no such model: '%s'" % name) raise AttributeError("no such model: '%s'" % name)
def get_model(self, name): def get_model(self, name):
if hasattr(models, name): if hasattr(models, name.title()):
return getattr(models, name) return getattr(models, name.title())
else: 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 # Get methods to retrieve list data from the tables
@@ -714,6 +714,15 @@ class DjangoInterface(object):
## Export reference objects: ## 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): def add_person_ref(self, obj, person_ref_data):
(private, (private,
citation_list, citation_list,
@@ -745,6 +754,20 @@ class DjangoInterface(object):
order=count + 1) order=count + 1)
note_ref.save() 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): def add_media_ref(self, obj, media_ref_data):
(private, citation_list, note_list, attribute_list, (private, citation_list, note_list, attribute_list,
ref, role) = media_ref_data ref, role) = media_ref_data
@@ -838,6 +861,15 @@ class DjangoInterface(object):
self.add_citation_list(child_ref, citation_list) self.add_citation_list(child_ref, citation_list)
self.add_note_list(child_ref, note_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): def add_event_ref(self, obj, event_data):
(private, note_list, attribute_list, ref, role) = event_data (private, note_list, attribute_list, ref, role) = event_data
try: try:

View File

@@ -68,13 +68,15 @@ urlpatterns += patterns('',
(r'^browse/$', browse_page), (r'^browse/$', browse_page),
(r'^login/$', 'django.contrib.auth.views.login'), (r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', logout_page), (r'^logout/$', logout_page),
(r'^(?P<view>(\w+))/$', view_list), # /object/ (r'^(?P<view>(\w+))/$', view_list), # /view/
(r'^(?P<view>(\w+))/add$', action, (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, (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+))$', (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+))$', 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+))/(?P<action>(\w+))$', process_name),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/surname/(?P<sorder>(\w+))$', process_surname), (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]) note_ref.ref_object.text[:50])
retval += table.get_html() retval += table.get_html()
if user.is_superuser and url and action == "view": 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: else:
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
return retval return retval