From 961a35b5291a011c047f90f4dc3d3746c8c744bc Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 25 May 2012 12:38:09 +0000 Subject: [PATCH] Family infrastructure in place svn: r19642 --- src/data/templates/view_family_detail.html | 30 +++++++++++----------- src/webapp/grampsdb/models.py | 4 +++ src/webapp/grampsdb/view/family.py | 13 +++++++--- src/webapp/grampsdb/views.py | 1 - src/webapp/utils.py | 13 ++++++---- 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/data/templates/view_family_detail.html b/src/data/templates/view_family_detail.html index 1de610de7..d62732aa0 100644 --- a/src/data/templates/view_family_detail.html +++ b/src/data/templates/view_family_detail.html @@ -14,7 +14,7 @@ {% include "detail_breadcrumb.html" %} -

{{familyform.father|render_name:user}} and {{familyform.mother|render_name:user}}

+

{{family.father|render_name:user}} and {{family.mother|render_name:user}}

{% comment %} 4 cols {% endcomment %} @@ -35,9 +35,9 @@ - + - + {% if user.is_authenticated or not familyform.father.probably_alive %} @@ -48,10 +48,10 @@ {% else %} - - - - + + + + {% endif %} @@ -68,16 +68,16 @@ - - - - + + + + - - - - + + + +
Name:{% render familyform.father user action %}{% render familyform.father user action %} Name:{% render familyform.mother user action %}{% render familyform.mother user action %}
{{familyform.father.death.label}}:{% render familyform.father user action %}Birth:[Private]Death:{{familyform.father.death|render_date:user}}Death:{{familyform.mother.death|render_date:user}}
Relationship information
ID:{{familyform.gramps_id}}Type:RELTYPE{{familyform.gramps_id.label}}:{% render familyform.gramps_id user action %}{{familyform.family_rel_type.label}}:{% render familyform.family_rel_type user action %}
Marker:{{familyform.marker_type}}Private:{{familyform.private}}{{familyform.tags.label}}:{% render familyform.tags user action %}{{familyform.private.label}}:{% render familyform.private user action %}
diff --git a/src/webapp/grampsdb/models.py b/src/webapp/grampsdb/models.py index 1a5bc4398..6bf53241c 100644 --- a/src/webapp/grampsdb/models.py +++ b/src/webapp/grampsdb/models.py @@ -394,6 +394,9 @@ class Tag(models.Model): color = models.CharField(max_length=13) # "#000000000000" # Black priority = models.IntegerField('priority', blank=False) + def __unicode__(self): + return str(self.name) + # Just the following have tag lists: # --------------------------------- #src/gen/lib/family.py @@ -877,6 +880,7 @@ TABLES = [ ("primary", Place), ("primary", Media), ("primary", Note), + ("primary", Tag), ("abstract", SecondaryObject), ("secondary", Attribute), ("secondary", SourceDatamap), diff --git a/src/webapp/grampsdb/view/family.py b/src/webapp/grampsdb/view/family.py index 8deb605ef..2a9749978 100644 --- a/src/webapp/grampsdb/view/family.py +++ b/src/webapp/grampsdb/view/family.py @@ -26,6 +26,7 @@ from webapp.utils import _, boolean from webapp.grampsdb.models import Family from webapp.grampsdb.forms import * from webapp.libdjango import DjangoInterface +from Utils import create_id ## Django Modules from django.shortcuts import get_object_or_404, render_to_response, redirect @@ -45,10 +46,16 @@ def process_family(request, context, handle, action): # view, edit, save action = "add" if request.POST.has_key("action"): action = request.POST.get("action") + + family = Family(father=Person.objects.all()[0], + family_rel_type=FamilyRelType.objects.get( + val=FamilyRelType._DEFAULT[0])) + familyform = FamilyForm(instance=family) + familyform.model = family - context["familyform"] = FamilyForm() - context["object"] = Family() - context["family"] = Family() + context["familyform"] = familyform + context["object"] = family + context["family"] = family context["action"] = action view_template = "view_family_detail.html" diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index 21eb81c99..693063551 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -59,7 +59,6 @@ from webapp.grampsdb.view import * from webapp.dbdjango import DbDjango import cli.user import gen.proxy -from Utils import create_id import const # Menu: (, //, | None, Need authentication ) diff --git a/src/webapp/utils.py b/src/webapp/utils.py index a430df2a2..3eed48181 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -607,10 +607,9 @@ def display_date(obj): return "" def render(formfield, user, action, test=False, truetext="", id=None): - #import pdb; pdb.set_trace() if not user.is_authenticated(): action = "view" - if action == "view": + if action == "view": # show as text if (not user.is_authenticated() and not test) or user.is_authenticated(): fieldname = formfield.name # 'surname' try: @@ -620,10 +619,12 @@ def render(formfield, user, action, test=False, truetext="", id=None): try: retval = str(formfield.form.data[fieldname]) # formfield._data() except: - retval = "[ERROR: %s]" % fieldname + #import pdb; pdb.set_trace() + #retval = "[ERROR: %s]" % fieldname + retval = "[None]" else: retval = truetext - else: + else: # show as widget if id != None: retval = formfield.as_widget(attrs={"id": id}) else: @@ -635,7 +636,9 @@ def render_name(name, user): Given a Django or Gramps object, render the name and return. This function uses authentication, privacy and probably_alive settings. """ - if isinstance(name, models.Name): + if name is None: + return "[None]" + elif isinstance(name, models.Name): if not user.is_authenticated(): name.sanitize() try: