diff --git a/src/data/templates/view_citation_detail.html b/src/data/templates/view_citation_detail.html
index aaf931509..c77e86eb3 100644
--- a/src/data/templates/view_citation_detail.html
+++ b/src/data/templates/view_citation_detail.html
@@ -7,6 +7,7 @@
$(function(){
$('#tabs').tabs();
+ $('#general-tabs').tabs();
});
@@ -77,7 +78,7 @@
- {% attribute_table person user action "/person/%s/attribute" person.handle %}
+ {% attribute_table person user action "/attribute/add/person/%s" person.handle %}
{% address_table person user action "/place/add/person/%s" person.handle %}
@@ -115,13 +115,13 @@
{% gallery_table person user action "/media/add/person/%s" person.handle %}
- {% internet_table person user action "/person/%s/internet" person.handle %}
+ {% internet_table person user action "/person/%s/add/internet" person.handle %}
- {% association_table person user action "/person/%s/association" person.handle %}
+ {% association_table person user action "/person/%s/add/association" person.handle %}
- {% lds_table person user action "/person/%s/lds" person.handle %}
+ {% lds_table person user action "/person/%s/add/lds" person.handle %}
{% reference_table person user action "/reference/add/person/%s" person.handle %}
diff --git a/src/webapp/grampsdb/models.py b/src/webapp/grampsdb/models.py
index f4a2dc573..ce2996858 100644
--- a/src/webapp/grampsdb/models.py
+++ b/src/webapp/grampsdb/models.py
@@ -382,6 +382,9 @@ class Config(models.Model):
value_type = models.CharField('type of value', max_length=25)
value = models.TextField('value')
+ def __unicode__(self):
+ return str(self.setting)
+
class Tag(models.Model):
handle = models.CharField(max_length=19, unique=True)
gramps_id = models.TextField(blank=True, null=True)
@@ -511,6 +514,9 @@ class Source(PrimaryObject):
pubinfo = models.CharField("Pub. info.", max_length=50, blank=True, null=True)
abbrev = models.CharField("Abbreviation", max_length=50, blank=True, null=True)
+ def __unicode__(self):
+ return str(self.title)
+
# Other keys here:
# .datamap_set
@@ -522,6 +528,9 @@ class Event(DateObject, PrimaryObject):
content_type_field="object_type",
object_id_field="object_id")
+ def __unicode__(self):
+ return str(self.description)
+
class Repository(PrimaryObject):
repository_type = models.ForeignKey('RepositoryType', verbose_name="Type")
name = models.TextField(blank=True)
@@ -531,6 +540,9 @@ class Repository(PrimaryObject):
object_id_field="object_id")
#url_list = models.ManyToManyField('Url', null=True, blank=True)
+ def __unicode__(self):
+ return str(self.name)
+
# Others keys here:
# .address_set
# .url_set
@@ -542,6 +554,9 @@ class Place(PrimaryObject):
lat = models.TextField(blank=True)
#url_list = models.ManyToManyField('Url', null=True, blank=True)
+ def __unicode__(self):
+ return str(self.title)
+
# Others keys here:
# .url_set
# .location_set
@@ -558,6 +573,9 @@ class Media(DateObject, PrimaryObject):
def make_tag_list(self):
return tuple()
+ def __unicode__(self):
+ return str(self.desc)
+
class Note(PrimaryObject):
note_type = models.ForeignKey('NoteType', verbose_name="Type")
text = models.TextField(blank=True)
@@ -570,6 +588,9 @@ class Note(PrimaryObject):
def make_tag_list(self):
return tuple()
+ def __unicode__(self):
+ return str(self.gramps_id)
+
#---------------------------------------------------------------------------
#
# Secondary Tables
diff --git a/src/webapp/grampsdb/view/citation.py b/src/webapp/grampsdb/view/citation.py
index 9477a4c28..70f927fc1 100644
--- a/src/webapp/grampsdb/view/citation.py
+++ b/src/webapp/grampsdb/view/citation.py
@@ -50,10 +50,10 @@ def process_citation(request, context, handle, action, add_to=None): # view, edi
# Handle: edit, view, add, create, save, delete
if action == "add":
- source = Source()
+ source = Source(gramps_id=dji.get_next_id(Source, "S"))
sourceform = SourceForm(instance=source)
sourceform.model = source
- citation = Citation(source=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"]:
diff --git a/src/webapp/grampsdb/view/event.py b/src/webapp/grampsdb/view/event.py
index 9ae79559d..32d9f9e4c 100644
--- a/src/webapp/grampsdb/view/event.py
+++ b/src/webapp/grampsdb/view/event.py
@@ -53,7 +53,7 @@ def process_event(request, context, handle, action, add_to=None): # view, edit,
# Handle: edit, view, add, create, save, delete
if action == "add":
- event = Event()
+ event = Event(gramps_id=dji.get_next_id(Event, "E"))
eventform = EventForm(instance=event)
eventform.model = event
elif action in ["view", "edit"]:
diff --git a/src/webapp/grampsdb/view/family.py b/src/webapp/grampsdb/view/family.py
index 2e5ce5b8c..0a714791c 100644
--- a/src/webapp/grampsdb/view/family.py
+++ b/src/webapp/grampsdb/view/family.py
@@ -50,6 +50,7 @@ def process_family(request, context, handle, action, add_to=None): # view, edit,
# Handle: edit, view, add, create, save, delete
if action == "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)
diff --git a/src/webapp/grampsdb/view/media.py b/src/webapp/grampsdb/view/media.py
index 8678ce89a..2a515d62b 100644
--- a/src/webapp/grampsdb/view/media.py
+++ b/src/webapp/grampsdb/view/media.py
@@ -50,7 +50,7 @@ def process_media(request, context, handle, action, add_to=None): # view, edit,
# Handle: edit, view, add, create, save, delete
if action == "add":
- media = Media()
+ media = Media(gramps_id=dji.get_next_id(Media, "M"))
mediaform = MediaForm(instance=media)
mediaform.model = media
elif action in ["view", "edit"]:
diff --git a/src/webapp/grampsdb/view/note.py b/src/webapp/grampsdb/view/note.py
index ff30a4dd6..ccb709505 100644
--- a/src/webapp/grampsdb/view/note.py
+++ b/src/webapp/grampsdb/view/note.py
@@ -50,7 +50,7 @@ def process_note(request, context, handle, action, add_to=None): # view, edit, s
# Handle: edit, view, add, create, save, delete
if action == "add":
- note = Note()
+ note = Note(gramps_id=dji.get_next_id(Note, "N"))
noteform = NoteForm(instance=note)
noteform.model = note
elif action in ["view", "edit"]:
diff --git a/src/webapp/grampsdb/view/person.py b/src/webapp/grampsdb/view/person.py
index 86a26c709..fd65bac63 100644
--- a/src/webapp/grampsdb/view/person.py
+++ b/src/webapp/grampsdb/view/person.py
@@ -28,6 +28,7 @@ from webapp.grampsdb.forms import *
from webapp.libdjango import DjangoInterface
## Django Modules
+from django.http import Http404
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
@@ -273,9 +274,7 @@ def process_name(request, handle, order, action="view"):
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
- # FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
- # FIXME: update probably_alive
return redirect("/person/%s/name/%s" % (person.handle, name.order))
else:
action = "add"
@@ -309,9 +308,7 @@ def process_name(request, handle, order, action="view"):
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
- # FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
- # FIXME: update probably_alive
return redirect("/person/%s/name/%s" % (person.handle, name.order))
else:
action = "edit"
@@ -387,7 +384,6 @@ def process_person(request, context, handle, action, add_to=None): # view, edit,
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False?
surname.save()
- # FIXME: last_saved, last_changed, last_changed_by
dji.rebuild_cache(person)
# FIXME: update probably_alive
if add_to:
@@ -430,8 +426,7 @@ def get_person_forms(handle, protect=False, empty=False, order=None):
if handle:
person = Person.objects.get(handle=handle)
else:
- person = Person()
- #person.gramps_id = "I0000" # FIXME: get next ID
+ person = Person(gramps_id=dji.get_next_id(Person, "I"))
## get a name
name = None
if order is not None:
diff --git a/src/webapp/grampsdb/view/place.py b/src/webapp/grampsdb/view/place.py
index 57346644d..009b3ec90 100644
--- a/src/webapp/grampsdb/view/place.py
+++ b/src/webapp/grampsdb/view/place.py
@@ -50,7 +50,7 @@ def process_place(request, context, handle, action, add_to=None): # view, edit,
# Handle: edit, view, add, create, save, delete
if action == "add":
- place = Place()
+ place = Place(gramps_id=dji.get_next_id(Place, "P"))
placeform = PlaceForm(instance=place)
placeform.model = place
elif action in ["view", "edit"]:
diff --git a/src/webapp/grampsdb/view/repository.py b/src/webapp/grampsdb/view/repository.py
index 1d71c93cf..8e363cf97 100644
--- a/src/webapp/grampsdb/view/repository.py
+++ b/src/webapp/grampsdb/view/repository.py
@@ -50,7 +50,7 @@ def process_repository(request, context, handle, action, add_to=None): # view, e
# Handle: edit, view, add, create, save, delete
if action == "add":
- repository = Repository()
+ repository = Repository(gramps_id=dji.get_next_id(Repository, "R"))
repositoryform = RepositoryForm(instance=repository)
repositoryform.model = repository
elif action in ["view", "edit"]:
diff --git a/src/webapp/grampsdb/view/source.py b/src/webapp/grampsdb/view/source.py
index 091043358..edd23fc79 100644
--- a/src/webapp/grampsdb/view/source.py
+++ b/src/webapp/grampsdb/view/source.py
@@ -50,7 +50,7 @@ def process_source(request, context, handle, action, add_to=None): # view, edit,
# Handle: edit, view, add, create, save, delete
if action == "add":
- source = Source()
+ source = Source(gramps_id=dji.get_next_id(Source, "S"))
sourceform = SourceForm(instance=source)
sourceform.model = source
elif action in ["view", "edit"]:
diff --git a/src/webapp/libdjango.py b/src/webapp/libdjango.py
index e3de6dcca..3a63dc498 100644
--- a/src/webapp/libdjango.py
+++ b/src/webapp/libdjango.py
@@ -145,6 +145,21 @@ class DjangoInterface(object):
else:
raise AttributeError("no such model: '%s'" % name)
+ def get_next_id(self, obj, prefix):
+ """
+ Get next gramps_id
+
+ >>> dji.get_next_id(Person, "P")
+ 'P0002'
+ >>> dji.get_next_id(Media, "M")
+ 'M2349'
+ """
+ ids = [o["gramps_id"] for o in obj.objects.values("gramps_id")]
+ count = 1
+ while "%s%04d" % (prefix, count) in ids:
+ count += 1
+ return "%s%04d" % (prefix, count)
+
def get_model(self, name):
if hasattr(models, name.title()):
return getattr(models, name.title())
diff --git a/src/webapp/utils.py b/src/webapp/utils.py
index 65516c5c3..c5a365900 100644
--- a/src/webapp/utils.py
+++ b/src/webapp/utils.py
@@ -243,7 +243,7 @@ def event_table(obj, user, action, url=None, *args):
str(event_ref.role_type))
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add event"), (url + "/add") % args)
+ retval += make_button(_("Add event"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -281,7 +281,7 @@ def name_table(obj, user, action, url=None, *args):
table.links(links)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add name"), (url + "/add") % args)
+ retval += make_button(_("Add name"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -309,7 +309,7 @@ def surname_table(obj, user, action, url=None, *args):
else:
retval += "
No such name order = %s
" % order
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add surname"), (url + "/add") % args)
+ retval += make_button(_("Add surname"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -336,7 +336,7 @@ 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 + "/add") % args)
+ retval += make_button(_("Add source"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -361,7 +361,7 @@ 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 + "/add") % args)
+ retval += make_button(_("Add citation"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -405,7 +405,7 @@ def attribute_table(obj, user, action, url=None, *args):
attribute.value)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add attribute"), (url + "/add") % args)
+ retval += make_button(_("Add attribute"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -429,7 +429,7 @@ def address_table(obj, user, action, url=None, *args):
location.country)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add address"), (url + "/add") % args)
+ retval += make_button(_("Add address"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -442,7 +442,7 @@ def gallery_table(obj, user, action, url=None, *args):
)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add gallery"), (url + "/add") % args)
+ retval += make_button(_("Add gallery"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -461,7 +461,7 @@ def internet_table(obj, user, action, url=None, *args):
url_obj.desc)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add internet"), ((str(url) % args) + "/add"))
+ retval += make_button(_("Add internet"), (str(url) % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -480,7 +480,7 @@ def association_table(obj, user, action, url=None, *args):
table.row()
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add association"), (url + "/add") % args)
+ retval += make_button(_("Add association"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -504,7 +504,7 @@ def lds_table(obj, user, action, url=None, *args):
get_title(lds.place))
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add LDS"), (url + "/add") % args)
+ retval += make_button(_("Add LDS"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval
@@ -570,7 +570,7 @@ def children_table(obj, user, action, url=None, *args):
table.links(links)
retval += table.get_html()
if user.is_superuser and url and action == "view":
- retval += make_button(_("Add child"), (url + "/child/add") % args)
+ retval += make_button(_("Add child"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
return retval