diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html
index 6e6165a57..752238544 100644
--- a/src/data/templates/view_person_detail.html
+++ b/src/data/templates/view_person_detail.html
@@ -74,7 +74,7 @@
{{personform.private.label}}: |
{% render personform.private user action %} |
{{personform.probably_alive.label}}: |
- {% render personform.probably_alive user action %} |
+ {% if person.probably_alive %}Yes{% else %}No{% endif %} |
diff --git a/src/data/templates/view_repository_detail.html b/src/data/templates/view_repository_detail.html
index cc65a0000..d3082249c 100644
--- a/src/data/templates/view_repository_detail.html
+++ b/src/data/templates/view_repository_detail.html
@@ -33,10 +33,10 @@
{% render repositoryform.name user action %} |
-{{repositoryform.repository_type.label}}: |
-{% render repositoryform.repository_type user action %} |
+{{repositoryform.repository_type.label}}: |
+{% render repositoryform.repository_type user action %} |
{{repositoryform.gramps_id.label}}: |
{% render repositoryform.gramps_id user action %} |
{{repositoryform.private.label}}: |
diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py
index 5159a5652..cb400b56c 100644
--- a/src/webapp/grampsdb/views.py
+++ b/src/webapp/grampsdb/views.py
@@ -550,7 +550,7 @@ def action(request, view, handle, act, add_to=None):
retval += "%s=%s\n" % (key, override[key])
del override[key]
else:
- retval += "%s=%s\n" % (key, repr(opt_default[key]))
+ retval += "%s=%s\n" % (key, opt_default[key])
# Any leftover overrides:
for key in sorted(override.keys()):
retval += "%s=%s\n" % (key, override[key])
@@ -1225,58 +1225,6 @@ def safe_int(num):
except:
return -1
-def process_child(request, handle, act, child):
- """
- handle - Family handle
- act - 'remove', 'up', or 'down'
- child - child number
- """
- from webapp.grampsdb.forms import FamilyForm
- context = RequestContext(request)
- context["view"] = "family"
- context["tview"] = _("Family")
- context["tviews"] = _("Familes")
- family = Family.objects.get(handle=handle)
- obj_type = ContentType.objects.get_for_model(family)
- childrefs = dji.ChildRef.filter(object_id=family.id,
- object_type=obj_type).order_by("order")
-
- if act == "remove":
- person = childrefs[int(child) - 1].ref_object
- [f.delete() for f in person.parent_families.filter(handle=handle)]
- childrefs[int(child) - 1].delete()
- dji.rebuild_cache(person)
- dji.rebuild_cache(family)
- elif act == "up":
- if int(child) >= 2:
- for ref in childrefs:
- if ref.order == int(child):
- ref.order = ref.order - 1
- elif ref.order == int(child) - 1:
- ref.order = ref.order + 1
- else:
- ref.order = ref.order
- for ref in childrefs:
- ref.save()
- dji.rebuild_cache(family)
- elif act == "down":
- if int(child) <= len(childrefs) - 1:
- childrefs[int(child) - 1].order = int(child) + 1
- childrefs[int(child)].order = int(child)
- childrefs[int(child) - 1].save()
- childrefs[int(child)].save()
- dji.rebuild_cache(family)
- else:
- raise Exception("invalid child action: %s" % act)
- familyform = FamilyForm(instance=family)
- familyform.model = family
- context["familyform"] = familyform
- context["object"] = family
- context["family"] = family
- context["action"] = "view"
- view_template = "view_family_detail.html"
- return render_to_response(view_template, context)
-
def process_reference(request, ref_by, handle, ref_to, order):
# FIXME: can I make this work for all?
context = RequestContext(request)
@@ -1309,3 +1257,104 @@ def process_reference(request, ref_by, handle, ref_to, order):
context["action"] = "view"
return render_to_response("reference.html", context)
+def process_child(request, handle, act, child):
+ """
+ handle - Family handle
+ act - 'remove', 'up', or 'down'
+ child - child number
+ """
+ family = Family.objects.get(handle=handle)
+ obj_type = ContentType.objects.get_for_model(family)
+ childrefs = dji.ChildRef.filter(object_id=family.id,
+ object_type=obj_type).order_by("order")
+
+ # FIXME: what about parent_families, families?
+ if act == "remove":
+ person = childrefs[int(child) - 1].ref_object
+ [f.delete() for f in person.parent_families.filter(handle=handle)]
+ childrefs[int(child) - 1].delete()
+ dji.rebuild_cache(person)
+ dji.rebuild_cache(family)
+ # FIXME: renumber order after delete
+ elif act == "up":
+ if int(child) >= 2:
+ for ref in childrefs:
+ if ref.order == int(child):
+ ref.order = ref.order - 1
+ elif ref.order == int(child) - 1:
+ ref.order = ref.order + 1
+ else:
+ ref.order = ref.order
+ for ref in childrefs:
+ ref.save()
+ dji.rebuild_cache(family)
+ elif act == "down":
+ if int(child) <= len(childrefs) - 1:
+ childrefs[int(child) - 1].order = int(child) + 1
+ childrefs[int(child)].order = int(child)
+ childrefs[int(child) - 1].save()
+ childrefs[int(child)].save()
+ dji.rebuild_cache(family)
+ else:
+ raise Exception("invalid child action: %s" % act)
+ return redirect("/family/%s/" % handle)
+
+def process_list_item(request, view, handle, act, item, index):
+ # /person/872323636232635/remove/event/1
+ # /family/872323636232635/up/citation/1
+ # /citation/872323636232635/down/attribute/2
+ index = int(index)
+ tab = {
+ "eventref": "#tab-events",
+ "citationref": "#tab-citations",
+ "attribute": "#tab-attributes",
+ "media": "#tab-media",
+ "lds": "#tab-lds",
+ }
+ if view == "person":
+ obj = dji.Person.get(handle=handle)
+ elif view == "event":
+ obj = dji.Event.get(handle=handle)
+ elif view == "family":
+ obj = dji.Family.get(handle=handle)
+ elif view == "citation":
+ obj = dji.Citation.get(handle=handle)
+ obj_type = ContentType.objects.get_for_model(obj)
+ # Next, get reference
+ if item == "eventref":
+ refs = dji.EventRef.filter(object_id=obj.id,
+ object_type=obj_type).order_by("order")
+ # Next, perform action:
+ if act == "remove":
+ count = 1
+ done = False
+ for ref in refs:
+ if count == index and not done:
+ ref.delete()
+ done = True
+ else:
+ ref.order = count
+ ref.save()
+ count += 1
+ elif act == "up" and index >= 2:
+ count = 1
+ for ref in refs:
+ if count == index - 1:
+ ref.order = index
+ ref.save()
+ elif count == index:
+ ref.order = index - 1
+ ref.save()
+ count += 1
+ elif act == "down" and index < len(refs):
+ count = 1
+ for ref in refs:
+ if count == index:
+ ref.order = index + 1
+ ref.save()
+ elif count == index + 1:
+ ref.order = index
+ ref.save()
+ count += 1
+ dji.rebuild_cache(obj)
+ return redirect("/%s/%s/%s" % (view, handle, tab[item]))
diff --git a/src/webapp/urls.py b/src/webapp/urls.py
index ab1d07fa5..b37feb5b0 100644
--- a/src/webapp/urls.py
+++ b/src/webapp/urls.py
@@ -92,6 +92,8 @@ urlpatterns += patterns('',
(r'^person/(?P(\w+))/name/(?P(\w+))/surname/(?P(\w+))/(?P(\w+))$',
process_surname),
(r'^family/(?P(\w+))/(?P(\w+))/child/(?P(\w+))$', process_child),
+ (r'^(?P(\w+))/(?P(\w+))/(?P(\w+))/(?P- (\w+))/(?P(\w+))$',
+ process_list_item),
)
# In urls:
diff --git a/src/webapp/utils.py b/src/webapp/utils.py
index 33eac4568..5f2553a0d 100644
--- a/src/webapp/utils.py
+++ b/src/webapp/utils.py
@@ -298,28 +298,39 @@ def event_table(obj, user, act, url, args):
retval = ""
table = Table("event_table")
table.columns(
+ "",
_("Description"),
_("Type"),
_("ID"),
_("Date"),
_("Place"),
_("Role"))
+ table.column_widths = [10, 20, 10, 7, 20, 23, 10]
if user.is_authenticated():
obj_type = ContentType.objects.get_for_model(obj)
event_ref_list = models.EventRef.objects.filter(
object_id=obj.id,
object_type=obj_type).order_by("order")
- event_list = [(obj.ref_object, obj) for obj in event_ref_list]
+ event_list = [(o.ref_object, o) for o in event_ref_list]
+ count = 1
for (djevent, event_ref) in event_list:
- table.row(
+ table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and act == "view" else "",
djevent.description,
table.db.get_event_from_handle(djevent.handle),
djevent.gramps_id,
display_date(djevent),
get_title(djevent.place),
str(event_ref.role_type))
+ count += 1
retval += table.get_html()
if user.is_superuser and act == "view":
+ count = 1
+ for (djevent, event_ref) in event_list:
+ item = obj.__class__.__name__.lower()
+ retval = retval.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/eventref/%d" % (item, obj.handle, count)))
+ retval = retval.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/eventref/%d" % (item, obj.handle, count)))
+ retval = retval.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/eventref/%d" % (item, obj.handle, count)))
+ count += 1
retval += make_button(_("Add New Event"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Event"), (url % args).replace("$act", "share"))
else:
@@ -415,23 +426,35 @@ def surname_table(obj, user, act, url=None, *args):
def citation_table(obj, user, act, url=None, *args):
retval = ""
table = Table("citation_table")
- table.columns(_("ID"),
+ table.columns("",
+ _("ID"),
_("Confidence"),
_("Page"))
+ table.column_widths = [10, 10, 50, 30]
if user.is_authenticated():
obj_type = ContentType.objects.get_for_model(obj)
citation_refs = dji.CitationRef.filter(object_type=obj_type,
- object_id=obj.id)
+ object_id=obj.id).order_by("order")
+ count = 1
for citation_ref in citation_refs:
if citation_ref.citation:
citation = table.db.get_citation_from_handle(
citation_ref.citation.handle)
- table.row(citation,
+ table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
+ citation,
str(citation.confidence),
str(citation.page),
)
+ count += 1
retval += table.get_html()
if user.is_superuser and url and act == "view":
+ count = 1
+ for citation_ref in citation_refs:
+ item = obj.__class__.__name__.lower()
+ retval = retval.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/citationref/%d" % (item, obj.handle, count)))
+ retval = retval.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/citationref/%d" % (item, obj.handle, count)))
+ retval = retval.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/citationref/%d" % (item, obj.handle, count)))
+ count += 1
retval += make_button(_("Add New Citation"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Citation"), (url % args).replace("$act", "share"))
else:
@@ -863,7 +886,7 @@ def children_table(obj, user, act, url=None, *args):
for childref in childrefs:
child = childref.ref_object
if user.is_authenticated():
- table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)),
+ table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
str(count),
"[%s]" % child.gramps_id,
render_name(child, user),
@@ -875,7 +898,8 @@ def children_table(obj, user, act, url=None, *args):
links.append(('URL', ("/person/%s" % child.handle)))
count += 1
else:
- table.row(str(count),
+ table.row("",
+ str(count),
"[%s]" % child.gramps_id,
render_name(child, user) if not child.private else "[Private]",
child.gender_type if not child.private else "[Private]",
@@ -890,13 +914,13 @@ def children_table(obj, user, act, url=None, *args):
count += 1
table.links(links)
retval += table.get_html()
- count = 1
- for childref in childrefs:
- retval = retval.replace("[[x%d]]" % count, make_button("x", "/family/%s/remove/child/%d" % (family.handle, count)))
- retval = retval.replace("[[^%d]]" % count, make_button("^", "/family/%s/up/child/%d" % (family.handle, count)))
- retval = retval.replace("[[v%d]]" % count, make_button("v", "/family/%s/down/child/%d" % (family.handle, count)))
- count += 1
if user.is_superuser and url and act == "view":
+ count = 1
+ for childref in childrefs:
+ retval = retval.replace("[[x%d]]" % count, make_button("x", "/family/%s/remove/child/%d" % (family.handle, count)))
+ retval = retval.replace("[[^%d]]" % count, make_button("^", "/family/%s/up/child/%d" % (family.handle, count)))
+ retval = retval.replace("[[v%d]]" % count, make_button("v", "/family/%s/down/child/%d" % (family.handle, count)))
+ count += 1
retval += make_button(_("Add New Person as Child"), (url.replace("$act", "add") % args))
retval += make_button(_("Add Existing Person as Child"), (url.replace("$act", "share") % args))
else: