Infrastructure to allow going back to browse page; deleted unneeded templates

svn: r19756
This commit is contained in:
Doug Blank 2012-06-04 20:58:05 +00:00
parent 186c686296
commit d62afc815f
19 changed files with 105 additions and 236 deletions

View File

@ -1,5 +1,6 @@
{% load my_tags %}
{% filter breadcrumb %}
{% format "/browse|Browse,/%s|%s,/%s/%s|%s [%s]" view tviews view object.handle tview object.gramps_id %}
{% endfilter %}
{% filter breadcrumb %}
{% format "/browse|Browse" %}||
{% format "/%s/%s|%s" view args tviews %}||
{% format "/%s/%s|%s [%s]" view object.handle tview object.gramps_id %}
{% endfilter %}

View File

@ -1,31 +0,0 @@
{% extends "base.html" %}
{% block windowtitle %}Person Details{% endblock %}
{% block pagetitle %}{{Pname}}{% endblock %}
{% block content %}
<form name="input" action={{URL}} method="post">{% csrf_token %}
<table cellspacing = "2">
<tr><td colspan = "2">Preferred Name</td></tr>
{% for field in NForm %}
<div class="fieldWrapper"><tr>
<td width="10"></td>
<td>{{ field.label_tag }}: </td>
<td width="300">{{ field }}<p>{{ field.help_text }}</p></td>
<td>{{ field.errors }}</td>
</tr></div>
{% endfor %}
</table>
<table cellspacing = "2">
{% for field in PForm %}
<div class="fieldWrapper"><tr>
<td>{{ field.label_tag }}: </td>
<td width="300">{{ field }}<p>{{ field.help_text }}</p></td>
<td>{{ field.errors }}</td>
</tr></div>
{% endfor %}
</table>
<input type="submit" value="Save & Exit" />
</form>
{% endblock %}

View File

@ -1,69 +0,0 @@
{% extends "base.html" %}
{% block windowtitle %}Person Details{% endblock %}
{% block pagetitle %}{{Pname}}{% endblock %}
{% block content %}
<form name="input" action={{URL}} method="post">{% csrf_token %}
{{ NForm.management_form }}
Names (<a id="displayText" href="javascript:toggle('nameset','show');">hide</a>)
<div id="nameset" style="display: block">
<table class="nicetable">
<tr>
<td>Preferred Name?</td>
<td>Prefix</td>
<td>First Name</td>
<td>Surname</td>
<td>Suffix</td>
<td>Type of Name</td>
<td>Delete</td>
</tr>
{% for form in NForm.forms %}
<tr>
{% for field in form %}
<td><p>{{ field }}</p>
<div id="errmsg"><p>{{ field.errors }}</p></div></td>
{% endfor %}
</tr>
{% endfor %}
<tr><td colspan="7"><div id="errmsg">{{ NamesetError }}</div></td></tr>
</table></div>
<table class="nicetable">
<tr>
<td>Reference ID: {{PForm.gramps_id}}</td>
<td>{{PForm.private}} Private </td>
<td>Last Changed: {{PLastChanged}}
<div id="errmsg"><p>{{PForm.last_changed.errors}}</p></div></td>
</tr><tr>
<td>Marker: {{PForm.marker_type}}
<div id="errmsg"><p>{{PForm.marker_type.errors}}</p></div></td>
<td>Gender: {{PForm.gender_type}}
<div id="errmsg"><p>{{PForm.gender_type.errors}}</p></div></td>
</tr><tr>
<td><p>Parent in these families:
(<a id="displayText" href="javascript:toggle('families','Edit');">
Edit</a>)</p><ul>{% for family in ParentF %}
<li>{{family}}</li>
{% endfor %}</ul></td>
<td><p>Child in these families:
(<a id="displayText" href="javascript:toggle('pfamilies','Edit');"> Edit</a>)</p><ul>{% for family in ChildF %}
<li>{{family}}</li>
{% endfor %}</ul></td>
</tr>
</table>
<table class="nicetable">
<tr><td width = "300"><div id="families" style="display: none">
<p>{{PForm.families}}</p>
<p>{{PForm.families.help_text}}</p>
<p>{{PForm.famlies.errors}}</p></div></td>
<td width = "300"><div id="pfamilies" style="display: none">
<p>{{PForm.parent_families}}</p>
<p>{{PForm.parent_families.help_text}}</p>
<p>{{PForm.parent_famlies.errors}}</p></div></td></tr>
</table>
<input type="submit" value="Save & Exit" />
</form>
{% endblock %}

View File

@ -1,9 +0,0 @@
{% extends "base.html" %}
{% block windowtitle %}Places{% endblock %}
{% block pagetitle %}Places{% endblock %}
{% block content %}
Congratulations, you found Places
{% endblock %}

View File

@ -1,49 +0,0 @@
{{ NForm.management_form }}
<table cellspacing = "2">
<tr><td colspan = "2">Names:</td></tr>
<tr><td width="10"></td>
<td><label>Preferred Name?</label></td>
<td width="50"><label>Prefix</label></td>
<td><label>First Name</label></td>
<td><label>Surname</label></td>
<td><label>Suffix</label></td>
<td><label>Type of Name</label></td>
<td><label>Delete</label></td>
</tr>
{% for form in NForm.forms %}
<div class="fieldWrapper"><tr>
<td width="10"></td>
{% for field in form %}
<td align="center">{{ field }}</td>
{% endfor %}
</tr></div>
<tr><td colspan="5>{{form.errors}}</td></tr>
{% endfor %}
</table>
{% for field in PForm %}
<div class="fieldWrapper"><tr>
<td>{{ field.label_tag }}: </td>
<td width="300">{{ field }}<p>{{ field.help_text }}</p></td>
<td>{{ field.errors }}</td>
</tr></div>
{% endfor %}
{{ NForm.management_form }}
<table>
<td>Preferred Name?</td>
<td>Prefix</td>
<td>First Name</td>
<td>Surname</td>
<td>Suffix</td>
<td>Type of Name</td>
<td>Delete</td>
</tr>
{% for form in NForm.forms %}
{% for field in form %}
<td align="left">{{ field }}<p>{{ field.errors }}</p></td>
{% endfor %}
</tr>
<tr><td colspan="7"></td></tr>
{% endfor %}
</table>

View File

@ -1,10 +0,0 @@
{% extends "view_page_detail.html" %}
{% load my_tags %}
{% block windowtitle %}Process Action{% endblock %}
{% block pagetitle %}Process Action{% endblock %}
{% block content %}
{{message}}
{% endblock %}

View File

@ -1,9 +0,0 @@
{% extends "base.html" %}
{% block windowtitle %}Data Changes Successfully Saved{% endblock %}
{% block pagetitle %}Data Changes Successfully Saved{% endblock %}
{% block content %}
Congratulations, your data changes were successful!
{% endblock %}

View File

@ -1,10 +0,0 @@
{% extends "gramps-base.html" %}
{% block title %}{{sitename}}: {{tview}} detail {% endblock %}
{% block heading %}{{sitename}}: {{tview}} detail {% endblock %}
{% block content %}
{{tview}} Detail page.
{% endblock %}

View File

@ -16,10 +16,12 @@
<div class="content" id="IndividualDetail">
{% filter breadcrumb %}
{% format "/browse|Browse,/person|People,/person/%s|Person [%s],/person/%s/name/%s|Name #%s" object.handle object.gramps_id object.handle order order %}
{% format "/browse|Browse" %} ||
{% format "/person|People" %} ||
{% format "/person/%s|Person [%s]" object.handle object.gramps_id %} ||
{% format "/person/%s/name/%s|Name #%s" object.handle order order %}
{% endfilter %}
<h3>{{nameform.model|make_name:user}} [{{person.gramps_id}}]</h3>
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 4 cols {% endcomment %}

View File

@ -10,7 +10,8 @@
<form name="SearchForm">
{% if tview != "Report" %}
{% filter breadcrumb %}
{% format "/browse|Browse,/%s|%s" view tviews %}
{% format "/browse|Browse" %} ||
{% format "/%s|%s" view tviews %}
{% endfilter %}
{% endif %}
<input type="submit" value="Search:"></input>

View File

@ -18,14 +18,14 @@
{% for name in page.object_list %}
<tr class="{% cycle odd,even %}">
{% if name.person %}
<td><a href="{{name.person.handle}}/" class="noThumb browsecell">{{ forloop.counter|row_count:page }}</a>
<td><a href="{{name.person.handle}}/{{args}}" class="noThumb browsecell">{{ forloop.counter|row_count:page }}</a>
</td>
<td><a href="{{name.person.handle}}/" class="noThumb browsecell">{{name|make_name:user}} &nbsp;</a>
<td><a href="{{name.person.handle}}/{{args}}" class="noThumb browsecell">{{name|make_name:user}} &nbsp;</a>
</td>
<td><a href="{{name.person.handle}}/" class="grampsid browsecell">[{{name.person.gramps_id}}]</a></td>
<td><a href="{{name.person.handle}}/" class="noThumb browsecell">{{name.person.gender_type}} &nbsp;</a></td>
<td><a href="{{name.person.handle}}/" class="noThumb browsecell">{{name.person.birth|date_as_text:user}} &nbsp;</a></td>
<td><a href="{{name.person.handle}}/" class="noThumb browsecell">{{name.person.death|date_as_text:user}} &nbsp;</a></td>
<td><a href="{{name.person.handle}}/{{args}}" class="grampsid browsecell">[{{name.person.gramps_id}}]</a></td>
<td><a href="{{name.person.handle}}/{{args}}" class="noThumb browsecell">{{name.person.gender_type}} &nbsp;</a></td>
<td><a href="{{name.person.handle}}/{{args}}" class="noThumb browsecell">{{name.person.birth|date_as_text:user}} &nbsp;</a></td>
<td><a href="{{name.person.handle}}/{{args}}" class="noThumb browsecell">{{name.person.death|date_as_text:user}} &nbsp;</a></td>
{% endif %}
</tr>
{% endfor %}
@ -33,7 +33,7 @@
</table>
{% if user.is_superuser %}
{% make_button "Add Person" "/person/add" %}
{% make_button "Add Person" "/person/add" args %}
{% endif %}
{% endblock %}

View File

@ -133,18 +133,22 @@
{% if user.is_superuser %}
{% if action == "edit" %}
{% make_button "Cancel" "/person/%s" person.handle %}
{% make_button "Cancel" "/person/%s" person.handle args %}
<input type="hidden" name="action" value="save"/>
<input type="hidden" name="search" value="{{search}}"/>
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Save"/>
{% else %}
{% ifequal action "add" %}
{% make_button "Cancel" "/person/" %}
<input type="hidden" name="action" value="create"/>
<input type="hidden" name="search" value="{{search}}"/>
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Person" "/person/add" %}
{% make_button "Edit Person" "/person/%s/edit" person.handle %}
{% make_button "Delete Person" "/person/%s/delete" person.handle %}
{% make_button "Add Person" "/person/add" args %}
{% make_button "Edit Person" "/person/%s/edit" person.handle args %}
{% make_button "Delete Person" "/person/%s/delete" person.handle args %}
{% endifequal %}
{% endif %}
{% else %}

View File

@ -16,10 +16,12 @@
<div class="content" id="IndividualDetail">
{% filter breadcrumb %}
{% format "/browse|Browse,/person|People,/person/%s|Person [%s],/person/%s/name/%s|Name #%s" object.handle object.gramps_id object.handle order order %}
{% format "/browse|Browse" %} ||
{% format "/person|People" %} ||
{% format "/person/%s|Person [%s]" object.handle object.gramps_id %} ||
{% format "/person/%s/name/%s|Name #%s" object.handle order order %}
{% endfilter %}
<h3>{{person|make_name:user}} [{{person.gramps_id}}]</h3>
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 4 cols {% endcomment %}

