Working on PrivateProxy ideas; minor tweaks otherwise

svn: r13853
This commit is contained in:
Doug Blank 2009-12-20 01:57:17 +00:00
parent 4392fa3120
commit 108ff236f7
11 changed files with 160 additions and 118 deletions

View File

@ -29,9 +29,9 @@
<div id="navigation">
{% block navigation %}
<ul>
<li class="{{ cview|currentSection:"home" }}"><a href="/">Home</a></li>
<li class="{{ tview|currentSection:"home" }}"><a href="/">Home</a></li>
{% for view in views %}
<li class="{{ cview|currentSection:view.1 }}"><a href="/{{view.1}}/">{{view.0}}</a></li>
<li class="{{tview|currentSection:view.1 }}"><a href="/{{view.1}}/">{{view.0}}</a></li>
{% endfor %}
{% if user.is_authenticated %}
<li><a href="/logout">Logout</a></li>

View File

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

View File

@ -11,7 +11,7 @@
</script>
<div class="content" id="IndividualDetail">
<h3>{{form|make_name:user}}</h3>
<h3>Name for Person [{{person.gramps_id}}]</h3>
<div id="summaryarea">
<table class="infolist"> {% comment %} 4 cols {% endcomment %}
<tbody>
@ -103,7 +103,7 @@
</div>
</div>
[<a href="/person/{{person.handle}}/">Back to Person Details</a>]
[<a href="/person/{{person.handle}}/">Back to Person</a>]
{% if user.is_authenticated %}
{% ifequal action "edit" %}
<input type="hidden" name="action" value="save"/>
@ -112,7 +112,6 @@
{% else %}
[<a href="/person/{{person.handle}}/name/{{order}}/edit">Edit Name</a>]
[<a href="/person/{{person.handle}}/name/{{order}}/delete">Delete Name</a>]
[<a href="/person/{{person.handle}}/name/add">Add Name</a>]
{% endifequal %}
{% else %}
{% endif %}

View File

@ -1,13 +0,0 @@
{% load my_tags %}
<table cellspacing="0">
<thead>
<tr>
{% table_header %}
</tr>
</thead>
<tbody>
{% for view in view_list %}<tr class="{% cycle odd,even %}">
<td><a href="/{{view.name|lower}}/">{{ view.name|escape }}</a></td>
</tr>{% endfor %}
</tbody>
</table>

View File

@ -1,8 +1,8 @@
{% extends "gramps-base.html" %}
{% load my_tags %}
{% block title %}Gramps-Connect: {{cview}} view {% endblock %}
{% block heading %}Gramps Connect: {{cview}} view {% endblock %}
{% block title %}Gramps-Connect: {{tview}} view {% endblock %}
{% block heading %}Gramps-Connect: {{tview}} view {% endblock %}
{% block content %}

View File

@ -1,8 +1,8 @@
{% extends "gramps-base.html" %}
{% load my_tags %}
{% block title %}Gramps-Connect: {{cview}} detail {% endblock %}
{% block heading %}Gramps-Connect: {{cview}} detail {% endblock %}
{% block title %}Gramps-Connect: {{tview}} detail {% endblock %}
{% block heading %}Gramps-Connect: {{tview}} detail {% endblock %}
{% block content %}

View File

