diff --git a/src/data/templates/reference.html b/src/data/templates/reference.html
index f505020c0..cd01fc480 100644
--- a/src/data/templates/reference.html
+++ b/src/data/templates/reference.html
@@ -6,7 +6,7 @@
{% include "detail_breadcrumb.html" %}
-
Reference Detail
+
Temporary Reference Detail
diff --git a/src/data/templates/view_citation_detail.html b/src/data/templates/view_citation_detail.html
index c77e86eb3..b4d418174 100644
--- a/src/data/templates/view_citation_detail.html
+++ b/src/data/templates/view_citation_detail.html
@@ -61,7 +61,7 @@
- {% note_table citation user action "/note/add/citation/%s" citation.handle %}
+ {% note_table citation user action "/note/$act/citation/%s" citation.handle %}
@@ -115,7 +115,7 @@
- {% note_table source user action "/note/add/source/%s" source.handle %}
+ {% note_table source user action "/note/$act/source/%s" source.handle %}
diff --git a/src/data/templates/view_family_detail.html b/src/data/templates/view_family_detail.html
index 73638015e..1a5cc9dda 100644
--- a/src/data/templates/view_family_detail.html
+++ b/src/data/templates/view_family_detail.html
@@ -98,19 +98,19 @@
{% children_table family user action "/family/%s/add/child" family.handle %}
- {% event_table family user action "/event/add/family/%s" family.handle %}
+ {% event_table family user action "/event/$act/family/%s" family.handle %}
- {% source_table family user action "/source/add/family/%s" family.handle %}
+ {% source_table family user action "/source/$act/family/%s" family.handle %}
{% attribute_table family user action "/attribute/add/family/%s" family.handle %}
- {% note_table family user action "/note/add/family/%s" family.handle %}
+ {% note_table family user action "/note/$act/family/%s" family.handle %}
- {% gallery_table family user action "/media/add/family/%s" family.handle %}
+ {% gallery_table family user action "/media/$act/family/%s" family.handle %}
{% lds_table family user action "/lds/add/family/%s" family.handle %}
diff --git a/src/data/templates/view_name_detail.html b/src/data/templates/view_name_detail.html
index 4f5c8eabd..401f44b7b 100644
--- a/src/data/templates/view_name_detail.html
+++ b/src/data/templates/view_name_detail.html
@@ -111,7 +111,7 @@
+ onclick="document.location.href='/person/{{person.handle}}#tab-names'"/>
{% if user.is_authenticated %}
{% ifequal action "add" %}
diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html
index aeeceb42a..c5d5c6a10 100644
--- a/src/data/templates/view_person_detail.html
+++ b/src/data/templates/view_person_detail.html
@@ -93,38 +93,38 @@
- {% event_table person user action "/event/add/person/%s" person.handle %}
+ {% event_table person user action "/event/$act/person/%s" person.handle %}
{% name_table person user action "/person/%s/name" person.handle %}
- {% citation_table person user action "/citation/add/person/%s" person.handle %}
+ {% citation_table person user action "/citation/$act/person/%s" person.handle %}
- {% attribute_table person user action "/attribute/add/person/%s" person.handle %}
+ {% attribute_table person user action "/attribute/$act/person/%s" person.handle %}
- {% address_table person user action "/place/add/person/%s" person.handle %}
+ {% address_table person user action "/place/$act/person/%s" person.handle %}
- {% note_table person user action "/note/add/person/%s" person.handle %}
+ {% note_table person user action "/note/$act/person/%s" person.handle %}
- {% gallery_table person user action "/media/add/person/%s" person.handle %}
+ {% gallery_table person user action "/media/$act/person/%s" person.handle %}
- {% internet_table person user action "/person/%s/add/internet" person.handle %}
+ {% internet_table person user action "/person/%s/$act/internet" person.handle %}
- {% association_table person user action "/person/%s/add/association" person.handle %}
+ {% association_table person user action "/person/%s/$act/association" person.handle %}
- {% lds_table person user action "/person/%s/add/lds" person.handle %}
+ {% lds_table person user action "/person/%s/$act/lds" person.handle %}
- {% reference_table person user action "/reference/add/person/%s" person.handle %}
+ {% reference_table person user action "/reference/$act/person/%s" person.handle %}
diff --git a/src/data/templates/view_surname_detail.html b/src/data/templates/view_surname_detail.html
index 0674e79e9..f407191a1 100644
--- a/src/data/templates/view_surname_detail.html
+++ b/src/data/templates/view_surname_detail.html
@@ -78,10 +78,10 @@
{% else %}
+ onclick="document.location.href='/person/{{person.handle}}#tab-names'"/>
+ onclick="document.location.href='/person/{{person.handle}}/name/{{order}}#tab-surnames'"/>
@@ -93,10 +93,10 @@
{% else %}
+ onclick="document.location.href='/person/{{person.handle}}#tab-names'"/>
+ onclick="document.location.href='/person/{{person.handle}}/name/order#tab-surnames'"/>
{% endif %}
{% endblock %}
diff --git a/src/webapp/grampsdb/models.py b/src/webapp/grampsdb/models.py
index 131f12eda..bc641bc2c 100644
--- a/src/webapp/grampsdb/models.py
+++ b/src/webapp/grampsdb/models.py
@@ -816,14 +816,16 @@ class EventRef(BaseRef):
role_type = models.ForeignKey('EventRoleType')
def __unicode__(self):
- return "EventRef to " + str(self.ref_object)
+ return str(self.ref_object)
def get_url(self):
# /person/3536453463/reference/event/2
ref_by = self.object_type.model_class().objects.get(id=self.object_id)
- ref_to = self.ref_object.__class__.__name__.lower()
+ ref_to = self.ref_object
return "/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
- ref_by.handle, ref_to, self.order)
+ ref_by.handle,
+ ref_to.__class__.__name__.lower(),
+ self.order)
class RepositoryRef(BaseRef):
ref_object = models.ForeignKey('Repository')
diff --git a/src/webapp/grampsdb/view/citation.py b/src/webapp/grampsdb/view/citation.py
index 70f927fc1..579b61d6d 100644
--- a/src/webapp/grampsdb/view/citation.py
+++ b/src/webapp/grampsdb/view/citation.py
@@ -94,7 +94,7 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_citation_ref(obj, citation.handle)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-citations" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/view/event.py b/src/webapp/grampsdb/view/event.py
index 7583662e6..68ce0ee9e 100644
--- a/src/webapp/grampsdb/view/event.py
+++ b/src/webapp/grampsdb/view/event.py
@@ -90,7 +90,7 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_event_ref_default(obj, event)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-events" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/view/media.py b/src/webapp/grampsdb/view/media.py
index 2a515d62b..99b420fb3 100644
--- a/src/webapp/grampsdb/view/media.py
+++ b/src/webapp/grampsdb/view/media.py
@@ -81,7 +81,7 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_media_ref_default(obj, media)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-gallery" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/view/person.py b/src/webapp/grampsdb/view/person.py
index 69d954849..a1df53992 100644
--- a/src/webapp/grampsdb/view/person.py
+++ b/src/webapp/grampsdb/view/person.py
@@ -146,7 +146,7 @@ def process_surname(request, handle, order, sorder, action="view"):
neworder += 1
else:
request.user.message_set.create(message="You can't delete the only surname")
- return redirect("/person/%s/name/%s" % (person.handle, name.order))
+ return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
elif action in ["add"]:
surname = Surname(name=name, primary=False,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
@@ -166,7 +166,7 @@ def process_surname(request, handle, order, sorder, action="view"):
surname = sf.save(commit=False)
check_primary(surname, surnames)
surname.save()
- return redirect("/person/%s/name/%s/surname/%s" %
+ return redirect("/person/%s/name/%s/surname/%s#tab-surnames" %
(person.handle, name.order, sorder))
action = "add"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
@@ -179,7 +179,7 @@ def process_surname(request, handle, order, sorder, action="view"):
surname = sf.save(commit=False)
check_primary(surname, name.surname_set.all().exclude(order=surname.order))
surname.save()
- return redirect("/person/%s/name/%s/surname/%s" %
+ return redirect("/person/%s/name/%s/surname/%s#tab-surnames" %
(person.handle, name.order, sorder))
action = "edit"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
@@ -224,7 +224,7 @@ def process_name(request, handle, order, action="view"):
check_order(request, person)
else:
request.user.message_set.create(message = "Can't delete only name.")
- return redirect("/person/%s" % person.handle)
+ return redirect("/person/%s#tab-names" % person.handle)
elif action == "add": # add name
person = Person.objects.get(handle=handle)
name = Name(person=person,
@@ -275,7 +275,7 @@ def process_name(request, handle, order, action="view"):
surname.primary = True # FIXME: why is this False?
surname.save()
dji.rebuild_cache(person)
- return redirect("/person/%s/name/%s" % (person.handle, name.order))
+ return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
else:
action = "add"
elif action == "save":
@@ -309,7 +309,7 @@ def process_name(request, handle, order, action="view"):
surname.primary = True # FIXME: why is this False?
surname.save()
dji.rebuild_cache(person)
- return redirect("/person/%s/name/%s" % (person.handle, name.order))
+ return redirect("/person/%s/name/%s#tab-surnames" % (person.handle, name.order))
else:
action = "edit"
context = RequestContext(request)
diff --git a/src/webapp/grampsdb/view/place.py b/src/webapp/grampsdb/view/place.py
index 009b3ec90..920f5c90e 100644
--- a/src/webapp/grampsdb/view/place.py
+++ b/src/webapp/grampsdb/view/place.py
@@ -81,7 +81,7 @@ def process_place(request, context, handle, action, add_to=None): # view, edit,
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_place_ref(obj, place.handle)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-places" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/view/repository.py b/src/webapp/grampsdb/view/repository.py
index 8e363cf97..1b1d36d98 100644
--- a/src/webapp/grampsdb/view/repository.py
+++ b/src/webapp/grampsdb/view/repository.py
@@ -81,7 +81,7 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_repository_ref(obj, repository)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-repositories" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/view/tag.py b/src/webapp/grampsdb/view/tag.py
index 66de628c3..87565413c 100644
--- a/src/webapp/grampsdb/view/tag.py
+++ b/src/webapp/grampsdb/view/tag.py
@@ -79,7 +79,7 @@ def process_tag(request, context, handle, action, add_to=None): # view, edit, sa
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_tag_ref_default(obj, tag)
- return redirect("/%s/%s" % (item, handle))
+ return redirect("/%s/%s#tab-tags" % (item, handle))
action = "view"
else:
action = "add"
diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py
index baeed0288..85cb27fa7 100644
--- a/src/webapp/grampsdb/views.py
+++ b/src/webapp/grampsdb/views.py
@@ -537,6 +537,13 @@ def check_access(request, context, obj, action):
else: # outside viewer
return not obj.private
+def add_share(request, view, item, handle):
+ """
+ Add a reference to an existing referenced from - .
+ """
+ # /view/share/person/handle
+ raise Http404(_('Not implemented yet.'))
+
def add_to(request, view, item, handle):
"""
Add a new
referenced from - .
@@ -703,18 +710,26 @@ def build_person_query(search, protect):
def process_reference(request, ref_by, handle, ref_to, order):
+ # FIXME: can I make this work for all?
context = RequestContext(request)
ref_by_class = dji.get_model(ref_by)
referenced_by = ref_by_class.objects.get(handle=handle)
object_type = ContentType.objects.get_for_model(referenced_by)
ref_to_class = dji.get_model("%sRef" % ref_to.title())
- referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
- object_type=object_type,
- order=order)
- form = modelformset_factory(ref_to_class, extra=0)(queryset=referenced_to)
- form.model = referenced_to[0]
+ exclude = ["last_changed_by", "last_changed", "object_type", "object_id", "order"]
+ if order == "new":
+ referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
+ object_type=object_type,
+ order=0)
+ form = modelformset_factory(ref_to_class, exclude=exclude, extra=1)(queryset=referenced_to)
+ else:
+ referenced_to = ref_to_class.objects.filter(object_id=referenced_by.id,
+ object_type=object_type,
+ order=order)
+ form = modelformset_factory(ref_to_class, exclude=exclude, extra=0)(queryset=referenced_to)
+ form.model = referenced_to[0]
context["form"] = form
- context["view"] = 'Reference'
+ context["view"] = 'reference'
context["tview"] = _('Reference')
context["tviews"] = _('References')
context["object"] = referenced_by
diff --git a/src/webapp/urls.py b/src/webapp/urls.py
index dd740d0ac..a6be88bda 100644
--- a/src/webapp/urls.py
+++ b/src/webapp/urls.py
@@ -73,6 +73,8 @@ urlpatterns += patterns('',
{"handle": None, "action": "add"}), # /view/add
(r'^(?P
(\w+))/add/(?P- (\w+))/(?P
(\w+))$',
add_to), # /view/add/item/handle
+ (r'^(?P(\w+))/share/(?P- (\w+))/(?P
(\w+))$',
+ add_share), # /view/share/item/handle
(r'^(?P(\w+))/(?P(\w+))/$', action,
{"action": "view"}), # /view/handle/
(r'^(?P(\w+))/(?P(\w+))/(?P(\w+))$',
diff --git a/src/webapp/utils.py b/src/webapp/utils.py
index 224eda695..9e252111e 100644
--- a/src/webapp/utils.py
+++ b/src/webapp/utils.py
@@ -218,11 +218,10 @@ def make_button(text, url, *args):
#return """[ %s ] """ % (url, text)
return """ """ % (text, url)
-def event_table(obj, user, action, url=None, *args):
+def event_table(obj, user, action, url, args):
retval = ""
table = Table()
table.columns(
- _("Event Reference"),
_("Description"),
_("Type"),
_("ID"),
@@ -238,15 +237,15 @@ def event_table(obj, user, action, url=None, *args):
for (djevent, event_ref) in event_list:
table.row(
event_ref,
- djevent.description or str(djevent),
table.db.get_event_from_handle(djevent.handle),
djevent.gramps_id,
display_date(djevent),
get_title(djevent.place),
str(event_ref.role_type))
retval += table.get_html()
- if user.is_superuser and url and action == "view":
- retval += make_button(_("Add event"), (url % args))
+ if user.is_superuser and action == "view":
+ retval += make_button(_("Add event"), (url % args).replace("$act", "add"))
+ retval += make_button(_("Share event"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -339,7 +338,8 @@ def source_table(obj, user, action, url=None, *args):
)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add source"), (url % args))
+ retval += make_button(_("Add source"), (url % args).replace("$act", "add"))
+ retval += make_button(_("Share source"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -364,7 +364,8 @@ def citation_table(obj, user, action, url=None, *args):
)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add citation"), (url % args))
+ retval += make_button(_("Add citation"), (url % args).replace("$act", "add"))
+ retval += make_button(_("Share citation"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -388,7 +389,8 @@ def note_table(obj, user, action, url=None, *args):
note_ref.ref_object.text[:50])
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add note"), (url % args))
+ retval += make_button(_("Add note"), (url % args).replace("$act", "add"))
+ retval += make_button(_("Share note"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -440,12 +442,23 @@ def address_table(obj, user, action, url=None, *args):
def gallery_table(obj, user, action, url=None, *args):
retval = ""
table = Table()
- table.columns(_("Name"),
+ table.columns(_("Description"),
_("Type"),
)
+ if user.is_authenticated():
+ obj_type = ContentType.objects.get_for_model(obj)
+ media_refs = dji.MediaRef.filter(object_type=obj_type,
+ object_id=obj.id)
+ for media_ref in media_refs:
+ media = table.db.get_object_from_handle(
+ media_ref.ref_object.handle)
+ table.row(table.db.get_object_from_handle(media.handle),
+ str(media_ref.ref_object.desc),
+ media_ref.ref_object.path)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add gallery"), (url % args))
+ retval += make_button(_("Add media"), (url % args).replace("$act", "add"))
+ retval += make_button(_("Share media"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -617,11 +630,15 @@ def render(formfield, user, action, test=False, truetext="", id=None):
if (not user.is_authenticated() and not test) or user.is_authenticated():
fieldname = formfield.name # 'surname'
try:
- retval = str(getattr(formfield.form.model, fieldname))
- if retval == "True":
- retval = "Yes"
- elif retval == "False":
- retval = "No"
+ item = getattr(formfield.form.model, fieldname)
+ if (item.__class__.__name__ == 'ManyRelatedManager'):
+ retval = ", ".join([str(i) for i in item.all()])
+ else:
+ retval = str(item)
+ if retval == "True":
+ retval = "Yes"
+ elif retval == "False":
+ retval = "No"
except:
# name, "prefix"
try: