From 9496e097d80fc3ba88fb27e40b7ac13b8499a6ca Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 5 Jun 2012 01:48:39 +0000 Subject: [PATCH] Pass search and page throughout, for going back from what you were doing svn: r19758 --- src/data/templates/view_citation_detail.html | 14 +++++---- src/data/templates/view_citations.html | 10 +++---- src/data/templates/view_event_detail.html | 14 +++++---- src/data/templates/view_events.html | 12 ++++---- src/data/templates/view_families.html | 14 ++++----- src/data/templates/view_family_detail.html | 14 +++++---- src/data/templates/view_media.html | 10 +++---- src/data/templates/view_media_detail.html | 14 +++++---- src/data/templates/view_name_detail.html | 26 +++++++--------- src/data/templates/view_note_detail.html | 14 +++++---- src/data/templates/view_notes.html | 8 ++--- src/data/templates/view_person_detail.html | 2 +- src/data/templates/view_place_detail.html | 14 +++++---- src/data/templates/view_places.html | 6 ++-- src/data/templates/view_repositories.html | 8 ++--- .../templates/view_repository_detail.html | 14 +++++---- src/data/templates/view_source_detail.html | 14 +++++---- src/data/templates/view_sources.html | 10 +++---- src/data/templates/view_surname_detail.html | 30 ++++++++----------- src/data/templates/view_tag_detail.html | 14 +++++---- src/data/templates/view_tags.html | 8 ++--- src/webapp/utils.py | 11 +++++-- 22 files changed, 155 insertions(+), 126 deletions(-) diff --git a/src/data/templates/view_citation_detail.html b/src/data/templates/view_citation_detail.html index 73cdd9b3b..65440e25b 100644 --- a/src/data/templates/view_citation_detail.html +++ b/src/data/templates/view_citation_detail.html @@ -140,18 +140,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/citation/%s" citation.handle %} + {% make_button "Cancel" "/citation/%s" citation.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/citation/" %} + {% make_button "Cancel" "/citation/" args %} + + {% else %} - {% make_button "Add Citation" "/citation/add" %} - {% make_button "Edit Citation" "/citation/%s/edit" citation.handle %} - {% make_button "Delete Citation" "/citation/%s/delete" citation.handle %} + {% make_button "Add Citation" "/citation/add" args %} + {% make_button "Edit Citation" "/citation/%s/edit" citation.handle args %} + {% make_button "Delete Citation" "/citation/%s/delete" citation.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_citations.html b/src/data/templates/view_citations.html index 8285cb127..4ff2f2d73 100644 --- a/src/data/templates/view_citations.html +++ b/src/data/templates/view_citations.html @@ -17,12 +17,12 @@ {% for source in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{source.gramps_id}}] {% if user.is_authenticated %} - {{source.title|escape|nbsp}} - {{source.pubinfo|nbsp}} - {{source.author|nbsp}} + {{source.title|escape|nbsp}} + {{source.pubinfo|nbsp}} + {{source.author|nbsp}} {% else %} @@ -34,7 +34,7 @@ {% if user.is_superuser %} - {% make_button "Add Citation" "/citation/add" %} + {% make_button "Add Citation" "/citation/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_event_detail.html b/src/data/templates/view_event_detail.html index 7fda94bdc..7b83f1ff9 100644 --- a/src/data/templates/view_event_detail.html +++ b/src/data/templates/view_event_detail.html @@ -77,18 +77,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/event/%s" event.handle %} + {% make_button "Cancel" "/event/%s" event.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/event/" %} + {% make_button "Cancel" "/event/" args %} + + {% else %} - {% make_button "Add Event" "/event/add" %} - {% make_button "Edit Event" "/event/%s/edit" event.handle %} - {% make_button "Delete Event" "/event/%s/delete" event.handle %} + {% make_button "Add Event" "/event/add" args %} + {% make_button "Edit Event" "/event/%s/edit" event.handle args %} + {% make_button "Delete Event" "/event/%s/delete" event.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_events.html b/src/data/templates/view_events.html index 544296cc1..8e5adddd3 100644 --- a/src/data/templates/view_events.html +++ b/src/data/templates/view_events.html @@ -18,15 +18,15 @@ {% for event in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{event.gramps_id}}] {% if user.is_authenticated %} - {{event.event_type|nbsp}} - {{event.description|nbsp}} - {{event|date_as_text:user}} - {{event.place.title|nbsp}} + {{event.event_type|nbsp}} + {{event.description|nbsp}} + {{event|date_as_text:user}} + {{event.place.title|nbsp}} {% else %} [Private] @@ -41,7 +41,7 @@ {% if user.is_superuser %} - {% make_button "Add Event" "/event/add" %} + {% make_button "Add Event" "/event/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_families.html b/src/data/templates/view_families.html index 7d7888d34..0d818e0be 100644 --- a/src/data/templates/view_families.html +++ b/src/data/templates/view_families.html @@ -16,14 +16,14 @@ {% for family in page.object_list %} - {{ forloop.counter|row_count:page }} - [{{family.gramps_id}}] - {{family.father|make_name:user|nbsp}} - {{family.mother|make_name:user|nbsp}} + {{ forloop.counter|row_count:page }} + [{{family.gramps_id}}] + {{family.father|make_name:user|nbsp}} + {{family.mother|make_name:user|nbsp}} {% if user.is_authenticated %} - {{family.family_rel_type|escape|nbsp}} + {{family.family_rel_type|escape|nbsp}} {% else %} - [Private] + [Private] {% endif %} {% endfor %} @@ -31,7 +31,7 @@ {% if user.is_superuser %} - {% make_button "Add Family" "/family/add" %} + {% make_button "Add Family" "/family/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_family_detail.html b/src/data/templates/view_family_detail.html index d4bb8ebe3..e55ca6e26 100644 --- a/src/data/templates/view_family_detail.html +++ b/src/data/templates/view_family_detail.html @@ -122,18 +122,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/family/%s" family.handle %} + {% make_button "Cancel" "/family/%s" family.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/family/" %} + {% make_button "Cancel" "/family/" args %} + + {% else %} - {% make_button "Add Family" "/family/add" %} - {% make_button "Edit Family" "/family/%s/edit" family.handle %} - {% make_button "Delete Family" "/family/%s/delete" family.handle %} + {% make_button "Add Family" "/family/add" args %} + {% make_button "Edit Family" "/family/%s/edit" family.handle args %} + {% make_button "Delete Family" "/family/%s/delete" family.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_media.html b/src/data/templates/view_media.html index 7956d1f15..5b3176263 100644 --- a/src/data/templates/view_media.html +++ b/src/data/templates/view_media.html @@ -17,12 +17,12 @@ {% for media in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{media.gramps_id}}] {% if user.is_authenticated %} - {{media.mime|escape}} - {{media|display_date|nbsp}} - {{media.path|escape}} + {{media.mime|escape}} + {{media|display_date|nbsp}} + {{media.path|escape}} {% else %} @@ -34,7 +34,7 @@ {% if user.is_superuser %} - {% make_button "Add Media" "/media/add" %} + {% make_button "Add Media" "/media/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_media_detail.html b/src/data/templates/view_media_detail.html index a4dd7bc54..68c868933 100644 --- a/src/data/templates/view_media_detail.html +++ b/src/data/templates/view_media_detail.html @@ -77,18 +77,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/media/%s" media.handle %} + {% make_button "Cancel" "/media/%s" media.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/media/" %} + {% make_button "Cancel" "/media/" args %} + + {% else %} - {% make_button "Add Media" "/media/add" %} - {% make_button "Edit Media" "/media/%s/edit" media.handle %} - {% make_button "Delete Media" "/media/%s/delete" media.handle %} + {% make_button "Add Media" "/media/add" args %} + {% make_button "Edit Media" "/media/%s/edit" media.handle args %} + {% make_button "Delete Media" "/media/%s/delete" media.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_name_detail.html b/src/data/templates/view_name_detail.html index 590521a77..d0b85277b 100644 --- a/src/data/templates/view_name_detail.html +++ b/src/data/templates/view_name_detail.html @@ -116,30 +116,24 @@ {% if user.is_authenticated %} {% ifequal action "add" %} - + {% make_button "Cancel" "/person/%s" person.handle args "#tab-names" %} + + {% else %} {% ifequal action "edit" %} - + {% make_button "Cancel" "/person/" args "#tab-names" %} + + {% else %} - - - - {% endifequal %} + {% make_button "Add Name" "/person/%s/name/add" person.handle args %} + {% make_button "Edit Name" "/person/%s/name/%s/edit" person.handle order args %} + {% make_button "Delete Name" "/person/%s/name/%s/delete" person.handle order args %} {% endifequal %} + {% endifequal %} {% else %} {% endif %} diff --git a/src/data/templates/view_note_detail.html b/src/data/templates/view_note_detail.html index 727837c6c..254e4367a 100644 --- a/src/data/templates/view_note_detail.html +++ b/src/data/templates/view_note_detail.html @@ -85,18 +85,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/note/%s" note.handle %} + {% make_button "Cancel" "/note/%s" note.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/note/" %} + {% make_button "Cancel" "/note/" args %} + + {% else %} - {% make_button "Add Note" "/note/add" %} - {% make_button "Edit Note" "/note/%s/edit" note.handle %} - {% make_button "Delete Note" "/note/%s/delete" note.handle %} + {% make_button "Add Note" "/note/add" args %} + {% make_button "Edit Note" "/note/%s/edit" note.handle args %} + {% make_button "Delete Note" "/note/%s/delete" note.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_notes.html b/src/data/templates/view_notes.html index c8e116af1..83dfb3746 100644 --- a/src/data/templates/view_notes.html +++ b/src/data/templates/view_notes.html @@ -16,11 +16,11 @@ {% for note in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{note.gramps_id}}] {% if user.is_authenticated %} - {{note.note_type|escape|nbsp}} - {{note.text|preview:70|nbsp}} + {{note.note_type|escape|nbsp}} + {{note.text|preview:70|nbsp}} {% else %} @@ -31,7 +31,7 @@ {% if user.is_superuser %} - {% make_button "Add Note" "/note/add" %} + {% make_button "Add Note" "/note/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html index 5768fbfbd..8b00b95e3 100644 --- a/src/data/templates/view_person_detail.html +++ b/src/data/templates/view_person_detail.html @@ -140,7 +140,7 @@ {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/person/" %} + {% make_button "Cancel" "/person/" args %} diff --git a/src/data/templates/view_place_detail.html b/src/data/templates/view_place_detail.html index 7057fd8a4..00d0113ff 100644 --- a/src/data/templates/view_place_detail.html +++ b/src/data/templates/view_place_detail.html @@ -85,18 +85,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/place/%s" place.handle %} + {% make_button "Cancel" "/place/%s" place.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/place/" %} + {% make_button "Cancel" "/place/" args %} + + {% else %} - {% make_button "Add Place" "/place/add" %} - {% make_button "Edit Place" "/place/%s/edit" place.handle %} - {% make_button "Delete Place" "/place/%s/delete" place.handle %} + {% make_button "Add Place" "/place/add" args %} + {% make_button "Edit Place" "/place/%s/edit" place.handle args %} + {% make_button "Delete Place" "/place/%s/delete" place.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_places.html b/src/data/templates/view_places.html index d67e72e71..6504a80ac 100644 --- a/src/data/templates/view_places.html +++ b/src/data/templates/view_places.html @@ -15,10 +15,10 @@ {% for place in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{place.gramps_id}}] {% if user.is_authenticated %} - {{place.title|escape|nbsp}} + {{place.title|escape|nbsp}} {% else %} {% endif %} @@ -28,7 +28,7 @@ {% if user.is_superuser %} - {% make_button "Add Places" "/place/add" %} + {% make_button "Add Places" "/place/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_repositories.html b/src/data/templates/view_repositories.html index c660910cc..41ff6250e 100644 --- a/src/data/templates/view_repositories.html +++ b/src/data/templates/view_repositories.html @@ -17,11 +17,11 @@ {% for repository in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{repository.gramps_id}}] {% if user.is_authenticated %} - {{repository.repository_type|escape|nbsp}} - {{repository.name|escape|nbsp}} + {{repository.repository_type|escape|nbsp}} + {{repository.name|escape|nbsp}} {% else %} @@ -32,7 +32,7 @@ {% if user.is_superuser %} - {% make_button "Add Repository" "/repository/add" %} + {% make_button "Add Repository" "/repository/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_repository_detail.html b/src/data/templates/view_repository_detail.html index 6e7688a62..24801125c 100644 --- a/src/data/templates/view_repository_detail.html +++ b/src/data/templates/view_repository_detail.html @@ -69,18 +69,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/repository/%s" repository.handle %} + {% make_button "Cancel" "/repository/%s" repository.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/repository/" %} + {% make_button "Cancel" "/repository/" args %} + + {% else %} - {% make_button "Add Repository" "/repository/add" %} - {% make_button "Edit Repository" "/repository/%s/edit" repository.handle %} - {% make_button "Delete Repository" "/repository/%s/delete" repository.handle %} + {% make_button "Add Repository" "/repository/add" args %} + {% make_button "Edit Repository" "/repository/%s/edit" repository.handle args %} + {% make_button "Delete Repository" "/repository/%s/delete" repository.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_source_detail.html b/src/data/templates/view_source_detail.html index 4244056bc..e278de513 100644 --- a/src/data/templates/view_source_detail.html +++ b/src/data/templates/view_source_detail.html @@ -78,18 +78,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/source/%s" source.handle %} + {% make_button "Cancel" "/source/%s" source.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/source/" %} + {% make_button "Cancel" "/source/" args %} + + {% else %} - {% make_button "Add Source" "/source/add" %} - {% make_button "Edit Source" "/source/%s/edit" source.handle %} - {% make_button "Delete Source" "/source/%s/delete" source.handle %} + {% make_button "Add Source" "/source/add" args %} + {% make_button "Edit Source" "/source/%s/edit" source.handle args %} + {% make_button "Delete Source" "/source/%s/delete" source.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_sources.html b/src/data/templates/view_sources.html index 965cd39f2..f66bbb410 100644 --- a/src/data/templates/view_sources.html +++ b/src/data/templates/view_sources.html @@ -17,12 +17,12 @@ {% for source in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{source.gramps_id}}] {% if user.is_authenticated %} - {{source.title|escape|nbsp}} - {{source.pubinfo|nbsp}} - {{source.author|nbsp}} + {{source.title|escape|nbsp}} + {{source.pubinfo|nbsp}} + {{source.author|nbsp}} {% else %} @@ -34,7 +34,7 @@ {% if user.is_superuser %} - {% make_button "Add Source" "/source/add" %} + {% make_button "Add Source" "/source/add" args %} {% endif %} {% endblock %} diff --git a/src/data/templates/view_surname_detail.html b/src/data/templates/view_surname_detail.html index 42be1c7ed..f641bce3f 100644 --- a/src/data/templates/view_surname_detail.html +++ b/src/data/templates/view_surname_detail.html @@ -68,28 +68,22 @@ {% if user.is_authenticated %} {% if action == "edit" %} - + {% make_button "Cancel" "/person/%s/name/%s/surname/%s" person.handle order sorder args %} + + {% else %} - {% if action == "add" %} - - - + {% if action == "add" %} + {% make_button "Cancel" "/person/%s/name/%s" person.handle order args %} + + + + {% else %} - - - + {% make_button "Add Surname" "/person/%s/name/%s/surname/add" person.handle order args %} + {% make_button "Edit Surname" "/person/%s/name/%s/surname/%s/edit" person.handle order sorder args %} + {% make_button "Add Surname" "/person/%s/name/%s/surname/%s/delete" person.handle order sorder args %} {% endif %} {% endif %} {% endif %} diff --git a/src/data/templates/view_tag_detail.html b/src/data/templates/view_tag_detail.html index 8a1b4d207..57f4c2ff7 100644 --- a/src/data/templates/view_tag_detail.html +++ b/src/data/templates/view_tag_detail.html @@ -53,18 +53,22 @@ {% if user.is_superuser %} {% if action == "edit" %} - {% make_button "Cancel" "/tag/%s" tag.handle %} + {% make_button "Cancel" "/tag/%s" tag.handle args %} + + {% else %} {% ifequal action "add" %} - {% make_button "Cancel" "/tag/" %} + {% make_button "Cancel" "/tag/" args %} + + {% else %} - {% make_button "Add Tag" "/tag/add" %} - {% make_button "Edit Tag" "/tag/%s/edit" tag.handle %} - {% make_button "Delete Tag" "/tag/%s/delete" tag.handle %} + {% make_button "Add Tag" "/tag/add" args %} + {% make_button "Edit Tag" "/tag/%s/edit" tag.handle args %} + {% make_button "Delete Tag" "/tag/%s/delete" tag.handle args %} {% endifequal %} {% endif %} {% else %} diff --git a/src/data/templates/view_tags.html b/src/data/templates/view_tags.html index 2da8dddac..86835accc 100644 --- a/src/data/templates/view_tags.html +++ b/src/data/templates/view_tags.html @@ -17,11 +17,11 @@ {% for tag in page.object_list %} {{ forloop.counter|row_count:page }} - + [{{tag.name}}] {% if user.is_authenticated %} - {{tag.color|nbsp}} - {{tag.priority|nbsp}} + {{tag.color|nbsp}} + {{tag.priority|nbsp}} {% else %} @@ -32,7 +32,7 @@ {% if user.is_superuser %} - {% make_button "Add Tag" "/tag/add" %} + {% make_button "Add Tag" "/tag/add" args %} {% endif %} {% endblock %} diff --git a/src/webapp/utils.py b/src/webapp/utils.py index 85328b7c4..58ad5ef70 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -248,15 +248,20 @@ def build_search(request): def make_button(text, url, *args): newargs = [] kwargs = "" + last = "" for arg in args: - if arg.startswith("?"): + if isinstance(arg, (str, unicode)) and arg.startswith("?"): kwargs = arg + elif isinstance(arg, (str, unicode)) and arg.startswith("#"): + last = arg elif arg == "": pass else: newargs.append(arg) - url = url % tuple(newargs) - return mark_safe("""""" % (text, url, kwargs)) + if newargs: + url = url % tuple(newargs) + return mark_safe("""""" % + (text, url, kwargs, last)) def event_table(obj, user, action, url, args): retval = ""