Renamed variables action -> act to avoid conflict with function
svn: r20039
This commit is contained in:
parent
9295c61005
commit
d944dc918f
@ -34,9 +34,9 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_citation(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_citation(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Citation")
|
||||
context["tviews"] = _("Citations")
|
||||
@ -44,12 +44,12 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
|
||||
view_template = "view_citation_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick citation",
|
||||
Citation,
|
||||
@ -58,7 +58,7 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick citation",
|
||||
Citation,
|
||||
@ -77,21 +77,21 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
source = Source(gramps_id=dji.get_next_id(Source, "S"))
|
||||
sourceform = SourceForm(instance=source)
|
||||
sourceform.model = source
|
||||
citation = Citation(source=source, gramps_id=dji.get_next_id(Citation, "C"))
|
||||
citationform = CitationForm(instance=citation)
|
||||
citationform.model = citation
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
citation = Citation.objects.get(handle=handle)
|
||||
citationform = CitationForm(instance=citation)
|
||||
citationform.model = citation
|
||||
source = citation.source
|
||||
sourceform = SourceForm(instance=source)
|
||||
sourceform.model = source
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
citation = Citation.objects.get(handle=handle)
|
||||
citationform = CitationForm(request.POST, instance=citation)
|
||||
citationform.model = citation
|
||||
@ -99,10 +99,10 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
|
||||
update_last_changed(citation, request.user.username)
|
||||
citation = citationform.save()
|
||||
dji.rebuild_cache(citation)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
source = Source(handle=create_id())
|
||||
sourceform = SourceForm(request.POST, instance=source)
|
||||
sourceform.model = source
|
||||
@ -124,21 +124,21 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
|
||||
dji.add_citation_ref(obj, citation.handle)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-citations" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
citation = Citation.objects.get(handle=handle)
|
||||
citation.delete()
|
||||
return redirect("/citation/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["citationform"] = citationform
|
||||
context["sourceform"] = sourceform
|
||||
context["object"] = citation
|
||||
context["citation"] = citation
|
||||
context["source"] = source
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -39,9 +39,9 @@ db = DbDjango()
|
||||
dd = displayer.display
|
||||
dp = parser.parse
|
||||
|
||||
def process_event(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_event(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Event")
|
||||
context["tviews"] = _("Events")
|
||||
@ -49,12 +49,12 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
view_template = "view_event_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick event",
|
||||
Event,
|
||||
@ -63,7 +63,7 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick event",
|
||||
Event,
|
||||
@ -82,11 +82,11 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
event = Event(gramps_id=dji.get_next_id(Event, "E"))
|
||||
eventform = EventForm(instance=event)
|
||||
eventform.model = event
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
event = Event.objects.get(handle=handle)
|
||||
genlibevent = db.get_event_from_handle(handle)
|
||||
if genlibevent:
|
||||
@ -94,7 +94,7 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
event.text = dd(date)
|
||||
eventform = EventForm(instance=event)
|
||||
eventform.model = event
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
event = Event.objects.get(handle=handle)
|
||||
eventform = EventForm(request.POST, instance=event)
|
||||
eventform.model = event
|
||||
@ -102,10 +102,10 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
update_last_changed(event, request.user.username)
|
||||
event = eventform.save()
|
||||
dji.rebuild_cache(event)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
event = Event(handle=create_id())
|
||||
eventform = EventForm(request.POST, instance=event)
|
||||
eventform.model = event
|
||||
@ -120,19 +120,19 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
|
||||
dji.add_event_ref_default(obj, event)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-events" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
event = Event.objects.get(handle=handle)
|
||||
event.delete()
|
||||
return redirect("/event/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["eventform"] = eventform
|
||||
context["object"] = event
|
||||
context["event"] = event
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -35,31 +35,31 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_family(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_family(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Family")
|
||||
context["tviews"] = _("Familes")
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete
|
||||
if action == "add":
|
||||
if act == "add":
|
||||
family = Family(
|
||||
gramps_id=dji.get_next_id(Family, "F"),
|
||||
family_rel_type=FamilyRelType.objects.get(
|
||||
val=FamilyRelType._DEFAULT[0]))
|
||||
familyform = FamilyForm(instance=family)
|
||||
familyform.model = family
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
family = Family.objects.get(handle=handle)
|
||||
familyform = FamilyForm(instance=family)
|
||||
familyform.model = family
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
family = Family.objects.get(handle=handle)
|
||||
familyform = FamilyForm(request.POST, instance=family)
|
||||
familyform.model = family
|
||||
@ -75,10 +75,10 @@ def process_family(request, context, handle, action, add_to=None): # view, edit,
|
||||
if family not in family.father.families.all():
|
||||
family.father.families.add(family)
|
||||
dji.rebuild_cache(family)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
family = Family(family_rel_type=FamilyRelType.objects.get(
|
||||
val=FamilyRelType._DEFAULT[0]),
|
||||
handle=create_id())
|
||||
@ -103,20 +103,20 @@ def process_family(request, context, handle, action, add_to=None): # view, edit,
|
||||
dji.add_family_ref(obj, family.handle)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
family = Family.objects.get(handle=handle)
|
||||
family.delete()
|
||||
return redirect("/family/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["familyform"] = familyform
|
||||
context["object"] = family
|
||||
context["family"] = family
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
view_template = "view_family_detail.html"
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -47,9 +47,9 @@ def pb2image(pb):
|
||||
width, height = pb.get_width(), pb.get_height()
|
||||
return Image.fromstring("RGB", (width,height), pb.get_pixels())
|
||||
|
||||
def process_media(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_media(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Media")
|
||||
context["tviews"] = _("Media")
|
||||
@ -57,12 +57,12 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
view_template = "view_media_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick media",
|
||||
Media,
|
||||
@ -71,7 +71,7 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick media",
|
||||
Media,
|
||||
@ -90,7 +90,7 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "full":
|
||||
elif act == "full":
|
||||
media = Media.objects.get(handle=handle)
|
||||
media_type, media_ext = media.mime.split("/", 1)
|
||||
# FIXME: This should be absolute:
|
||||
@ -107,7 +107,7 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
image = png.Image(pixels, meta)
|
||||
image.save(response)
|
||||
return response
|
||||
elif action == "thumbnail":
|
||||
elif act == "thumbnail":
|
||||
media = Media.objects.get(handle=handle)
|
||||
media_type, media_ext = media.mime.split("/", 1)
|
||||
# FIXME: This should be absolute:
|
||||
@ -147,15 +147,15 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
image.save("%s/thumbnail/%s" % (folder, media.path), media_ext)
|
||||
image.save(response, media_ext.upper())
|
||||
return response
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
media = Media(gramps_id=dji.get_next_id(Media, "M"))
|
||||
mediaform = MediaForm(instance=media)
|
||||
mediaform.model = media
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
media = Media.objects.get(handle=handle)
|
||||
mediaform = MediaForm(instance=media)
|
||||
mediaform.model = media
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
media = Media.objects.get(handle=handle)
|
||||
mediaform = MediaForm(request.POST, instance=media)
|
||||
mediaform.model = media
|
||||
@ -163,10 +163,10 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
update_last_changed(media, request.user.username)
|
||||
media = mediaform.save()
|
||||
dji.rebuild_cache(media)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
media = Media(handle=create_id())
|
||||
mediaform = MediaForm(request.POST, instance=media)
|
||||
mediaform.model = media
|
||||
@ -182,19 +182,19 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
|
||||
return redirect("/%s/%s#tab-gallery" % (item, handle))
|
||||
else:
|
||||
dji.rebuild_cache(media)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
media = Media.objects.get(handle=handle)
|
||||
media.delete()
|
||||
return redirect("/media/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["mediaform"] = mediaform
|
||||
context["object"] = media
|
||||
context["media"] = media
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -37,9 +37,9 @@ dji = DjangoInterface()
|
||||
db = DbDjango()
|
||||
snf = StyledNoteFormatter(db)
|
||||
|
||||
def process_note(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_note(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Note")
|
||||
context["tviews"] = _("Notes")
|
||||
@ -47,12 +47,12 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
|
||||
view_template = "view_note_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick note",
|
||||
Note,
|
||||
@ -61,7 +61,7 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick note",
|
||||
Note,
|
||||
@ -80,18 +80,18 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
note = Note(gramps_id=dji.get_next_id(Note, "N"))
|
||||
notetext = ""
|
||||
noteform = NoteForm(instance=note, initial={"notetext": notetext})
|
||||
noteform.model = note
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
note = Note.objects.get(handle=handle)
|
||||
genlibnote = db.get_note_from_handle(note.handle)
|
||||
notetext = snf.format(genlibnote)
|
||||
noteform = NoteForm(instance=note, initial={"notetext": notetext})
|
||||
noteform.model = note
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
note = Note.objects.get(handle=handle)
|
||||
notetext = ""
|
||||
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
|
||||
@ -104,11 +104,11 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
|
||||
dji.save_note_markup(note, notedata[1])
|
||||
dji.rebuild_cache(note)
|
||||
notetext = noteform.data["notetext"]
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
notetext = noteform.data["notetext"]
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
note = Note(handle=create_id())
|
||||
notetext = ""
|
||||
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
|
||||
@ -128,22 +128,22 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-notes" % (item, handle))
|
||||
notetext = noteform.data["notetext"]
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
notetext = noteform.data["notetext"]
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
# FIXME: delete markup too for this note
|
||||
note = Note.objects.get(handle=handle)
|
||||
note.delete()
|
||||
return redirect("/note/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["noteform"] = noteform
|
||||
context["object"] = note
|
||||
context["notetext"] = notetext
|
||||
context["note"] = note
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -113,25 +113,25 @@ def check_preferred(request, name, person):
|
||||
if not ok:
|
||||
name.preferred = True
|
||||
|
||||
def process_surname(request, handle, order, sorder, action="view"):
|
||||
def process_surname(request, handle, order, sorder, act="view"):
|
||||
#import pdb; pdb.set_trace()
|
||||
# /sdjhgsdjhdhgsd/name/1/surname/1 (view)
|
||||
# /sdjhgsdjhdhgsd/name/1/surname/add
|
||||
# /sdjhgsdjhdhgsd/name/1/surname/2/[edit|view|add|delete]
|
||||
|
||||
if sorder == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
person = Person.objects.get(handle=handle)
|
||||
name = person.name_set.get(order=order)
|
||||
|
||||
if action in ["view", "edit"]:
|
||||
if act in ["view", "edit"]:
|
||||
surname = name.surname_set.get(order=sorder)
|
||||
if action == "edit":
|
||||
if act == "edit":
|
||||
surname.prefix = make_empty(True, surname.prefix, " prefix ")
|
||||
elif action in ["delete"]:
|
||||
elif act in ["delete"]:
|
||||
surnames = name.surname_set.all().order_by("order")
|
||||
if len(surnames) > 1:
|
||||
neworder = 1
|
||||
@ -148,11 +148,11 @@ def process_surname(request, handle, order, sorder, action="view"):
|
||||
request.user.message_set.create(message="You can't delete the only surname")
|
||||
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
|
||||
build_search(request)))
|
||||
elif action in ["add"]:
|
||||
elif act in ["add"]:
|
||||
surname = Surname(name=name, primary=False,
|
||||
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
|
||||
surname.prefix = make_empty(True, surname.prefix, " prefix ")
|
||||
elif action == "create":
|
||||
elif act == "create":
|
||||
surnames = name.surname_set.all().order_by("order")
|
||||
sorder = 1
|
||||
for surname in surnames:
|
||||
@ -171,9 +171,9 @@ def process_surname(request, handle, order, sorder, action="view"):
|
||||
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
|
||||
(person.handle, name.order, sorder,
|
||||
build_search(request)))
|
||||
action = "add"
|
||||
act = "add"
|
||||
surname.prefix = make_empty(True, surname.prefix, " prefix ")
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
surname = name.surname_set.get(order=sorder)
|
||||
sf = SurnameForm(request.POST, instance=surname)
|
||||
sf.model = surname
|
||||
@ -186,17 +186,17 @@ def process_surname(request, handle, order, sorder, action="view"):
|
||||
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
|
||||
(person.handle, name.order, sorder,
|
||||
build_search(request)))
|
||||
action = "edit"
|
||||
act = "edit"
|
||||
surname.prefix = make_empty(True, surname.prefix, " prefix ")
|
||||
# else, edit again
|
||||
else:
|
||||
raise Exception("unknown action: '%s'" % action)
|
||||
raise Exception("unknown act: '%s'" % act)
|
||||
|
||||
sf = SurnameForm(instance=surname)
|
||||
sf.model = surname
|
||||
|
||||
context = RequestContext(request)
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
context["tview"] = _("Surname")
|
||||
context["handle"] = handle
|
||||
context["id"] = id
|
||||
@ -208,19 +208,19 @@ def process_surname(request, handle, order, sorder, action="view"):
|
||||
view_template = 'view_surname_detail.html'
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
def process_name(request, handle, order, action="view"):
|
||||
def process_name(request, handle, order, act="view"):
|
||||
if order == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
### Process action:
|
||||
if action in "view":
|
||||
act = request.POST.get("action")
|
||||
### Process act:
|
||||
if act in "view":
|
||||
pf, nf, sf, person = get_person_forms(handle, order=order)
|
||||
name = nf.model
|
||||
elif action == "edit":
|
||||
elif act == "edit":
|
||||
pf, nf, sf, person = get_person_forms(handle, order=order)
|
||||
name = nf.model
|
||||
elif action == "delete":
|
||||
elif act == "delete":
|
||||
person = Person.objects.get(handle=handle)
|
||||
name = person.name_set.filter(order=order)
|
||||
names = person.name_set.all()
|
||||
@ -231,7 +231,7 @@ def process_name(request, handle, order, action="view"):
|
||||
request.user.message_set.create(message = "Can't delete only name.")
|
||||
return redirect("/person/%s%s#tab-names" % (person.handle,
|
||||
build_search(request)))
|
||||
elif action == "add": # add name
|
||||
elif act == "add": # add name
|
||||
person = Person.objects.get(handle=handle)
|
||||
name = Name(person=person,
|
||||
preferred=False,
|
||||
@ -246,7 +246,7 @@ def process_name(request, handle, order, action="view"):
|
||||
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
|
||||
sf = SurnameForm(request.POST, instance=surname)
|
||||
sf.model = surname
|
||||
elif action == "create":
|
||||
elif act == "create":
|
||||
# make new data
|
||||
person = Person.objects.get(handle=handle)
|
||||
name = Name(preferred=False)
|
||||
@ -285,8 +285,8 @@ def process_name(request, handle, order, action="view"):
|
||||
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
|
||||
build_search(request)))
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "save":
|
||||
act = "add"
|
||||
elif act == "save":
|
||||
# look up old data:
|
||||
person = Person.objects.get(handle=handle)
|
||||
oldname = person.name_set.get(order=order)
|
||||
@ -321,9 +321,9 @@ def process_name(request, handle, order, action="view"):
|
||||
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
|
||||
build_search(request)))
|
||||
else:
|
||||
action = "edit"
|
||||
act = "edit"
|
||||
context = RequestContext(request)
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
context["tview"] = _('Name')
|
||||
context["tviews"] = _('Names')
|
||||
context["view"] = 'name'
|
||||
@ -338,15 +338,15 @@ def process_name(request, handle, order, action="view"):
|
||||
view_template = "view_name_detail.html"
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
def process_person(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_person(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Person")
|
||||
context["tviews"] = _("People")
|
||||
logform = None
|
||||
if request.user.is_authenticated():
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick a person",
|
||||
Person,
|
||||
@ -356,7 +356,7 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to # ("Family", handle)
|
||||
pickform = PickForm("Pick a person",
|
||||
Person,
|
||||
@ -378,18 +378,18 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = "family"
|
||||
return render_to_response("pick.html", context)
|
||||
elif action in ["edit", "view"]:
|
||||
elif act in ["edit", "view"]:
|
||||
pf, nf, sf, person = get_person_forms(handle, empty=False)
|
||||
if action == "edit":
|
||||
if act == "edit":
|
||||
logform = LogForm()
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
|
||||
logform = LogForm()
|
||||
elif action == "delete":
|
||||
elif act == "delete":
|
||||
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
|
||||
person.delete()
|
||||
return redirect("/person/%s" % build_search(request))
|
||||
elif action in ["save", "create"]: # could be create a new person
|
||||
elif act in ["save", "create"]: # could be create a new person
|
||||
# look up old data, if any:
|
||||
logform = LogForm(request.POST)
|
||||
if handle:
|
||||
@ -434,7 +434,7 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
|
||||
surname.primary = True # FIXME: why is this False? Remove from form?
|
||||
surname.save()
|
||||
# FIXME: put this in correct place to get correct cache, before changes:
|
||||
make_log(person, action, request.user.username, logform.cleaned_data["reason"], person.cache)
|
||||
make_log(person, act, request.user.username, logform.cleaned_data["reason"], person.cache)
|
||||
if add_to: # Adding a child to the family
|
||||
item, handle = add_to # ("Family", handle)
|
||||
model = dji.get_model(item) # what model?
|
||||
@ -449,9 +449,9 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
|
||||
else:
|
||||
# need to edit again
|
||||
if handle:
|
||||
action = "edit"
|
||||
act = "edit"
|
||||
else:
|
||||
action = "add"
|
||||
act = "add"
|
||||
else: # error?
|
||||
raise Http404(_("Requested %s does not exist.") % "person")
|
||||
else: # not authenticated
|
||||
@ -464,7 +464,7 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
|
||||
raise Http404(_("Requested %s does not exist.") % "person")
|
||||
pf, nf, sf, person = get_person_forms(handle, protect=True)
|
||||
# END NON-AUTHENTICATED ACCESS
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
context["view"] = "person"
|
||||
context["tview"] = _("Person")
|
||||
context["tviews"] = _("People")
|
||||
|
@ -34,9 +34,9 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_place(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_place(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Place")
|
||||
context["tviews"] = _("Places")
|
||||
@ -44,20 +44,20 @@ def process_place(request, context, handle, action, add_to=None): # view, edit,
|
||||
view_template = "view_place_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete
|
||||
if action == "add":
|
||||
if act == "add":
|
||||
place = Place(gramps_id=dji.get_next_id(Place, "P"))
|
||||
placeform = PlaceForm(instance=place)
|
||||
placeform.model = place
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
place = Place.objects.get(handle=handle)
|
||||
placeform = PlaceForm(instance=place)
|
||||
placeform.model = place
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
place = Place.objects.get(handle=handle)
|
||||
placeform = PlaceForm(request.POST, instance=place)
|
||||
placeform.model = place
|
||||
@ -65,10 +65,10 @@ def process_place(request, context, handle, action, add_to=None): # view, edit,
|
||||
update_last_changed(place, request.user.username)
|
||||
place = placeform.save()
|
||||
dji.rebuild_cache(place)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
place = Place(handle=create_id())
|
||||
placeform = PlaceForm(request.POST, instance=place)
|
||||
placeform.model = place
|
||||
@ -83,19 +83,19 @@ def process_place(request, context, handle, action, add_to=None): # view, edit,
|
||||
dji.add_place_ref(obj, place.handle)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-places" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
place = Place.objects.get(handle=handle)
|
||||
place.delete()
|
||||
return redirect("/place/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["placeform"] = placeform
|
||||
context["object"] = place
|
||||
context["place"] = place
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -34,9 +34,9 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_repository(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_repository(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Repository")
|
||||
context["tviews"] = _("Repositories")
|
||||
@ -44,12 +44,12 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
|
||||
view_template = "view_repository_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick repository",
|
||||
Repository,
|
||||
@ -58,7 +58,7 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick repository",
|
||||
Repository,
|
||||
@ -77,15 +77,15 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
repository = Repository(gramps_id=dji.get_next_id(Repository, "R"))
|
||||
repositoryform = RepositoryForm(instance=repository)
|
||||
repositoryform.model = repository
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
repository = Repository.objects.get(handle=handle)
|
||||
repositoryform = RepositoryForm(instance=repository)
|
||||
repositoryform.model = repository
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
repository = Repository.objects.get(handle=handle)
|
||||
repositoryform = RepositoryForm(request.POST, instance=repository)
|
||||
repositoryform.model = repository
|
||||
@ -93,10 +93,10 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
|
||||
update_last_changed(repository, request.user.username)
|
||||
repository = repositoryform.save()
|
||||
dji.rebuild_cache(repository)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
repository = Repository(handle=create_id())
|
||||
repositoryform = RepositoryForm(request.POST, instance=repository)
|
||||
repositoryform.model = repository
|
||||
@ -111,20 +111,20 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
|
||||
dji.add_repository_ref_default(obj, repository)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-repositories" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
repository = Repository.objects.get(handle=handle)
|
||||
repository.delete()
|
||||
return redirect("/repository/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["repositoryform"] = repositoryform
|
||||
context["object"] = repository
|
||||
context["repository"] = repository
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
|
@ -34,9 +34,9 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_source(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_source(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Source")
|
||||
context["tviews"] = _("Sources")
|
||||
@ -44,12 +44,12 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
|
||||
view_template = "view_source_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete, share, save-share
|
||||
if action == "share":
|
||||
if act == "share":
|
||||
item, handle = add_to
|
||||
context["pickform"] = PickForm("Pick source",
|
||||
Source,
|
||||
@ -58,7 +58,7 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "save-share":
|
||||
elif act == "save-share":
|
||||
item, handle = add_to
|
||||
pickform = PickForm("Pick source",
|
||||
Source,
|
||||
@ -77,15 +77,15 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
|
||||
context["object_handle"] = handle
|
||||
context["object_type"] = item
|
||||
return render_to_response("pick.html", context)
|
||||
elif action == "add":
|
||||
elif act == "add":
|
||||
source = Source(gramps_id=dji.get_next_id(Source, "S"))
|
||||
sourceform = SourceForm(instance=source)
|
||||
sourceform.model = source
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
source = Source.objects.get(handle=handle)
|
||||
sourceform = SourceForm(instance=source)
|
||||
sourceform.model = source
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
source = Source.objects.get(handle=handle)
|
||||
sourceform = SourceForm(request.POST, instance=source)
|
||||
sourceform.model = source
|
||||
@ -93,10 +93,10 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
|
||||
update_last_changed(source, request.user.username)
|
||||
source = sourceform.save()
|
||||
dji.rebuild_cache(source)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
source = Source(handle=create_id())
|
||||
sourceform = SourceForm(request.POST, instance=source)
|
||||
sourceform.model = source
|
||||
@ -106,20 +106,20 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
|
||||
dji.rebuild_cache(source)
|
||||
if add_to:
|
||||
raise Exception("Cannot add reference")
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
source = Source.objects.get(handle=handle)
|
||||
source.delete()
|
||||
return redirect("/source/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["sourceform"] = sourceform
|
||||
context["object"] = source
|
||||
context["source"] = source
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
|
@ -34,9 +34,9 @@ from django.template import Context, RequestContext
|
||||
## Globals
|
||||
dji = DjangoInterface()
|
||||
|
||||
def process_tag(request, context, handle, action, add_to=None): # view, edit, save
|
||||
def process_tag(request, context, handle, act, add_to=None): # view, edit, save
|
||||
"""
|
||||
Process action on person. Can return a redirect.
|
||||
Process act on person. Can return a redirect.
|
||||
"""
|
||||
context["tview"] = _("Tag")
|
||||
context["tviews"] = _("Tags")
|
||||
@ -44,20 +44,20 @@ def process_tag(request, context, handle, action, add_to=None): # view, edit, sa
|
||||
view_template = "view_tag_detail.html"
|
||||
|
||||
if handle == "add":
|
||||
action = "add"
|
||||
act = "add"
|
||||
if request.POST.has_key("action"):
|
||||
action = request.POST.get("action")
|
||||
act = request.POST.get("action")
|
||||
|
||||
# Handle: edit, view, add, create, save, delete
|
||||
if action == "add":
|
||||
if act == "add":
|
||||
tag = Tag()
|
||||
tagform = TagForm(instance=tag)
|
||||
tagform.model = tag
|
||||
elif action in ["view", "edit"]:
|
||||
elif act in ["view", "edit"]:
|
||||
tag = Tag.objects.get(handle=handle)
|
||||
tagform = TagForm(instance=tag)
|
||||
tagform.model = tag
|
||||
elif action == "save":
|
||||
elif act == "save":
|
||||
tag = Tag.objects.get(handle=handle)
|
||||
tagform = TagForm(request.POST, instance=tag)
|
||||
tagform.model = tag
|
||||
@ -65,10 +65,10 @@ def process_tag(request, context, handle, action, add_to=None): # view, edit, sa
|
||||
update_last_changed(tag, request.user.username)
|
||||
tag = tagform.save()
|
||||
dji.rebuild_cache(tag)
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "edit"
|
||||
elif action == "create":
|
||||
act = "edit"
|
||||
elif act == "create":
|
||||
tag = Tag(handle=create_id())
|
||||
tagform = TagForm(request.POST, instance=tag)
|
||||
tagform.model = tag
|
||||
@ -83,19 +83,19 @@ def process_tag(request, context, handle, action, add_to=None): # view, edit, sa
|
||||
dji.add_tag_ref_default(obj, tag)
|
||||
dji.rebuild_cache(obj)
|
||||
return redirect("/%s/%s#tab-tags" % (item, handle))
|
||||
action = "view"
|
||||
act = "view"
|
||||
else:
|
||||
action = "add"
|
||||
elif action == "delete":
|
||||
act = "add"
|
||||
elif act == "delete":
|
||||
tag = Tag.objects.get(handle=handle)
|
||||
tag.delete()
|
||||
return redirect("/tag/")
|
||||
else:
|
||||
raise Exception("Unhandled action: '%s'" % action)
|
||||
raise Exception("Unhandled act: '%s'" % act)
|
||||
|
||||
context["tagform"] = tagform
|
||||
context["object"] = tag
|
||||
context["tag"] = tag
|
||||
context["action"] = action
|
||||
context["action"] = act
|
||||
|
||||
return render_to_response(view_template, context)
|
||||
|
@ -293,7 +293,7 @@ def make_button(text, url, *args):
|
||||
return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" %
|
||||
(text, url, kwargs, last))
|
||||
|
||||
def event_table(obj, user, action, url, args):
|
||||
def event_table(obj, user, act, url, args):
|
||||
retval = ""
|
||||
table = Table("event_table")
|
||||
table.columns(
|
||||
@ -318,14 +318,14 @@ def event_table(obj, user, action, url, args):
|
||||
get_title(djevent.place),
|
||||
str(event_ref.role_type))
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and action == "view":
|
||||
if user.is_superuser and act == "view":
|
||||
retval += make_button(_("Add New Event"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("Add Existing Event"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def history_table(obj, user, action):
|
||||
def history_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("history_table")
|
||||
table.columns(
|
||||
@ -350,7 +350,7 @@ def history_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def name_table(obj, user, action, url=None, *args):
|
||||
def name_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("name_table")
|
||||
table.columns(_("Name"),
|
||||
@ -382,13 +382,13 @@ def name_table(obj, user, action, url=None, *args):
|
||||
(url % name.person.handle) + ("/%s" % name.order)))
|
||||
table.links(links)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Name"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def surname_table(obj, user, action, url=None, *args):
|
||||
def surname_table(obj, user, act, url=None, *args):
|
||||
person_handle = args[0]
|
||||
order = args[1]
|
||||
retval = ""
|
||||
@ -405,13 +405,13 @@ def surname_table(obj, user, action, url=None, *args):
|
||||
retval += table.get_html()
|
||||
else:
|
||||
retval += "<p id='error'>No such name order = %s</p>" % order
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Surname"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def citation_table(obj, user, action, url=None, *args):
|
||||
def citation_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("citation_table")
|
||||
table.columns(_("ID"),
|
||||
@ -430,14 +430,14 @@ def citation_table(obj, user, action, url=None, *args):
|
||||
str(citation.page),
|
||||
)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Citation"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("Add Existing Citation"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def repository_table(obj, user, action, url=None, *args):
|
||||
def repository_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("repository_table")
|
||||
table.columns(
|
||||
@ -447,14 +447,14 @@ def repository_table(obj, user, action, url=None, *args):
|
||||
if user.is_authenticated():
|
||||
pass
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Repository"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("Add Existing Repository"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def note_table(obj, user, action, url=None, *args):
|
||||
def note_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("note_table")
|
||||
table.columns(
|
||||
@ -472,14 +472,14 @@ def note_table(obj, user, action, url=None, *args):
|
||||
str(note_ref.ref_object.note_type),
|
||||
note_ref.ref_object.text[:50])
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Note"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("Add Existing Note"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def data_table(obj, user, action, url=None, *args):
|
||||
def data_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("data_table")
|
||||
table.columns(_("Type"),
|
||||
@ -488,13 +488,13 @@ def data_table(obj, user, action, url=None, *args):
|
||||
if user.is_authenticated():
|
||||
pass
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Data"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def attribute_table(obj, user, action, url=None, *args):
|
||||
def attribute_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("attribute_table")
|
||||
table.columns(_("Type"),
|
||||
@ -508,13 +508,13 @@ def attribute_table(obj, user, action, url=None, *args):
|
||||
table.row(attribute.attribute_type.name,
|
||||
attribute.value)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Attribute"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def address_table(obj, user, action, url=None, *args):
|
||||
def address_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("address_table")
|
||||
table.columns(_("Date"),
|
||||
@ -532,13 +532,13 @@ def address_table(obj, user, action, url=None, *args):
|
||||
location.state,
|
||||
location.country)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Address"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def location_table(obj, user, action, url=None, *args):
|
||||
def location_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("location_table")
|
||||
table.columns(_("Date"),
|
||||
@ -549,13 +549,13 @@ def location_table(obj, user, action, url=None, *args):
|
||||
if user.is_authenticated():
|
||||
pass # FIXME
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Address"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def media_table(obj, user, action, url=None, *args):
|
||||
def media_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("media_table")
|
||||
table.columns(_("Description"),
|
||||
@ -573,14 +573,14 @@ def media_table(obj, user, action, url=None, *args):
|
||||
str(media_ref.ref_object.desc),
|
||||
media_ref.ref_object.path)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Media"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("Add Existing Media"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def internet_table(obj, user, action, url=None, *args):
|
||||
def internet_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("internet_table")
|
||||
table.columns(_("Type"),
|
||||
@ -593,13 +593,13 @@ def internet_table(obj, user, action, url=None, *args):
|
||||
url_obj.path,
|
||||
url_obj.desc)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Internet"), (str(url) % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def association_table(obj, user, action, url=None, *args):
|
||||
def association_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("association_table")
|
||||
table.columns(_("Name"),
|
||||
@ -612,13 +612,13 @@ def association_table(obj, user, action, url=None, *args):
|
||||
for association in associations:
|
||||
table.row()
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add Association"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def lds_table(obj, user, action, url=None, *args):
|
||||
def lds_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("lds_table")
|
||||
table.columns(_("Type"),
|
||||
@ -636,13 +636,13 @@ def lds_table(obj, user, action, url=None, *args):
|
||||
lds.temple,
|
||||
get_title(lds.place))
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add LDS"), (url % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def reference_table(obj, user, action, url=None, *args):
|
||||
def reference_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("reference_table")
|
||||
table.columns(
|
||||
@ -655,14 +655,14 @@ def reference_table(obj, user, action, url=None, *args):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def person_reference_table(obj, user, action):
|
||||
def person_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("person_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in obj.families.all():
|
||||
table.row(
|
||||
_("Family (spouse in)"),
|
||||
@ -677,14 +677,14 @@ def person_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def note_reference_table(obj, user, action):
|
||||
def note_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("note_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in models.NoteRef.objects.filter(ref_object=obj):
|
||||
ref_from_class = reference.object_type.model_class()
|
||||
item = ref_from_class.objects.get(id=reference.object_id)
|
||||
@ -696,14 +696,14 @@ def note_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def event_reference_table(obj, user, action):
|
||||
def event_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("event_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in models.EventRef.objects.filter(ref_object=obj):
|
||||
ref_from_class = reference.object_type.model_class()
|
||||
item = ref_from_class.objects.get(id=reference.object_id)
|
||||
@ -715,14 +715,14 @@ def event_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def repository_reference_table(obj, user, action):
|
||||
def repository_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("repository_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in models.RepositoryRef.objects.filter(ref_object=obj):
|
||||
ref_from_class = reference.object_type.model_class()
|
||||
item = ref_from_class.objects.get(id=reference.object_id)
|
||||
@ -734,7 +734,7 @@ def repository_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def citation_reference_table(obj, user, action):
|
||||
def citation_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("citation_reference_table")
|
||||
table.columns(
|
||||
@ -742,7 +742,7 @@ def citation_reference_table(obj, user, action):
|
||||
_("Reference"),
|
||||
# _("ID")
|
||||
)
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in models.CitationRef.objects.filter(citation=obj):
|
||||
ref_from_class = reference.object_type.model_class()
|
||||
item = ref_from_class.objects.get(id=reference.object_id)
|
||||
@ -753,28 +753,28 @@ def citation_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def source_reference_table(obj, user, action):
|
||||
def source_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("source_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
pass
|
||||
# FIXME: where is source ref?
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def media_reference_table(obj, user, action):
|
||||
def media_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("media_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
for reference in models.MediaRef.objects.filter(ref_object=obj):
|
||||
ref_from_class = reference.object_type.model_class()
|
||||
item = ref_from_class.objects.get(id=reference.object_id)
|
||||
@ -786,27 +786,27 @@ def media_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def place_reference_table(obj, user, action):
|
||||
def place_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("place_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
pass # FIXME
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def tag_reference_table(obj, user, action):
|
||||
def tag_reference_table(obj, user, act):
|
||||
retval = ""
|
||||
table = Table("tag_reference_table")
|
||||
table.columns(
|
||||
_("Type"),
|
||||
_("Reference"),
|
||||
_("ID"))
|
||||
if user.is_authenticated() and action != "add":
|
||||
if user.is_authenticated() and act != "add":
|
||||
querysets = [obj.person_set, obj.family_set, obj.note_set, obj.media_set]
|
||||
for queryset in querysets:
|
||||
for item in queryset.all():
|
||||
@ -818,7 +818,7 @@ def tag_reference_table(obj, user, action):
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
return retval
|
||||
|
||||
def children_table(obj, user, action, url=None, *args):
|
||||
def children_table(obj, user, act, url=None, *args):
|
||||
retval = ""
|
||||
table = Table("children_table")
|
||||
table.columns(
|
||||
@ -866,7 +866,7 @@ def children_table(obj, user, action, url=None, *args):
|
||||
count += 1
|
||||
table.links(links)
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and url and action == "view":
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("Add New Person as Child"), (url.replace("$act", "add") % args))
|
||||
retval += make_button(_("Add Existing Person as Child"), (url.replace("$act", "share") % args))
|
||||
else:
|
||||
@ -905,16 +905,16 @@ def display_date(obj):
|
||||
else:
|
||||
return ""
|
||||
|
||||
def media_link(handle, user, action):
|
||||
def media_link(handle, user, act):
|
||||
retval = """<a href="%s"><img src="%s" /></a>""" % (
|
||||
"/media/%s/full" % handle,
|
||||
"/media/%s/thumbnail" % handle)
|
||||
return retval
|
||||
|
||||
def render(formfield, user, action, id=None, url=None, *args):
|
||||
def render(formfield, user, act, id=None, url=None, *args):
|
||||
if not user.is_authenticated():
|
||||
action = "view"
|
||||
if action == "view": # show as text
|
||||
act = "view"
|
||||
if act == "view": # show as text
|
||||
fieldname = formfield.name # 'surname'
|
||||
try:
|
||||
item = getattr(formfield.form.model, fieldname)
|
||||
@ -945,7 +945,7 @@ def render(formfield, user, action, id=None, url=None, *args):
|
||||
retval = formfield.as_widget()
|
||||
return retval
|
||||
|
||||
def render_name(name, user, action=None):
|
||||
def render_name(name, user, act=None):
|
||||
"""
|
||||
Given a Django or Gramps object, render the name and return. This
|
||||
function uses authentication, privacy and probably_alive settings.
|
||||
|
Loading…
x
Reference in New Issue
Block a user