Webapp: changes for web portion to use new Django interface

This commit is contained in:
Doug Blank 2015-08-21 17:24:14 -04:00
parent a93872a0f3
commit 4f4fe6c0de
7 changed files with 214 additions and 219 deletions

View File

@ -20,7 +20,7 @@
""" Views for Person, Name, and Surname """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search from gramps.webapp.utils import _, boolean, update_last_changed, build_search, db
from gramps.webapp.grampsdb.models import Event, EventType, EventRef, EventRoleType, Person from gramps.webapp.grampsdb.models import Event, EventType, EventRef, EventRoleType, Person
from gramps.webapp.grampsdb.forms import * from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface, lookup_role_index from gramps.webapp.libdjango import DjangoInterface, lookup_role_index
@ -33,7 +33,6 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() dji = DjangoInterface()
db = DbDjango()
dd = displayer.display dd = displayer.display
dp = parser.parse dp = parser.parse
@ -94,8 +93,8 @@ def recheck_birth_death_refs(person):
obj_type = ContentType.objects.get_for_model(person) obj_type = ContentType.objects.get_for_model(person)
# Update Birth event references: # Update Birth event references:
events = EventRef.objects.filter( events = EventRef.objects.filter(
object_id=person.id, object_id=person.id,
object_type=obj_type, object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary"), role_type=get_type_from_name(EventRoleType, "Primary"),
ref_object__event_type__val=EventType.BIRTH).order_by("order") ref_object__event_type__val=EventType.BIRTH).order_by("order")
if events: if events:
@ -108,8 +107,8 @@ def recheck_birth_death_refs(person):
person.birth_ref_index = -1 person.birth_ref_index = -1
# Update Death event references: # Update Death event references:
events = EventRef.objects.filter( events = EventRef.objects.filter(
object_id=person.id, object_id=person.id,
object_type=obj_type, object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary"), role_type=get_type_from_name(EventRoleType, "Primary"),
ref_object__event_type__val=EventType.DEATH).order_by("order") ref_object__event_type__val=EventType.DEATH).order_by("order")
if events: if events:
@ -120,7 +119,7 @@ def recheck_birth_death_refs(person):
else: else:
person.death = None person.death = None
person.death_ref_index = -1 person.death_ref_index = -1
def process_event(request, context, handle, act, add_to=None): # view, edit, save def process_event(request, context, handle, act, add_to=None): # view, edit, save
""" """
Process act on person. Can return a redirect. Process act on person. Can return a redirect.
@ -138,24 +137,24 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
# Handle: edit, view, add, create, save, delete, share, save-share # Handle: edit, view, add, create, save, delete, share, save-share
if act == "share": if act == "share":
item, handle = add_to item, handle = add_to
context["pickform"] = PickForm("Pick event", context["pickform"] = PickForm("Pick event",
Event, Event,
(), (),
request.POST) request.POST)
context["object_handle"] = handle context["object_handle"] = handle
context["object_type"] = item context["object_type"] = item
return render_to_response("pick.html", context) return render_to_response("pick.html", context)
elif act == "save-share": elif act == "save-share":
item, handle = add_to item, handle = add_to
pickform = PickForm("Pick event", pickform = PickForm("Pick event",
Event, Event,
(), (),
request.POST) request.POST)
if pickform.data["picklist"]: if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model? parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"] ref_handle = pickform.data["picklist"]
ref_obj = Event.objects.get(handle=ref_handle) ref_obj = Event.objects.get(handle=ref_handle)
dji.add_event_ref_default(parent_obj, ref_obj) dji.add_event_ref_default(parent_obj, ref_obj)
if item == "person": # then need to recheck birth/death indexes: if item == "person": # then need to recheck birth/death indexes:
recheck_birth_death_refs(parent_obj) recheck_birth_death_refs(parent_obj)
@ -171,7 +170,7 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
event = Event(gramps_id=dji.get_next_id(Event, "E")) event = Event(gramps_id=dji.get_next_id(Event, "E"))
eventform = EventForm(instance=event) eventform = EventForm(instance=event)
eventform.model = event eventform.model = event
elif act in ["view", "edit"]: elif act in ["view", "edit"]:
event = Event.objects.get(handle=handle) event = Event.objects.get(handle=handle)
genlibevent = db.get_event_from_handle(handle) genlibevent = db.get_event_from_handle(handle)
if genlibevent: if genlibevent:
@ -179,7 +178,7 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
event.text = dd(date) event.text = dd(date)
eventform = EventForm(instance=event) eventform = EventForm(instance=event)
eventform.model = event eventform.model = event
elif act == "save": elif act == "save":
event = Event.objects.get(handle=handle) event = Event.objects.get(handle=handle)
eventform = EventForm(request.POST, instance=event) eventform = EventForm(request.POST, instance=event)
eventform.model = event eventform.model = event
@ -193,7 +192,7 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
act = "view" act = "view"
else: else:
act = "edit" act = "edit"
elif act == "create": elif act == "create":
event = Event(handle=create_id()) event = Event(handle=create_id())
eventform = EventForm(request.POST, instance=event) eventform = EventForm(request.POST, instance=event)
eventform.model = event eventform.model = event
@ -213,7 +212,7 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
act = "view" act = "view"
else: else:
act = "add" act = "add"
elif act == "delete": elif act == "delete":
event = Event.objects.get(handle=handle) event = Event.objects.get(handle=handle)
delete_event(event) delete_event(event)
return redirect("/event/") return redirect("/event/")
@ -224,5 +223,5 @@ def process_event(request, context, handle, act, add_to=None): # view, edit, sav
context["object"] = event context["object"] = event
context["event"] = event context["event"] = event
context["action"] = act context["action"] = act
return render_to_response(view_template, context) return render_to_response(view_template, context)

View File