View File

@ -24,8 +24,6 @@
from webapp.grampsdb.models import *
from django.contrib import admin
print dir(admin.ModelAdmin)
class MyAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
print "object_id:", object_id

View File

@ -645,6 +645,12 @@ class Surname(models.Model):
def __unicode__(self):
return "%s" % self.surname
def get_url(self):
# /person/handle/name/1/surname/2
return "/person/%s/name/%s/surname/%s" % (self.name.person.handle,
self.name.order,
self.order)
class Name(DateObject, SecondaryObject):
name_type = models.ForeignKey('NameType', verbose_name="Type",
related_name="name_code",
@ -693,6 +699,10 @@ class Name(DateObject, SecondaryObject):
tuple(x.name_origin_type), x.connector) for x in
self.surname_set.all()]
def get_url(self):
# /person/handle/name/1
return "/person/%s/name/%s" % (self.person.handle, self.order)
class Lds(DateObject, SecondaryObject):
"""
BAPTISM = 0

View File

@ -149,11 +149,11 @@ def breadcrumb(path, arg=None):
if arg:
path = path.replace("{0}", arg)
retval = ""
for item in path.split(","):
p, name = item.split("|")
for item in path.split("||"):
p, name = item.split("|", 1)
if retval != "":
retval += " > "
retval += '<a href="%s"><b>%s</b></a>' % (p, name)
retval += '<a href="%s"><b>%s</b></a>' % (p.strip(), name.strip())
return "<p>%s</p>" % retval
breadcrumb.is_safe = True
register.filter('breadcrumb', breadcrumb)
@ -181,6 +181,11 @@ def format(string, arg0=None, arg1=None, arg2=None, arg3=None, arg4=None, arg5=N
format.is_safe = True
register.simple_tag(format)
def make_args(search, page):
return webapp.utils.build_args(search=search, page=page)
make_args.is_safe = True
register.simple_tag(make_args)
def currentSection(view1, view2): # tview, menu
if view1.strip().lower() in [view[1] for view in VIEWS] and view2 == "browse":
return "class=CurrentSection"

View File

@ -22,7 +22,7 @@
""" Views for Person, Name, and Surname """
## Gramps Modules
from webapp.utils import _, boolean, update_last_changed
from webapp.utils import _, boolean, update_last_changed, build_search
from webapp.grampsdb.models import Person, Name, Surname
from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
@ -146,7 +146,8 @@ def process_surname(request, handle, order, sorder, action="view"):
neworder += 1
else:
request.user.message_set.create(message="You can't delete the only surname")
return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
elif action in ["add"]:
surname = Surname(name=name, primary=False,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
@ -166,8 +167,9 @@ def process_surname(request, handle, order, sorder, action="view"):
surname = sf.save(commit=False)
check_primary(surname, surnames)
surname.save()
return redirect("/person/%s/name/%s/surname/%s#tab-surnames" %
(person.handle, name.order, sorder))
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
(person.handle, name.order, sorder,
build_search(request)))
action = "add"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif action == "save":
@ -179,13 +181,14 @@ def process_surname(request, handle, order, sorder, action="view"):
surname = sf.save(commit=False)
check_primary(surname, name.surname_set.all().exclude(order=surname.order))
surname.save()
return redirect("/person/%s/name/%s/surname/%s#tab-surnames" %
(person.handle, name.order, sorder))
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
(person.handle, name.order, sorder,
build_search(request)))
action = "edit"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
# else, edit again
else:
raise
raise Exception("unknown action: '%s'" % action)
sf = SurnameForm(instance=surname)
sf.model = surname
@ -209,7 +212,7 @@ def process_name(request, handle, order, action="view"):
if request.POST.has_key("action"):
action = request.POST.get("action")
### Process action:
if action == "view":
if action in "view":
pf, nf, sf, person = get_person_forms(handle, order=order)
name = nf.model
elif action == "edit":
@ -224,7 +227,8 @@ def process_name(request, handle, order, action="view"):
check_order(request, person)
else:
request.user.message_set.create(message = "Can't delete only name.")
return redirect("/person/%s#tab-names" % person.handle)
return redirect("/person/%s%s#tab-names" % (person.handle,
build_search(request)))
elif action == "add": # add name
person = Person.objects.get(handle=handle)
name = Name(person=person,
@ -275,7 +279,8 @@ def process_name(request, handle, order, action="view"):
surname.primary = True # FIXME: why is this False?
surname.save()
dji.rebuild_cache(person)
return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
else:
action = "add"
elif action == "save":
@ -309,7 +314,8 @@ def process_name(request, handle, order, action="view"):
surname.primary = True # FIXME: why is this False?
surname.save()
dji.rebuild_cache(person)
return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
else:
action = "edit"
context = RequestContext(request)
@ -342,7 +348,7 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
elif action == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/")
return redirect("/person/%s" % build_search(request))
elif action in ["save", "create"]: # could be create a new person
# look up old data, if any:
if handle:
@ -391,8 +397,8 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
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("/%s/%s%s" % (item, handle, build_search(request)))
return redirect("/person/%s%s" % (person.handle, build_search(request)))
else:
# need to edit again
if handle:

View File

@ -54,7 +54,7 @@ from django.forms.models import modelformset_factory
#
#------------------------------------------------------------------------
import webapp
from webapp.utils import _
from webapp.utils import _, build_args
from webapp.grampsdb.models import *
from webapp.grampsdb.view import *
from webapp.dbdjango import DbDjango
@ -102,6 +102,12 @@ def context_processor(request):
context["False"] = False
context["sitename"] = Config.objects.get(setting="sitename").value
context["default"] = ""
search = request.GET.get("search", None) or request.POST.get("search", None)
page = request.GET.get("page", None) or request.POST.get("page", None)
context["page"] = page
context["search"] = search
context["args"] = build_args(search=search, page=page)
return context
def main_page(request):

View File

@ -227,10 +227,36 @@ class Table(object):
# We have a couple of HTML bits that we want to unescape:
return str(self.doc.doc.htmllist[0]).replace("&amp;nbsp;", "&nbsp;")
def build_args(**kwargs):
retval = ""
first = True
for key in kwargs:
if kwargs[key] is not None:
if first:
retval+= "?"
first = False
else:
retval += "&"
retval += "%s=%s" % (key, kwargs[key])
return retval
def build_search(request):
search = request.GET.get("search", None) or request.POST.get("search", None)
page = request.GET.get("page", None) or request.POST.get("page", None)
return build_args(search=search, page=page)
def make_button(text, url, *args):
url = url % args
#return """[ <a href="%s">%s</a> ] """ % (url, text)
return """<input type="button" value="%s" onclick="document.location.href='%s'"/>""" % (text, url)
newargs = []
kwargs = ""
for arg in args:
if arg.startswith("?"):
kwargs = arg
elif arg == "":
pass
else:
newargs.append(arg)
url = url % tuple(newargs)
return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s'"/>""" % (text, url, kwargs))
def event_table(obj, user, action, url, args):
retval = ""
@ -314,13 +340,8 @@ def surname_table(obj, user, action, url=None, *args):
except:
name = None
if name:
links = []
for surname in name.surname_set.all().order_by("order"):
table.row(str(surname.order), surname.surname)
links.append(('URL',
# url is "/person/%s/name/%s/surname"
(url % args) + ("/%s" % surname.order)))
table.links(links)
table.row(str(surname.order), surname)
retval += table.get_html()
else:
retval += "<p id='error'>No such name order = %s</p>" % order