Using Gramps Proxy Databases from Gramps-Connect: first revisions
svn: r13863
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
"setting" : "db_created" ,
|
||||
"description" : "database creation date/time" ,
|
||||
"value_type" : "str" ,
|
||||
"value" : "2009-11-22 17:24"
|
||||
"value" : "2009-12-12 20:42"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -1,3 +1,6 @@
|
||||
import re
|
||||
|
||||
from django import template
|
||||
from django.template import escape, Library
|
||||
from django.utils.safestring import mark_safe
|
||||
from web.utils import *
|
||||
@@ -21,6 +24,40 @@ for filter_name in util_filters:
|
||||
func.is_safe = True
|
||||
register.filter(filter_name, func)
|
||||
|
||||
def get_person_from_handle(db, handle):
|
||||
# db is a Gramps Db interface
|
||||
# handle is a Person Handle
|
||||
return db.get_person_from_handle(handle)
|
||||
|
||||
class TemplateNode(template.Node):
|
||||
def __init__(self, args, var_name):
|
||||
self.db = template.Variable(args[0])
|
||||
self.handle = template.Variable(args[1])
|
||||
self.var_name = var_name
|
||||
|
||||
def render(self, context):
|
||||
context[self.var_name] = \
|
||||
get_person_from_handle(self.db.resolve(context),
|
||||
self.handle.resolve(context))
|
||||
return ''
|
||||
|
||||
def do_get_person_from_handle(parser, token):
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, args = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise template.TemplateSyntaxError, \
|
||||
("%r tag requires arguments" % token.contents.split()[0])
|
||||
m = re.search(r'(.*?) as (\w+)', args)
|
||||
if not m:
|
||||
raise template.TemplateSyntaxError, \
|
||||
("%r tag had invalid arguments" % tag_name)
|
||||
args_string, var_name = m.groups()
|
||||
args = args_string.split()
|
||||
return TemplateNode(args, var_name)
|
||||
|
||||
register.tag("get_person_from_handle", do_get_person_from_handle)
|
||||
|
||||
probably_alive.is_safe = True
|
||||
register.filter('probably_alive', probably_alive)
|
||||
|
||||
|
@@ -43,6 +43,9 @@ import web
|
||||
from web.grampsdb.models import *
|
||||
from web.grampsdb.forms import NameForm
|
||||
from web.utils import probably_alive
|
||||
from web.djangodb import DjangoDb
|
||||
|
||||
from gen.proxy import LivingProxyDb
|
||||
|
||||
_ = lambda text: text
|
||||
|
||||
@@ -276,6 +279,15 @@ def view_detail(request, view, handle):
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
def view(request, view):
|
||||
db_direct = DjangoDb()
|
||||
if not request.user.is_authenticated():
|
||||
#MODE_EXCLUDE_ALL = 0
|
||||
#MODE_INCLUDE_LAST_NAME_ONLY = 1
|
||||
#MODE_INCLUDE_FULL_NAME_ONLY = 2
|
||||
db = LivingProxyDb(db_direct,
|
||||
LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||
else:
|
||||
db = db_direct
|
||||
search = ""
|
||||
if view == "event":
|
||||
if request.user.is_authenticated():
|
||||
@@ -499,6 +511,7 @@ def view(request, view):
|
||||
context["tview"] = _(view.title())
|
||||
context["search"] = search
|
||||
context["total"] = total
|
||||
context["db"] = db
|
||||
if search:
|
||||
context["search_query"] = ("&search=%s" % escape(search))
|
||||
else:
|
||||
|
Reference in New Issue
Block a user