@ -20,7 +20,7 @@
""" Views for Person, Name, and Surname """ """ Views for Person, Name, and Surname """
## Gramps Modules ## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, StyledNoteFormatter, parse_styled_text, build_search from gramps.webapp.utils import _, boolean, update_last_changed, StyledNoteFormatter, parse_styled_text, build_search, db
from gramps.webapp.grampsdb.models import Note from gramps.webapp.grampsdb.models import Note
from gramps.webapp.grampsdb.forms import * from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface from gramps.webapp.libdjango import DjangoInterface
@ -32,7 +32,6 @@ from django.template import Context, RequestContext
## Globals ## Globals
dji = DjangoInterface() dji = DjangoInterface()
db = DbDjango()
snf = StyledNoteFormatter(db) snf = StyledNoteFormatter(db)
# add a note to a person: # add a note to a person:
@ -59,24 +58,24 @@ def process_note(request, context, handle, act, add_to=None): # view, edit, save
# Handle: edit, view, add, create, save, delete, share, save-share # Handle: edit, view, add, create, save, delete, share, save-share
if act == "share": if act == "share":
item, handle = add_to item, handle = add_to
context["pickform"] = PickForm("Pick note", context["pickform"] = PickForm("Pick note",
Note, Note,
(), (),
request.POST) request.POST)
context["object_handle"] = handle context["object_handle"] = handle
context["object_type"] = item context["object_type"] = item
return render_to_response("pick.html", context) return render_to_response("pick.html", context)
elif act == "save-share": elif act == "save-share":
item, handle = add_to item, handle = add_to
pickform = PickForm("Pick note", pickform = PickForm("Pick note",
Note, Note,
(), (),
request.POST) request.POST)
if pickform.data["picklist"]: if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model? parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"] ref_handle = pickform.data["picklist"]
ref_obj = Note.objects.get(handle=ref_handle) ref_obj = Note.objects.get(handle=ref_handle)
dji.add_note_ref(parent_obj, ref_obj) dji.add_note_ref(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-notes" % (item, handle, build_search(request))) return redirect("/%s/%s%s#tab-notes" % (item, handle, build_search(request)))
@ -90,13 +89,13 @@ def process_note(request, context, handle, act, add_to=None): # view, edit, save
notetext = "" notetext = ""
noteform = NoteForm(instance=note, initial={"notetext": notetext}) noteform = NoteForm(instance=note, initial={"notetext": notetext})
noteform.model = note noteform.model = note
elif act in ["view", "edit"]: elif act in ["view", "edit"]:
note = Note.objects.get(handle=handle) note = Note.objects.get(handle=handle)
genlibnote = db.get_note_from_handle(note.handle) genlibnote = db.get_note_from_handle(note.handle)
notetext = snf.format(genlibnote) notetext = snf.format(genlibnote)
noteform = NoteForm(instance=note, initial={"notetext": notetext}) noteform = NoteForm(instance=note, initial={"notetext": notetext})
noteform.model = note noteform.model = note
elif act == "save": elif act == "save":
note = Note.objects.get(handle=handle) note = Note.objects.get(handle=handle)
notetext = "" notetext = ""
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext}) noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
@ -108,12 +107,12 @@ def process_note(request, context, handle, act, add_to=None): # view, edit, save
note = noteform.save() note = noteform.save()
dji.save_note_markup(note, notedata[1]) dji.save_note_markup(note, notedata[1])
note.save_cache() note.save_cache()
notetext = noteform.data["notetext"] notetext = noteform.data["notetext"]
act = "view" act = "view"
else: else:
notetext = noteform.data["notetext"] notetext = noteform.data["notetext"]
act = "edit" act = "edit"
elif act == "create": elif act == "create":
note = Note(handle=create_id()) note = Note(handle=create_id())
notetext = "" notetext = ""
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext}) noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
@ -132,12 +131,12 @@ def process_note(request, context, handle, act, add_to=None): # view, edit, save
dji.add_note_ref(obj, note) dji.add_note_ref(obj, note)
obj.save_cache() obj.save_cache()
return redirect("/%s/%s#tab-notes" % (item, handle)) return redirect("/%s/%s#tab-notes" % (item, handle))
notetext = noteform.data["notetext"] notetext = noteform.data["notetext"]
act = "view" act = "view"
else: else:
notetext = noteform.data["notetext"] notetext = noteform.data["notetext"]
act = "add" act = "add"
elif act == "delete": elif act == "delete":
# FIXME: delete markup too for this note # FIXME: delete markup too for this note
note = Note.objects.get(handle=handle) note = Note.objects.get(handle=handle)
note.delete() note.delete()
@ -150,5 +149,5 @@ def process_note(request, context, handle, act, add_to=None): # view, edit, save
context["notetext"] = notetext context["notetext"] = notetext
context["note"] = note context["note"] = note
context["action"] = act context["action"] = act
return render_to_response(view_template, context) return render_to_response(view_template, context)

View File