@ -11,91 +11,54 @@
</script>
<div class="content" id="IndividualDetail">
<h3>{{person.name_set|make_name:user}}</h3>
<h3></h3>
<div id="summaryarea">
<table class="infolist"> {% comment %} 5 cols {% endcomment %}
<tbody>
{% if user.is_authenticated %}
<tr>
<td class="ColumnAttribute">Family:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"surname"}}</td>
<td class="ColumnValue" id="data">{{name.surname}}</td>
<td class="ColumnAttribute">Prefix:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"prefix"}}</td>
<td rowspan="5" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
<td class="ColumnValue" id="data">{{name.prefix}}</td>
<td rowspan="6" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
</tr>
<tr>
<td class="ColumnAttribute" colspan="2"></td>
<td class="ColumnAttribute">Suffix:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"suffix"}}</td>
<td class="ColumnValue" id="data">{{name.suffix}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Given:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"first_name"}}</td>
<td class="ColumnValue" id="data">{{name.first_name}}</td>
<td class="ColumnAttribute">Call Name:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"call"}}</td>
<td class="ColumnValue" id="data">{{name.call}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Type:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"name_type"}}</td>
<td class="ColumnValue" id="data">{{name.name_type}}</td>
<td class="ColumnAttribute">Patronymic:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"patronymic"}}</td>
</tr>
<td class="ColumnValue" id="data">{{name.patronymic}}</td>
</tr>
<tr>
<td class="ColumnAttribute" colspan="2"></td>
<td class="ColumnAttribute">Title:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"title"}}</td>
<tr>
<td class="ColumnValue" id="data">{{name.title}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Gender:</td>
<td class="ColumnValue" id="data">{{person.gender_type|escape}}</td>
<td class="ColumnValue" id="data">{{person.gender_type}}</td>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{person.gramps_id|escape}}</td>
<td class="ColumnValue" id="data">{{person.gramps_id}}</td>
</tr>
<tr>
<td class="ColumnAttribute">Marker:</td>
<td class="ColumnValue" id="data">{{person.marker_type|escape}}</td>
<td class="ColumnValue" id="data">{{person.marker_type}}</td>
<td class="ColumnAttribute" colspan="3"></td>
</tr>
</tbody>
</table>
{% else %}
<tr>
<td class="ColumnAttribute">Family:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"surname"}}</td>
<td class="ColumnAttribute">Prefix:</td>
<td class="ColumnValue" id="data">[Private]</td>
<td rowspan="5" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
</tr>
<td class="ColumnAttribute" colspan="2"></td>
<td class="ColumnAttribute">Suffix:</td>
<td class="ColumnValue" id="data">[Private]</td>
<tr>
<td class="ColumnAttribute">Given:</td>
<td class="ColumnValue" id="data">[Private]</td>
<td class="ColumnAttribute">Call Name:</td>
<td class="ColumnValue" id="data">[Private]</td>
</tr>
<tr>
<td class="ColumnAttribute">Type:</td>
<td class="ColumnValue" id="data">{{person.name_set|preferred:"name_type"}}</td>
<td class="ColumnAttribute">Patronymic:</td>
<td class="ColumnValue" id="data">[Private]</td>
</tr>
</tr>
<td class="ColumnAttribute" colspan="2"></td>
<td class="ColumnAttribute">Title:</td>
<td class="ColumnValue" id="data">[Private]</td>
<tr>
<tr>
<td class="ColumnAttribute">Gender:</td>
<td class="ColumnValue" id="data">{{person.gender_type|escape}}</td>
<td class="ColumnAttribute">ID:</td>
<td class="ColumnValue" id="data">{{person.gramps_id|escape}}</td>
<td class="ColumnAttribute">Marker:</td>
<td class="ColumnValue" id="data"></td>
</tr>
</tbody>
</table>
{% endif %}
</div>
</div>
<!-- Tabs -->

View File

@ -344,6 +344,17 @@ class Person(PrimaryObject):
# .lds_set
# .url_set
def get_primary_name(self):
"""
Return the preferred name of a person.
"""
names = self.name_set.all().order_by("order")
if names.count() > 0:
name = names[0]
else:
name = None
return name
class Family(PrimaryObject):
father = models.ForeignKey('Person', related_name="father_ref",
null=True, blank=True)
@ -456,6 +467,18 @@ class Name(DateObject, SecondaryObject):
["", " "][bool(self.prefix)],
self.surname,
self.first_name)
@staticmethod
def get_dummy():
name = Name()
#name.
def sanitize(self):
self.first_name = "[Private]"
self.prefix = ""
self.suffix = ""
self.prefix = ""
self.prefix = ""
self.prefix = ""
class Lds(DateObject, SecondaryObject):
"""

View File

@ -48,15 +48,12 @@ register.filter('preview', preview)
make_name.is_safe = True
register.filter('make_name', make_name)
def preferred(name_set, attr):
def preferred(person):
try:
name = name_set.get(preferred=True)
name = person.name_set.get(preferred=True)
except:
return "[No preferred name]"
if name:
return escape(getattr(name, attr))
else:
return "[Missing]"
name = None
return name
preferred.is_safe = True
register.filter('preferred', preferred)
@ -88,13 +85,6 @@ def table_header(context, headers = None):
register.inclusion_tag('table_header.html',
takes_context=True)(table_header)
def view_navigation(context):
# add things for the view here
return context
register.inclusion_tag('view_navigation.html',
takes_context=True)(view_navigation)
def paginator(context, adjacent_pages=2):
"""
To be used in conjunction with the object_list generic view.