@ -57,13 +57,13 @@ from gramps.version import VERSION
# Gramps-connect imports: # Gramps-connect imports:
import gramps.webapp import gramps.webapp
from gramps.webapp.utils import _, build_args from gramps.webapp.utils import _, build_args, db
from gramps.webapp.grampsdb.models import * from gramps.webapp.grampsdb.models import *
from gramps.webapp.grampsdb.view import * from gramps.webapp.grampsdb.view import *
from gramps.webapp.djangodb import DbDjango from gramps.webapp.djangodb import DbDjango
import gramps.cli.user import gramps.cli.user
# Menu: (<Nice name>, /<path>/, <Model> | None, Need authentication ) # Menu: (<Nice name>, /<path>/, <Model> | None, Need authentication )
MENU = [ MENU = [
(_('Browse'), 'browse', None, False), (_('Browse'), 'browse', None, False),
(_('Reports'), 'report', Report, True), (_('Reports'), 'report', Report, True),
@ -71,7 +71,7 @@ MENU = [
] ]
# Views: [(<Nice name plural>, /<name>/handle, <Model>), ] # Views: [(<Nice name plural>, /<name>/handle, <Model>), ]
VIEWS = [ VIEWS = [
(_('People'), 'person', Name), (_('People'), 'person', Name),
(_('Families'), 'family', Family), (_('Families'), 'family', Family),
(_('Events'), 'event', Event), (_('Events'), 'event', Event),
(_('Notes'), 'note', Note), (_('Notes'), 'note', Note),
@ -107,8 +107,8 @@ def context_processor(request):
search = request.GET.get("search", "") or request.POST.get("search", "") search = request.GET.get("search", "") or request.POST.get("search", "")
page = request.GET.get("page", "") or request.POST.get("page", "") page = request.GET.get("page", "") or request.POST.get("page", "")
context["page"] = page context["page"] = page
context["search"] = search context["search"] = search
context["args"] = build_args(search=search, page=page) context["args"] = build_args(search=search, page=page)
return context return context
@ -120,7 +120,7 @@ def main_page(request):
context["view"] = 'home' context["view"] = 'home'
context["tview"] = _('Home') context["tview"] = _('Home')
return render_to_response("main_page.html", context) return render_to_response("main_page.html", context)
def logout_page(request): def logout_page(request):
""" """
Logout a user. Logout a user.
@ -174,10 +174,10 @@ def timestamp():
return time.strftime("%Y-%m-%d:%H:%M:%S") return time.strftime("%Y-%m-%d:%H:%M:%S")
def send_file(request, filename, mimetype): def send_file(request, filename, mimetype):
""" """
Send a file through Django without loading the whole file into Send a file through Django without loading the whole file into
memory at once. The FileWrapper will turn the file object into an memory at once. The FileWrapper will turn the file object into an
iterator for chunks of 8KB. iterator for chunks of 8KB.
""" """
from django.core.servers.basehttp import FileWrapper from django.core.servers.basehttp import FileWrapper
wrapper = FileWrapper(open(filename, mode="rb")) wrapper = FileWrapper(open(filename, mode="rb"))
@ -196,7 +196,6 @@ def process_report_run(request, handle):
from gramps.webapp.reports import import_file, export_file, download from gramps.webapp.reports import import_file, export_file, download
from gramps.cli.plug import run_report from gramps.cli.plug import run_report
import traceback import traceback
db = DbDjango()
if request.user.is_authenticated(): if request.user.is_authenticated():
profile = request.user.profile profile = request.user.profile
report = Report.objects.get(handle=handle) report = Report.objects.get(handle=handle)
@ -227,7 +226,7 @@ def process_report_run(request, handle):
export_file(db, filename, gramps.cli.user.User()) # callback export_file(db, filename, gramps.cli.user.User()) # callback
mimetype = 'text/plain' mimetype = 'text/plain'
elif report.report_type == "import": elif report.report_type == "import":
filename = download(args["i"], "/tmp/%s-%s-%s.%s" % (str(profile.user.username), filename = download(args["i"], "/tmp/%s-%s-%s.%s" % (str(profile.user.username),
str(handle), str(handle),
timestamp(), timestamp(),
args["iff"])) args["iff"]))
@ -311,7 +310,7 @@ def view_list(request, view):
object_list = Note.objects \ object_list = Note.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_notes.html' view_template = 'view_notes.html'
total = Note.objects.all().count() total = Note.objects.all().count()
elif view == "person": elif view == "person":
@ -321,7 +320,7 @@ def view_list(request, view):
object_list = Name.objects \ object_list = Name.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_people.html' view_template = 'view_people.html'
total = Name.objects.all().count() total = Name.objects.all().count()
elif view == "family": elif view == "family":
@ -331,7 +330,7 @@ def view_list(request, view):
object_list = Family.objects \ object_list = Family.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_families.html' view_template = 'view_families.html'
total = Family.objects.all().count() total = Family.objects.all().count()
elif view == "place": elif view == "place":
@ -341,7 +340,7 @@ def view_list(request, view):
object_list = Place.objects \ object_list = Place.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_places.html' view_template = 'view_places.html'
total = Place.objects.all().count() total = Place.objects.all().count()
elif view == "repository": elif view == "repository":
@ -351,7 +350,7 @@ def view_list(request, view):
object_list = Repository.objects \ object_list = Repository.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_repositories.html' view_template = 'view_repositories.html'
total = Repository.objects.all().count() total = Repository.objects.all().count()
elif view == "citation": elif view == "citation":
@ -361,7 +360,7 @@ def view_list(request, view):
object_list = Citation.objects \ object_list = Citation.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_citations.html' view_template = 'view_citations.html'
total = Citation.objects.all().count() total = Citation.objects.all().count()
elif view == "source": elif view == "source":
@ -371,7 +370,7 @@ def view_list(request, view):
object_list = Source.objects \ object_list = Source.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_sources.html' view_template = 'view_sources.html'
total = Source.objects.all().count() total = Source.objects.all().count()
elif view == "tag": elif view == "tag":
@ -381,7 +380,7 @@ def view_list(request, view):
object_list = Tag.objects \ object_list = Tag.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_tags.html' view_template = 'view_tags.html'
total = Tag.objects.all().count() total = Tag.objects.all().count()
elif view == "report": elif view == "report":
@ -391,16 +390,16 @@ def view_list(request, view):
object_list = Report.objects \ object_list = Report.objects \
.filter(query) \ .filter(query) \
.order_by(*order) \ .order_by(*order) \
.distinct() .distinct()
view_template = 'view_report.html' view_template = 'view_report.html'
total = Report.objects.all().count() total = Report.objects.all().count()
else: else:
raise Http404("Requested page type '%s' not known" % view) raise Http404("Requested page type '%s' not known" % view)
if request.user.is_authenticated(): if request.user.is_authenticated():
paginator = Paginator(object_list, 20) paginator = Paginator(object_list, 20)
else: else:
paginator = Paginator(object_list, 20) paginator = Paginator(object_list, 20)
try: try:
page = int(request.GET.get('page', '1')) page = int(request.GET.get('page', '1'))
@ -445,7 +444,7 @@ def add_share(request, view, item, handle):
""" """
# /person/share/family/handle # /person/share/family/handle
# Use an existing person with this family # Use an existing person with this family
# r'^(?P<view>(\w+))/share/(?P<item>(\w+))/(?P<handle>(\w+))$', # r'^(?P<view>(\w+))/share/(?P<item>(\w+))/(?P<handle>(\w+))$',
act = "share" act = "share"
if "action" in request.POST: if "action" in request.POST:
act = request.POST.get("action") # can be "save-share" act = request.POST.get("action") # can be "save-share"
@ -465,7 +464,6 @@ def action(request, view, handle, act, add_to=None):
/object/handle/action, or /object/add. /object/handle/action, or /object/add.
""" """
from gramps.webapp.reports import get_plugin_options from gramps.webapp.reports import get_plugin_options
db = DbDjango()
# redirect: # redirect:
rd = None rd = None
obj = None obj = None
@ -641,7 +639,7 @@ def action(request, view, handle, act, add_to=None):
obj = Report.objects.get(handle=handle) obj = Report.objects.get(handle=handle)
except: except:
raise Http404(_("Requested %s does not exist.") % view) raise Http404(_("Requested %s does not exist.") % view)
override = {} override = {}
if obj.options: if obj.options:
for pair in obj.options.split("\\n"): for pair in obj.options.split("\\n"):
key, value = pair.split("=", 1) key, value = pair.split("=", 1)
@ -689,11 +687,11 @@ def build_string_query(field, value, exact=False, startswith=False, endswith=Fal
if exact: if exact:
retval = Q(**{"%s" % field: value}) retval = Q(**{"%s" % field: value})
elif startswith: elif startswith:
retval = Q(**{"%s__istartswith" % field: value}) retval = Q(**{"%s__istartswith" % field: value})
elif endswith: elif endswith:
retval = Q(**{"%s__iendswith" % field: value}) retval = Q(**{"%s__iendswith" % field: value})
else: # default else: # default
retval = Q(**{"%s__icontains" % field: value}) retval = Q(**{"%s__icontains" % field: value})
return retval return retval
def build_person_query(request, search): def build_person_query(request, search):
@ -704,11 +702,11 @@ def build_person_query(request, search):
protect = not request.user.is_authenticated() protect = not request.user.is_authenticated()
### Build the order: ### Build the order:
if protect: if protect:
# Do this to get the names sorted by private/alive # Do this to get the names sorted by private/alive
# NOTE: names can be private # NOTE: names can be private
terms = ["surname", "given", "id", "tag"] terms = ["surname", "given", "id", "tag"]
query = Q(private=False) & Q(person__private=False) query = Q(private=False) & Q(person__private=False)
order = ["surname__surname", "private", "person__probably_alive", order = ["surname__surname", "private", "person__probably_alive",
"first_name"] "first_name"]
else: else:
terms = ["surname", "given", "id", "tag", "public", "private"] terms = ["surname", "given", "id", "tag", "public", "private"]
@ -775,11 +773,11 @@ def build_person_query(request, search):
make_message(request, "Invalid query field '%s'" % field) make_message(request, "Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(surname__surname__icontains=search) | query &= (Q(surname__surname__icontains=search) |
Q(surname__prefix__icontains=search) | Q(surname__prefix__icontains=search) |
Q(person__gramps_id__icontains=search)) Q(person__gramps_id__icontains=search))
else: else:
query &= (Q(surname__surname__icontains=search) | query &= (Q(surname__surname__icontains=search) |
Q(first_name__icontains=search) | Q(first_name__icontains=search) |
Q(suffix__icontains=search) | Q(suffix__icontains=search) |
Q(surname__prefix__icontains=search) | Q(surname__prefix__icontains=search) |
@ -798,21 +796,21 @@ def build_family_query(request, search):
protect = not request.user.is_authenticated() protect = not request.user.is_authenticated()
if protect: if protect:
terms = ["father", "mother", "id", "type", "surnames", "tag"] terms = ["father", "mother", "id", "type", "surnames", "tag"]
query = (Q(private=False) & Q(father__private=False) & query = (Q(private=False) & Q(father__private=False) &
Q(mother__private=False)) Q(mother__private=False))
order = ["father__name__surname__surname", order = ["father__name__surname__surname",
"father__private", "father__probably_alive", "father__private", "father__probably_alive",
"father__name__first_name", "father__name__first_name",
"mother__name__surname__surname", "mother__name__surname__surname",
"mother__private", "mother__probably_alive", "mother__private", "mother__probably_alive",
"mother__name__first_name"] "mother__name__first_name"]
else: else:
terms = ["father", "mother", "id", "type", "surnames", "father.name.first_name", terms = ["father", "mother", "id", "type", "surnames", "father.name.first_name",
"mother.name.first_name", "tag", "public", "private"] "mother.name.first_name", "tag", "public", "private"]
query = Q() query = Q()
order = ["father__name__surname__surname", order = ["father__name__surname__surname",
"father__name__first_name", "father__name__first_name",
"mother__name__surname__surname", "mother__name__surname__surname",
"mother__name__first_name"] "mother__name__first_name"]
if search: if search:
if "," in search or "=" in search: if "," in search or "=" in search:
@ -912,13 +910,13 @@ def build_media_query(request, search):
if "." in field and not protect: if "." in field and not protect:
query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith) query &= build_string_query(field.replace(".", "__"), value, exact, startswith, endswith)
elif field == "id": elif field == "id":
query &= build_string_query("gramps_id", value, exact, startswith, endswith) query &= build_string_query("gramps_id", value, exact, startswith, endswith)
elif field == "path": elif field == "path":
query &= build_string_query("path", value, exact, startswith, endswith) query &= build_string_query("path", value, exact, startswith, endswith)
elif field == "description": elif field == "description":
query &= build_string_query("desc", value, exact, startswith, endswith) query &= build_string_query("desc", value, exact, startswith, endswith)
elif field == "mime": elif field == "mime":
query &= build_string_query("mime", value, exact, startswith, endswith) query &= build_string_query("mime", value, exact, startswith, endswith)
elif field == "tag": elif field == "tag":
query &= build_string_query("tags__name", value, exact, startswith, endswith) query &= build_string_query("tags__name", value, exact, startswith, endswith)
elif field == "private": elif field == "private":
@ -926,17 +924,17 @@ def build_media_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
Q(path__icontains=search) | Q(path__icontains=search) |
Q(desc__icontains=search) | Q(desc__icontains=search) |
Q(mime__icontains=search)) Q(mime__icontains=search))
else: else:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
Q(path__icontains=search) | Q(path__icontains=search) |
Q(desc__icontains=search) | Q(desc__icontains=search) |
Q(mime__icontains=search)) Q(mime__icontains=search))
else: # no search else: # no search
pass # nothing left to do pass # nothing left to do
@ -978,9 +976,9 @@ def build_note_query(request, search):
elif field == "id": elif field == "id":
query &= build_string_query("gramps_id", value, exact, startswith, endswith) query &= build_string_query("gramps_id", value, exact, startswith, endswith)
elif field == "type": elif field == "type":
query &= build_string_query("note_type__name", value, exact, startswith, endswith) query &= build_string_query("note_type__name", value, exact, startswith, endswith)
elif field == "text": elif field == "text":
query &= build_string_query("text", value, exact, startswith, endswith) query &= build_string_query("text", value, exact, startswith, endswith)
elif field == "tag": elif field == "tag":
query &= build_string_query("tags__name", value, exact, startswith, endswith) query &= build_string_query("tags__name", value, exact, startswith, endswith)
elif field == "private": elif field == "private":
@ -988,7 +986,7 @@ def build_note_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
@ -1041,13 +1039,13 @@ def build_place_query(request, search):
elif field == "id": elif field == "id":
query &= build_string_query("gramps_id", value, exact, startswith, endswith) query &= build_string_query("gramps_id", value, exact, startswith, endswith)
elif field == "title": elif field == "title":
query &= build_string_query("title", value, exact, startswith, endswith) query &= build_string_query("title", value, exact, startswith, endswith)
elif field == "private": elif field == "private":
query &= Q(private=boolean(value)) query &= Q(private=boolean(value))
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
@ -1095,7 +1093,7 @@ def build_repository_query(request, search):
elif field == "id": elif field == "id":
query &= build_string_query("gramps_id", value, exact, startswith, endswith) query &= build_string_query("gramps_id", value, exact, startswith, endswith)
elif field == "name": elif field == "name":
query &= build_string_query("name", value, exact, startswith, endswith) query &= build_string_query("name", value, exact, startswith, endswith)
elif field == "type": elif field == "type":
query &= build_string_query("repository_type__name", value, exact, startswith, endswith) query &= build_string_query("repository_type__name", value, exact, startswith, endswith)
elif field == "private": elif field == "private":
@ -1103,7 +1101,7 @@ def build_repository_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
@ -1159,7 +1157,7 @@ def build_citation_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search)) query &= (Q(gramps_id__icontains=search))
@ -1209,7 +1207,7 @@ def build_source_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= Q(gramps_id__icontains=search) query &= Q(gramps_id__icontains=search)
@ -1255,7 +1253,7 @@ def build_tag_query(request, search):
elif field == "name": elif field == "name":
query &= Q(name__icontains=value) query &= Q(name__icontains=value)
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= Q(name__icontains=search) query &= Q(name__icontains=search)
@ -1302,7 +1300,7 @@ def build_report_query(request, search):
elif field == "name": elif field == "name":
query &= Q(name__icontains=value) query &= Q(name__icontains=value)
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= Q(name__icontains=search) query &= Q(name__icontains=search)
@ -1358,7 +1356,7 @@ def build_event_query(request, search):
elif field == "public": elif field == "public":
query &= Q(public=boolean(value)) query &= Q(public=boolean(value))
else: else:
request.user.message_set.create(message="Invalid query field '%s'" % field) request.user.message_set.create(message="Invalid query field '%s'" % field)
else: # no search fields, just raw search else: # no search fields, just raw search
if protect: if protect:
query &= (Q(gramps_id__icontains=search) | query &= (Q(gramps_id__icontains=search) |
@ -1393,12 +1391,12 @@ def process_reference(request, ref_by, handle, ref_to, order):
ref_to_class = dji.get_model("%sRef" % ref_to.title()) ref_to_class = dji.get_model("%sRef" % ref_to.title())
exclude = ["last_changed_by", "last_changed", "object_type", "object_id", "ref_object"] exclude = ["last_changed_by", "last_changed", "object_type", "object_id", "ref_object"]
if order == "new": if order == "new":
referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id, referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
object_type=object_type, object_type=object_type,
order=0) order=0)
form = modelformset_factory(ref_to_class, exclude=exclude, extra=1)(queryset=referenced_to) form = modelformset_factory(ref_to_class, exclude=exclude, extra=1)(queryset=referenced_to)
else: else:
referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id, referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
object_type=object_type, object_type=object_type,
order=order) order=order)
form = modelformset_factory(ref_to_class, exclude=exclude, extra=0)(queryset=referenced_to) form = modelformset_factory(ref_to_class, exclude=exclude, extra=0)(queryset=referenced_to)
@ -1410,7 +1408,7 @@ def process_reference(request, ref_by, handle, ref_to, order):
context["object"] = referenced_by context["object"] = referenced_by
context["handle"] = referenced_by.handle context["handle"] = referenced_by.handle
context["url"] = referenced_to[0].get_reference_to().get_url() context["url"] = referenced_to[0].get_reference_to().get_url()
#"/%s/%s" % (referenced_to[0].ref_object.__class__.__name__.lower(), #"/%s/%s" % (referenced_to[0].ref_object.__class__.__name__.lower(),
# referenced_to[0].ref_object.handle) # referenced_to[0].ref_object.handle)
context["referenced_by"] = "/%s/%s" % (referenced_by.__class__.__name__.lower(), context["referenced_by"] = "/%s/%s" % (referenced_by.__class__.__name__.lower(),
referenced_by.handle) referenced_by.handle)
@ -1451,7 +1449,7 @@ def process_child(request, handle, act, child):
elif act == "down": elif act == "down":
if int(child) <= len(childrefs) - 1: if int(child) <= len(childrefs) - 1:
childrefs[int(child) - 1].order = int(child) + 1 childrefs[int(child) - 1].order = int(child) + 1
childrefs[int(child)].order = int(child) childrefs[int(child)].order = int(child)
childrefs[int(child) - 1].save() childrefs[int(child) - 1].save()
childrefs[int(child)].save() childrefs[int(child)].save()
dji.rebuild_cache(family) dji.rebuild_cache(family)
@ -1465,12 +1463,12 @@ def process_list_item(request, view, handle, act, item, index):
# /citation/872323636232635/down/attribute/2 # /citation/872323636232635/down/attribute/2
index = int(index) index = int(index)
tab = { tab = {
"eventref": "#tab-events", "eventref": "#tab-events",
"citationref": "#tab-citations", "citationref": "#tab-citations",
"repositoryref": "#tab-repositories", "repositoryref": "#tab-repositories",
"noteref": "#tab-notes", "noteref": "#tab-notes",
"attribute": "#tab-attributes", "attribute": "#tab-attributes",
"media": "#tab-media", "media": "#tab-media",
"lds": "#tab-lds", "lds": "#tab-lds",
"parentfamily": "#tab-references", "parentfamily": "#tab-references",
"family": "#tab-references", "family": "#tab-references",
@ -1548,11 +1546,10 @@ def process_json_request(request):
""" """
import gramps.gen.lib import gramps.gen.lib
from gramps.gen.proxy import PrivateProxyDb, LivingProxyDb from gramps.gen.proxy import PrivateProxyDb, LivingProxyDb
db = DbDjango()
if not request.user.is_authenticated(): if not request.user.is_authenticated():
db = PrivateProxyDb(db) db = PrivateProxyDb(db)
db = LivingProxyDb(db, db = LivingProxyDb(db,
LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY, LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY,
None, # current year None, # current year
1) # years after death 1) # years after death
field = request.GET.get("field", None) field = request.GET.get("field", None)

View File

@ -41,9 +41,8 @@
import os, sys import os, sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gramps.webapp.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gramps.webapp.default_settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)

View File

@ -20,7 +20,7 @@
#### This sets up Django so you can interact with it via the Python #### This sets up Django so you can interact with it via the Python
#### command line. #### command line.
#### Start with something like: #### Start with something like:
#### $ PYTHONPATH=..:../plugins/lib python -i shell.py #### $ PYTHONPATH=..:../plugins/lib python -i shell.py
#### >>> Person.objects.all() #### >>> Person.objects.all()
import os import os
@ -58,7 +58,7 @@ with open(pystartup) as f:
exec(code, globals(), locals()) exec(code, globals(), locals())
from django.conf import settings from django.conf import settings
import gramps.webapp.settings as default_settings from gramps.webapp import default_settings
try: try:
settings.configure(default_settings) settings.configure(default_settings)
except RuntimeError: except RuntimeError:
@ -82,12 +82,13 @@ from gramps.cli.user import User as GUser # gramps user
from django.db.models import Q from django.db.models import Q
db = DbDjango() db = DbDjango()
dji = DjangoInterface()
db.load(os.path.abspath(os.path.dirname(__file__)))
dd = displayer.display dd = displayer.display
dp = parser.parse dp = parser.parse
#import_file(db, #import_file(db,
# "/home/dblank/gramps/trunk/example/gramps/data.gramps", # "/home/dblank/gramps/trunk/example/gramps/data.gramps",
# GUser()) # GUser())
#snf = StyledNoteFormatter(db) #snf = StyledNoteFormatter(db)

View File

@ -25,6 +25,7 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import sys import sys
import os
import re import re
import datetime import datetime
from html.parser import HTMLParser from html.parser import HTMLParser
@ -74,7 +75,7 @@ _ = glocale.translation.gettext
TAB_HEIGHT = 200 TAB_HEIGHT = 200
util_filters = [ util_filters = [
'nbsp', 'nbsp',
'date_as_text', 'date_as_text',
'render_name', 'render_name',
] ]
@ -83,7 +84,7 @@ util_tags = [
'render', 'render',
'media_link', 'media_link',
'render_name', 'render_name',
"get_person_from_handle", "get_person_from_handle",
"event_table", "event_table",
"history_table", "history_table",
"name_table", "name_table",
@ -117,10 +118,10 @@ util_tags = [
# Module Constants # Module Constants
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
dji = libdjango.DjangoInterface()
dd = displayer.display dd = displayer.display
dp = parser.parse dp = parser.parse
db = DbDjango() db = DbDjango()
db.load(os.path.abspath(os.path.dirname(__file__)))
def register_plugins(user): def register_plugins(user):
dbstate = DbState() dbstate = DbState()
@ -199,7 +200,7 @@ class Table(object):
""" """
def __init__(self, id, style=None): def __init__(self, id, style=None):
self.id = id # css id self.id = id # css id
self.db = DbDjango() self.db = db
self.access = SimpleAccess(self.db) self.access = SimpleAccess(self.db)
self.table = SimpleTable(self.access) self.table = SimpleTable(self.access)
self.column_widths = None self.column_widths = None
@ -210,24 +211,24 @@ class Table(object):
# None is paperstyle, which is ignored: # None is paperstyle, which is ignored:
self.doc = Doc(HtmlDoc( self.doc = Doc(HtmlDoc(
make_basic_stylesheet( make_basic_stylesheet(
Table={"set_width":95}, Table={"set_width":95},
TableHeaderCell={"set_bottom_border": True, TableHeaderCell={"set_bottom_border": True,
"set_right_border": True, "set_right_border": True,
"set_padding": .1, "set_padding": .1,
}, },
TableDataCell={"set_bottom_border": True, TableDataCell={"set_bottom_border": True,
"set_right_border": True, "set_right_border": True,
"set_padding": .1, "set_padding": .1,
}, },
), ),
None)) None))
self.doc.doc._backend = HtmlBackend() self.doc.doc._backend = HtmlBackend()
self.doc.doc.use_table_headers = True self.doc.doc.use_table_headers = True
# You can set elements id, class, etc: # You can set elements id, class, etc:
self.doc.doc.htmllist += [ self.doc.doc.htmllist += [
Html('div', Html('div',
class_="content", class_="content",
id=self.id, id=self.id,
style=("overflow: auto; height:%spx; background-color: #f4f0ec;" % TAB_HEIGHT) if not style else style)] style=("overflow: auto; height:%spx; background-color: #f4f0ec;" % TAB_HEIGHT) if not style else style)]
def columns(self, *args): def columns(self, *args):
@ -292,7 +293,7 @@ def make_button(text, url, *args):
if text[0] in "+$-?x" or text in ["x", "^", "v", "<", "<<", ">", ">>"]: if text[0] in "+$-?x" or text in ["x", "^", "v", "<", "<<", ">", ">>"]:
return mark_safe(make_image_button(text, url, kwargs, last)) return mark_safe(make_image_button(text, url, kwargs, last))
else: else:
return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" % return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" %
(text, url, kwargs, last)) (text, url, kwargs, last))
def make_image_button(text, url, kwargs, last): def make_image_button(text, url, kwargs, last):
@ -335,7 +336,7 @@ def make_image_button(text, url, kwargs, last):
return make_image_button2(button, text, url, kwargs, last) return make_image_button2(button, text, url, kwargs, last)
def make_image_button2(button, text, url, kwargs="", last=""): def make_image_button2(button, text, url, kwargs="", last=""):
if button == "cancel": if button == "cancel":
filename = "/images/gtk-remove.png" filename = "/images/gtk-remove.png"
elif button == "x": # delete elif button == "x": # delete
filename = "/images/gtk-remove.png" filename = "/images/gtk-remove.png"
@ -374,7 +375,7 @@ def event_table(obj, user, act, url, args):
table = Table("event_table") table = Table("event_table")
table.columns( table.columns(
"", "",
_("Description"), _("Description"),
_("Type"), _("Type"),
_("ID"), _("ID"),
_("Date"), _("Date"),
@ -384,7 +385,7 @@ def event_table(obj, user, act, url, args):
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
event_ref_list = models.EventRef.objects.filter( event_ref_list = models.EventRef.objects.filter(
object_id=obj.id, object_id=obj.id,
object_type=obj_type).order_by("order") object_type=obj_type).order_by("order")
event_list = [(o.ref_object, o) for o in event_ref_list] event_list = [(o.ref_object, o) for o in event_ref_list]
links = [] links = []
@ -393,7 +394,7 @@ def event_table(obj, user, act, url, args):
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and act == "view" else "", table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and act == "view" else "",
djevent.description, djevent.description,
table.db.get_event_from_handle(djevent.handle), table.db.get_event_from_handle(djevent.handle),
djevent.gramps_id, djevent.gramps_id,
display_date(djevent), display_date(djevent),
get_title(djevent.place), get_title(djevent.place),
str(event_ref.role_type)) str(event_ref.role_type))
@ -429,16 +430,16 @@ def history_table(obj, user, act):
cssid = "tab-history" cssid = "tab-history"
table = Table("history_table") table = Table("history_table")
table.columns( table.columns(
_("Action"), _("Action"),
_("Comment"), _("Comment"),
) )
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
for entry in models.Log.objects.filter( for entry in models.Log.objects.filter(
object_id=obj.id, object_id=obj.id,
object_type=obj_type): object_type=obj_type):
table.row( table.row(
"%s on %s by %s" % (entry.log_type, "%s on %s by %s" % (entry.log_type,
entry.last_changed, entry.last_changed,
entry.last_changed_by), entry.last_changed_by),
entry.reason) entry.reason)
@ -458,7 +459,7 @@ def name_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-names" cssid = "tab-names"
table = Table("name_table") table = Table("name_table")
table.columns(_("Name"), table.columns(_("Name"),
_("Type"), _("Type"),
_("Group As"), _("Group As"),
_("Source"), _("Source"),
@ -467,14 +468,14 @@ def name_table(obj, user, act, url=None, *args):
links = [] links = []
for name in obj.name_set.all().order_by("order"): for name in obj.name_set.all().order_by("order"):
obj_type = ContentType.objects.get_for_model(name) obj_type = ContentType.objects.get_for_model(name)
citationq = dji.CitationRef.filter(object_type=obj_type, citationq = db.dji.CitationRef.filter(object_type=obj_type,
object_id=name.id).count() > 0 object_id=name.id).count() > 0
note_refs = dji.NoteRef.filter(object_type=obj_type, note_refs = db.dji.NoteRef.filter(object_type=obj_type,
object_id=name.id) object_id=name.id)
note = "" note = ""
if note_refs.count() > 0: if note_refs.count() > 0:
try: try:
note = dji.Note.get(id=note_refs[0].object_id).text[:50] note = db.dji.Note.get(id=note_refs[0].object_id).text[:50]
except: except:
note = None note = None
table.row(make_name(name, user), table.row(make_name(name, user),
@ -482,7 +483,7 @@ def name_table(obj, user, act, url=None, *args):
name.group_as, name.group_as,
["No", "Yes"][citationq], ["No", "Yes"][citationq],
note) note)
links.append(('URL', links.append(('URL',
# url is "/person/%s/name" # url is "/person/%s/name"
(url % name.person.handle) + ("/%s" % name.order))) (url % name.person.handle) + ("/%s" % name.order)))
has_data = True has_data = True
@ -535,14 +536,14 @@ def citation_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-sources" cssid = "tab-sources"
table = Table("citation_table") table = Table("citation_table")
table.columns("", table.columns("",
_("ID"), _("ID"),
_("Confidence"), _("Confidence"),
_("Page")) _("Page"))
table.column_widths = [11, 10, 49, 30] table.column_widths = [11, 10, 49, 30]
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
citation_refs = dji.CitationRef.filter(object_type=obj_type, citation_refs = db.dji.CitationRef.filter(object_type=obj_type,
object_id=obj.id).order_by("order") object_id=obj.id).order_by("order")
links = [] links = []
count = 1 count = 1
@ -603,7 +604,7 @@ def repository_table(obj, user, act, url=None, *args):
retval += """</div>""" retval += """</div>"""
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
refs = dji.RepositoryRef.filter(object_type=obj_type, refs = db.dji.RepositoryRef.filter(object_type=obj_type,
object_id=obj.id) object_id=obj.id)
count = 1 count = 1
for repo_ref in refs: for repo_ref in refs:
@ -612,7 +613,7 @@ def repository_table(obj, user, act, url=None, *args):
Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "", Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
repository.gramps_id, repository.gramps_id,
repository.name, repository.name,
repo_ref.call_number, repo_ref.call_number,
str(repository.repository_type), str(repository.repository_type),
) )
has_data = True has_data = True
@ -645,7 +646,7 @@ def note_table(obj, user, act, url=None, *args):
table.column_widths = [11, 10, 20, 59] table.column_widths = [11, 10, 20, 59]
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
note_refs = dji.NoteRef.filter(object_type=obj_type, note_refs = db.dji.NoteRef.filter(object_type=obj_type,
object_id=obj.id).order_by("order") object_id=obj.id).order_by("order")
links = [] links = []
count = 1 count = 1
@ -690,7 +691,7 @@ def data_table(obj, user, act, url=None, *args):
table = Table("data_table") table = Table("data_table")
table.columns( table.columns(
"", "",
_("Type"), _("Type"),
_("Value"), _("Value"),
) )
table.column_widths = [11, 39, 50] table.column_widths = [11, 39, 50]
@ -739,12 +740,12 @@ def attribute_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-attributes" cssid = "tab-attributes"
table = Table("attribute_table") table = Table("attribute_table")
table.columns(_("Type"), table.columns(_("Type"),
_("Value"), _("Value"),
) )
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
attributes = dji.Attribute.filter(object_type=obj_type, attributes = db.dji.Attribute.filter(object_type=obj_type,
object_id=obj.id) object_id=obj.id)
for attribute in attributes: for attribute in attributes:
table.row(attribute.attribute_type.name, table.row(attribute.attribute_type.name,
@ -766,7 +767,7 @@ def address_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-addresses" cssid = "tab-addresses"
table = Table("address_table") table = Table("address_table")
table.columns(_("Date"), table.columns(_("Date"),
_("Address"), _("Address"),
_("City"), _("City"),
_("State"), _("State"),
@ -797,13 +798,13 @@ def media_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-media" cssid = "tab-media"
table = Table("media_table") table = Table("media_table")
table.columns(_("Description"), table.columns(_("Description"),
_("Type"), _("Type"),
_("Path/Filename"), _("Path/Filename"),
) )
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj) obj_type = ContentType.objects.get_for_model(obj)
media_refs = dji.MediaRef.filter(object_type=obj_type, media_refs = db.dji.MediaRef.filter(object_type=obj_type,
object_id=obj.id) object_id=obj.id)
for media_ref in media_refs: for media_ref in media_refs:
media = table.db.get_object_from_handle( media = table.db.get_object_from_handle(
@ -833,7 +834,7 @@ def internet_table(obj, user, act, url=None, *args):
_("Path"), _("Path"),
_("Description")) _("Description"))
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
urls = dji.Url.filter(person=obj) urls = db.dji.Url.filter(person=obj)
for url_obj in urls: for url_obj in urls:
table.row(str(url_obj.url_type), table.row(str(url_obj.url_type),
url_obj.path, url_obj.path,
@ -855,7 +856,7 @@ def association_table(obj, user, act, url=None, *args):
has_data = False has_data = False
cssid = "tab-associations" cssid = "tab-associations"
table = Table("association_table") table = Table("association_table")
table.columns(_("Name"), table.columns(_("Name"),
_("ID"), _("ID"),
_("Association")) _("Association"))
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""" retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
@ -872,11 +873,11 @@ def association_table(obj, user, act, url=None, *args):
associations = person.get_person_ref_list() associations = person.get_person_ref_list()
for association in associations: # PersonRef for association in associations: # PersonRef
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "", table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
association.ref_object.get_primary_name(), association.ref_object.get_primary_name(),
association.ref_object.gramps_id, association.ref_object.gramps_id,
association.description, association.description,
) )
links.append(('URL', "/person/%s/association/%d" % (obj.handle, count))) links.append(('URL', "/person/%s/association/%d" % (obj.handle, count)))
has_data = True has_data = True
count += 1 count += 1
table.links(links) table.links(links)
@ -893,17 +894,17 @@ def association_table(obj, user, act, url=None, *args):
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def location_table(obj, user, act, url=None, *args): def location_table(obj, user, act, url=None, *args):
# obj is Place or Address # obj is Place or Address
retval = "" retval = ""
has_data = False has_data = False
cssid = "tab-alternatelocations" cssid = "tab-alternatelocations"
table = Table("location_table") table = Table("location_table")
table.columns(_("Street"), table.columns(_("Street"),
_("Locality"), _("Locality"),
_("City"), _("City"),
_("State"), _("State"),
_("Country")) _("Country"))
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
# FIXME: location confusion! # FIXME: location confusion!
# The single Location on the Location Tab is here too? # The single Location on the Location Tab is here too?
@ -918,22 +919,22 @@ def location_table(obj, user, act, url=None, *args):
location.country) location.country)
has_data = True has_data = True
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""" retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view": if user.is_superuser and url and act == "view":
retval += make_button(_("+Add Address"), (url % args)) retval += make_button(_("+Add Address"), (url % args))
else: else:
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
retval += """</div>""" retval += """</div>"""
retval += table.get_html() retval += table.get_html()
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def lds_table(obj, user, act, url=None, *args): def lds_table(obj, user, act, url=None, *args):
retval = "" retval = ""
has_data = False has_data = False
cssid = "tab-lds" cssid = "tab-lds"
table = Table("lds_table") table = Table("lds_table")
table.columns(_("Type"), table.columns(_("Type"),
_("Date"), _("Date"),
_("Status"), _("Status"),
_("Temple"), _("Temple"),
@ -969,14 +970,14 @@ def person_reference_table(obj, user, act):
table1.columns( table1.columns(
"As Spouse", "As Spouse",
_("ID"), _("ID"),
_("Reference"), _("Reference"),
) )
table1.column_widths = [11, 10, 79] table1.column_widths = [11, 10, 79]
table2 = Table("person_reference_table", style="background-color: #f4f0ec;") table2 = Table("person_reference_table", style="background-color: #f4f0ec;")
table2.columns( table2.columns(
"As Child", "As Child",
_("ID"), _("ID"),
_("Reference"), _("Reference"),
) )
table2.column_widths = [11, 10, 79] table2.column_widths = [11, 10, 79]
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
@ -1023,25 +1024,25 @@ def person_reference_table(obj, user, act):
count += 1 count += 1
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""" retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
retval += make_image_button2("add spouse to new family", retval += make_image_button2("add spouse to new family",
_("Add as Spouse to New Family"), _("Add as Spouse to New Family"),
"/family/add/spouse/%s" % obj.handle) "/family/add/spouse/%s" % obj.handle)
retval += make_image_button2("add spouse to existing family", retval += make_image_button2("add spouse to existing family",
_("Add as Spouse to Existing Family"), _("Add as Spouse to Existing Family"),
"/family/share/spouse/%s" % obj.handle) "/family/share/spouse/%s" % obj.handle)
retval += "&nbsp;" retval += "&nbsp;"
retval += make_image_button2("add child to new family", retval += make_image_button2("add child to new family",
_("Add as Child to New Family"), _("Add as Child to New Family"),
"/family/add/child/%s" % obj.handle) "/family/add/child/%s" % obj.handle)
retval += make_image_button2("add child to existing family", retval += make_image_button2("add child to existing family",
_("Add as Child to Existing Family"), _("Add as Child to Existing Family"),
"/family/share/child/%s" % obj.handle) "/family/share/child/%s" % obj.handle)
retval += """</div>""" retval += """</div>"""
retval += """<div style="overflow: auto; height:%spx;">""" % TAB_HEIGHT retval += """<div style="overflow: auto; height:%spx;">""" % TAB_HEIGHT
retval += text1 + text2 + "</div>" retval += text1 + text2 + "</div>"
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def note_reference_table(obj, user, act): def note_reference_table(obj, user, act):
retval = "" retval = ""
@ -1050,7 +1051,7 @@ def note_reference_table(obj, user, act):
table = Table("note_reference_table") table = Table("note_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
for reference in models.NoteRef.objects.filter(ref_object=obj): for reference in models.NoteRef.objects.filter(ref_object=obj):
@ -1065,7 +1066,7 @@ def note_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def event_reference_table(obj, user, act): def event_reference_table(obj, user, act):
retval = "" retval = ""
@ -1074,7 +1075,7 @@ def event_reference_table(obj, user, act):
table = Table("event_reference_table") table = Table("event_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
for reference in models.EventRef.objects.filter(ref_object=obj): for reference in models.EventRef.objects.filter(ref_object=obj):
@ -1093,7 +1094,7 @@ def event_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def repository_reference_table(obj, user, act): def repository_reference_table(obj, user, act):
retval = "" retval = ""
@ -1102,7 +1103,7 @@ def repository_reference_table(obj, user, act):
table = Table("repository_reference_table") table = Table("repository_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
for reference in models.RepositoryRef.objects.filter(ref_object=obj): for reference in models.RepositoryRef.objects.filter(ref_object=obj):
@ -1117,7 +1118,7 @@ def repository_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def citation_reference_table(obj, user, act): def citation_reference_table(obj, user, act):
retval = "" retval = ""
@ -1126,7 +1127,7 @@ def citation_reference_table(obj, user, act):
table = Table("citation_reference_table") table = Table("citation_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
# _("ID") # _("ID")
) )
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
@ -1141,7 +1142,7 @@ def citation_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def source_reference_table(obj, user, act): def source_reference_table(obj, user, act):
retval = "" retval = ""
@ -1150,7 +1151,7 @@ def source_reference_table(obj, user, act):
table = Table("source_reference_table") table = Table("source_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
for item in obj.citation_set.all(): for item in obj.citation_set.all():
@ -1163,7 +1164,7 @@ def source_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def media_reference_table(obj, user, act): def media_reference_table(obj, user, act):
retval = "" retval = ""
@ -1172,7 +1173,7 @@ def media_reference_table(obj, user, act):
table = Table("media_reference_table") table = Table("media_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
for reference in models.MediaRef.objects.filter(ref_object=obj): for reference in models.MediaRef.objects.filter(ref_object=obj):
@ -1187,7 +1188,7 @@ def media_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def place_reference_table(obj, user, act): def place_reference_table(obj, user, act):
retval = "" retval = ""
@ -1210,7 +1211,7 @@ def place_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
def tag_reference_table(obj, user, act): def tag_reference_table(obj, user, act):
retval = "" retval = ""
@ -1219,7 +1220,7 @@ def tag_reference_table(obj, user, act):
table = Table("tag_reference_table") table = Table("tag_reference_table")
table.columns( table.columns(
_("Type"), _("Type"),
_("Reference"), _("Reference"),
_("ID")) _("ID"))
if (user.is_authenticated() or obj.public) and act != "add": if (user.is_authenticated() or obj.public) and act != "add":
querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set] querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set]
@ -1234,7 +1235,7 @@ def tag_reference_table(obj, user, act):
retval += nbsp("") # to keep tabs same height retval += nbsp("") # to keep tabs same height
if has_data: if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval return retval
class Link(object): class Link(object):
def __init__(self, string, url=None): def __init__(self, string, url=None):
@ -1260,11 +1261,11 @@ def children_table(obj, user, act, url=None, *args):
_("Maternal"), _("Maternal"),
_("Birth Date"), _("Birth Date"),
) )
table.column_widths = [11, 5, 10, 29, 8, 8, 10, 19] table.column_widths = [11, 5, 10, 29, 8, 8, 10, 19]
family = obj family = obj
obj_type = ContentType.objects.get_for_model(family) obj_type = ContentType.objects.get_for_model(family)
childrefs = dji.ChildRef.filter(object_id=family.id, childrefs = db.dji.ChildRef.filter(object_id=family.id,
object_type=obj_type).order_by("order") object_type=obj_type).order_by("order")
links = [] links = []
count = 1 count = 1
@ -1272,7 +1273,7 @@ def children_table(obj, user, act, url=None, *args):
child = childref.ref_object child = childref.ref_object
if user.is_authenticated() or obj.public: if user.is_authenticated() or obj.public:
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "", table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
str(count), str(count),
"[%s]" % child.gramps_id, "[%s]" % child.gramps_id,
render_name(child, user), render_name(child, user),
child.gender_type, child.gender_type,
@ -1285,7 +1286,7 @@ def children_table(obj, user, act, url=None, *args):
count += 1 count += 1
else: else:
table.row("", table.row("",
str(count), str(count),
"[%s]" % child.gramps_id, "[%s]" % child.gramps_id,
render_name(child, user) if not child.private else "[Private]", render_name(child, user) if not child.private else "[Private]",
child.gender_type if not child.private else "[Private]", child.gender_type if not child.private else "[Private]",
@ -1331,7 +1332,7 @@ def get_title(place):
return "" return ""
def display_date(obj): def display_date(obj):
date_tuple = dji.get_date(obj) date_tuple = db.dji.get_date(obj)
if date_tuple: if date_tuple:
gdate = GDate() gdate = GDate()
gdate.unserialize(date_tuple) gdate.unserialize(date_tuple)
@ -1341,7 +1342,7 @@ def display_date(obj):
def media_link(handle, user, act): def media_link(handle, user, act):
retval = """<a href="%s"><img src="%s" /></a>""" % ( retval = """<a href="%s"><img src="%s" /></a>""" % (
"/media/%s/full" % handle, "/media/%s/full" % handle,
"/media/%s/thumbnail" % handle) "/media/%s/thumbnail" % handle)
return retval return retval
@ -1375,7 +1376,7 @@ def render(formfield, user, act, id=None, url=None, *args):
except: except:
# name, "prefix" # name, "prefix"
try: try:
retval = str(formfield.form.data[fieldname]) retval = str(formfield.form.data[fieldname])
except: except:
retval = "[None]" retval = "[None]"
else: # show as widget else: # show as widget
@ -1409,7 +1410,7 @@ def render_name(name, user, act=None):
surname = name.model.surname_set.get(primary=True) surname = name.model.surname_set.get(primary=True)
except: except:
surname = "[No primary surname]" surname = "[No primary surname]"
return "%s, %s" % (surname, return "%s, %s" % (surname,
name.model.first_name) name.model.first_name)
elif isinstance(name, Person): # name is a Person elif isinstance(name, Person): # name is a Person
person = name person = name
@ -1446,7 +1447,7 @@ def date_as_text(obj, user):
""" """
if user.is_authenticated() or (obj and obj.public): if user.is_authenticated() or (obj and obj.public):
if obj: if obj:
date_tuple = dji.get_date(obj) date_tuple = db.dji.get_date(obj)
if date_tuple: if date_tuple:
gdate = GDate().unserialize(date_tuple) gdate = GDate().unserialize(date_tuple)
return dd(gdate) return dd(gdate)
@ -1455,7 +1456,7 @@ def date_as_text(obj, user):
return "" return ""
def person_get_event(person, event_type=None): def person_get_event(person, event_type=None):
event_ref_list = dji.get_event_ref_list(person) event_ref_list = db.dji.get_event_ref_list(person)
if event_type: if event_type:
index = libdjango.lookup_role_index(event_type, event_ref_list) index = libdjango.lookup_role_index(event_type, event_ref_list)
if index >= 0: if index >= 0:
@ -1470,8 +1471,8 @@ def person_get_event(person, event_type=None):
else: else:
return "" return ""
else: else:
retval = [[obj.ref_object for obj in retval = [[obj.ref_object for obj in
models.EventRef.objects.filter(ref_object__handle=event_handle[3])] models.EventRef.objects.filter(ref_object__handle=event_handle[3])]
for event_handle in event_ref_list] for event_handle in event_ref_list]
return [j for i in retval for j in i] return [j for i in retval for j in i]
@ -1485,7 +1486,7 @@ def update_last_changed(obj, user):
register_plugins(GUser()) register_plugins(GUser())
# works after registering plugins: # works after registering plugins:
from gramps.plugins.docgen.htmldoc import HtmlDoc from gramps.plugins.docgen.htmldoc import HtmlDoc
from gramps.plugins.lib.libhtmlbackend import HtmlBackend, DocBackend, process_spaces from gramps.plugins.lib.libhtmlbackend import HtmlBackend, DocBackend, process_spaces
from gramps.plugins.lib.libhtml import Html from gramps.plugins.lib.libhtml import Html
@ -1537,10 +1538,10 @@ class StyledNoteFormatter(object):
if obj: if obj:
handle = obj.handle handle = obj.handle
else: else:
raise AttributeError("gramps_id '%s' not found in '%s'" % raise AttributeError("gramps_id '%s' not found in '%s'" %
(handle, obj_class)) (handle, obj_class))
else: else:
raise AttributeError("invalid gramps_id lookup " + raise AttributeError("invalid gramps_id lookup " +
"in table name '%s'" % obj_class) "in table name '%s'" % obj_class)
# handle, ppl # handle, ppl
return "/%s/%s" % (obj_class.lower(), handle) return "/%s/%s" % (obj_class.lower(), handle)
@ -1696,7 +1697,7 @@ def make_log(obj, log_type, last_changed_by, reason, cache):
last_changed_by=last_changed_by, last_changed_by=last_changed_by,
cache=cache) cache=cache)
log.save() log.save()
def person_get_birth_date(person): def person_get_birth_date(person):
#db = DbDjango() #db = DbDjango()
#event = get_birth_or_fallback(db, db.get_person_from_handle(person.handle)) #event = get_birth_or_fallback(db, db.get_person_from_handle(person.handle))
@ -1710,4 +1711,3 @@ def person_get_death_date(person):
#if event: #if event:
# return event.date # return event.date
return None return None