View File

@ -42,6 +42,7 @@ from django.db.models import Q
import web
from web.grampsdb.models import *
from web.grampsdb.forms import NameForm
from web.utils import probably_alive
_ = lambda text: text
@ -82,13 +83,13 @@ def context_processor(request):
def main_page(request):
context = RequestContext(request)
context["view"] = 'home'
context["cview"] = _('Home')
context["tview"] = _('Home')
return render_to_response("main_page.html", context)
def logout_page(request):
context = RequestContext(request)
context["view"] = 'home'
context["cview"] = _('Home')
context["tview"] = _('Home')
logout(request)
return HttpResponseRedirect('/')
@ -100,7 +101,7 @@ def user_page(request, username):
context = RequestContext(request)
context["username"] = username
context["view"] = 'user'
context["cview"] = _('User')
context["tview"] = _('User')
return render_to_response('user_page.html', context)
def view_name_detail(request, handle, order, action="view"):
@ -171,7 +172,7 @@ def view_name_detail(request, handle, order, action="view"):
action = "edit"
context = RequestContext(request)
context["action"] = action
context["cview"] = action #_('Name')
context["tview"] = _('Name')
context["view"] = 'name'
context["handle"] = handle
context["id"] = id
@ -190,67 +191,91 @@ def view_name_detail(request, handle, order, action="view"):
else:
return render_to_response(view_template, context)
class PrivateProxy(object):
def __init__(self, obj):
self.obj = obj
def __getattr__(self, attr):
return getattr(self.obj, attr)
def view_detail(request, view, handle):
context = RequestContext(request)
context["view"] = view
if view == "event":
try:
obj = Event.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_event_detail.html'
context["tview"] = _("Event")
elif view == "family":
try:
obj = Family.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_family_detail.html'
context["tview"] = _("Family")
elif view == "media":
try:
obj = Media.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_media_detail.html'
context["tview"] = _("Media")
elif view == "note":
try:
obj = Note.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_note_detail.html'
context["tview"] = _("Note")
elif view == "person":
try:
obj = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_person_detail.html'
person = obj
name = person.get_primary_name()
if request.user.is_authenticated():
pass # see everything, no limits
elif probably_alive(person.handle):
name.first_name = "[Living]"
elif person.private:
name = Name()
name.surname = "[Private]"
name.first_name = "[Private]"
# FIXME: protect everything else; what if name.private?
context["name"] = name
context["tview"] = _("Person")
elif view == "place":
try:
obj = Place.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_place_detail.html'
context["tview"] = _("Place")
elif view == "repository":
try:
obj = Repository.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_repository_detail.html'
context["tview"] = _("Repository")
elif view == "source":
try:
obj = Source.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % view)
view_template = 'view_source_detail.html'
context["tview"] = _("Source")
else:
raise Http404(_("Requested page type not known"))
cview = view.title()
context = RequestContext(request)
context["cview"] = cview
context["view"] = view
context["handle"] = handle
context[view] = obj
return render_to_response(view_template, context)
def view(request, view):
cview = view.title()
search = ""
if view == "event":
if request.user.is_authenticated():
@ -471,7 +496,7 @@ def view(request, view):
context = RequestContext(request)
context["page"] = page
context["view"] = view
context["cview"] = cview
context["tview"] = _(view.title())
context["search"] = search
context["total"] = total
if search:

View File

@ -131,7 +131,11 @@ def render(formfield, action):
retval = formfield.as_widget()
return retval
def make_button(text, url):
return """[<a href="%s">%s</a>]""" % (url, text)
def person_event_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Description"),
_("Type"),
@ -153,9 +157,14 @@ def person_event_table(djperson, user):
display_date(djevent),
get_title(djevent.place),
str(event_ref.role_type))
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add event"), "/person/%s/event/add" % djperson.handle)
return retval
def person_name_table(djperson, user):
print "person_name_table", djperson, user
retval = ""
table = Table()
table.columns(_("Name"),
_("Type"),
@ -172,7 +181,10 @@ def person_name_table(djperson, user):
object_id=name.id)
note = ""
if note_refs.count() > 0:
note = dji.Note.get(id=note_refs[0].object_id).text[:50]
try:
note = dji.Note.get(id=note_refs[0].object_id).text[:50]
except:
note = None
table.row(make_name(name, user),
str(name.name_type),
name.group_as,
@ -181,9 +193,13 @@ def person_name_table(djperson, user):
links.append(('URL', "/person/%s/name/%s" %
(name.person.handle, name.order)))
table.links(links)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add name"), "/person/%s/name/add" % djperson.handle)
return retval
def person_source_table(djperson, user):
retval = ""
table = Table()
table.columns(_("ID"),
_("Title"),
@ -200,9 +216,13 @@ def person_source_table(djperson, user):
source_ref.ref_object.author,
source_ref.page,
)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add source"), "/person/%s/source/add" % djperson.handle)
return retval
def person_attribute_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Type"),
_("Value"),
@ -214,9 +234,13 @@ def person_attribute_table(djperson, user):
for attribute in attributes:
table.row(attribute.attribute_type.name,
attribute.value)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add attribute"), "/person/%s/attribute/add" % djperson.handle)
return retval
def person_address_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Date"),
_("Address"),
@ -232,9 +256,13 @@ def person_address_table(djperson, user):
location.city,
location.state,
location.country)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add address"), "/person/%s/address/add" % djperson.handle)
return retval
def person_note_table(djperson, user):
retval = ""
table = Table()
table.columns(
_("ID"),
@ -250,16 +278,24 @@ def person_note_table(djperson, user):
table.row(table.db.get_note_from_handle(note.handle),
str(note_ref.ref_object.note_type),
note_ref.ref_object.text[:50])
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add note"), "/person/%s/note/add" % djperson.handle)
return retval
def person_gallery_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Name"),
_("Type"),
)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add gallery"), "/person/%s/gallery/add" % djperson.handle)
return retval
def person_internet_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Type"),
_("Path"),
@ -270,9 +306,13 @@ def person_internet_table(djperson, user):
table.row(str(url.url_type),
url.path,
url.desc)
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add internet"), "/person/%s/internet/add" % djperson.handle)
return retval
def person_association_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Name"),
_("ID"),
@ -282,9 +322,13 @@ def person_association_table(djperson, user):
associations = gperson.get_person_ref_list()
for association in associations:
table.row()
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add association"), "/person/%s/association/add" % djperson.handle)
return retval
def person_lds_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Type"),
_("Date"),
@ -300,9 +344,13 @@ def person_lds_table(djperson, user):
str(lds.status),
lds.temple,
get_title(lds.place))
return table.get_html()
retval += table.get_html()
if user.is_authenticated():
retval += make_button(_("Add LDS"), "/person/%s/lds/add" % djperson.handle)
return retval
def person_reference_table(djperson, user):
retval = ""
table = Table()
table.columns(_("Type"),
_("ID"),
@ -316,6 +364,7 @@ def person_reference_table(djperson, user):
return table.get_html()
def family_children_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("#"),
@ -332,6 +381,7 @@ def family_children_table(djfamily, user):
return table.get_html()
def family_event_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("Description"),
@ -345,6 +395,7 @@ def family_event_table(djfamily, user):
return table.get_html()
def family_source_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("ID"),
@ -356,6 +407,7 @@ def family_source_table(djfamily, user):
return table.get_html()
def family_attribute_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("Type"),
@ -365,6 +417,7 @@ def family_attribute_table(djfamily, user):
return table.get_html()
def family_note_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("Type"),
@ -374,6 +427,7 @@ def family_note_table(djfamily, user):
return table.get_html()
def family_gallery_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("Column"),
@ -382,6 +436,7 @@ def family_gallery_table(djfamily, user):
return table.get_html()
def family_lds_table(djfamily, user):
retval = ""
table = Table()
table.columns(
_("Type"),