From 5763a579855de32f3bd557a9889f9b53b9ad092d Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 1 Jun 2012 16:00:24 +0000 Subject: [PATCH] Added some Tag support; renamed Report items from textreport to report to be more general; added super user admin return and editing of profile/user svn: r19735 --- src/data/templates/gramps-base.html | 1 + src/data/templates/user_page.html | 9 +++++++++ src/webapp/dbdjango.py | 11 +++++++++++ src/webapp/grampsdb/admin.py | 16 ++++++++++++--- src/webapp/grampsdb/views.py | 3 ++- src/webapp/init.py | 30 ++++++++++++++--------------- src/webapp/libdjango.py | 8 ++++++++ 7 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/data/templates/gramps-base.html b/src/data/templates/gramps-base.html index 7fa696057..84b79200d 100644 --- a/src/data/templates/gramps-base.html +++ b/src/data/templates/gramps-base.html @@ -50,6 +50,7 @@ #data { border: 1px solid; background-color: white; + color: brown; } {% endif %} +{% if user.is_superuser %} + {% make_button "Edit Profile" "/admin/grampsdb/profile/%s" user.id %} + {% make_button "Edit User" "/admin/auth/user/%s" user.id %} +{% else %} + User +{% endif %} + +

{% endblock %} diff --git a/src/webapp/dbdjango.py b/src/webapp/dbdjango.py index ed296a5df..768f4d0a3 100644 --- a/src/webapp/dbdjango.py +++ b/src/webapp/dbdjango.py @@ -618,6 +618,10 @@ class DbDjango(DbWriteBase, DbReadBase): data = self.dji.get_note(note) return gen.lib.Note.create(data) + def make_tag(self, tag): + data = self.dji.get_tag(tag) + return gen.lib.Tag.create(data) + def make_place(self, place): if self.use_db_cache and place.cache: data = cPickle.loads(base64.decodestring(place.cache)) @@ -707,6 +711,13 @@ class DbDjango(DbWriteBase, DbReadBase): def iter_family_handles(self): return (family.handle for family in self.dji.Family.all()) + def get_tag_from_name(self, name): + try: + tag = self.dji.Tag.filter(name=name) + return self.make_tag(tag[0]) + except: + return None + def get_person_from_gramps_id(self, gramps_id): if self.import_cache: for handle in self.import_cache: diff --git a/src/webapp/grampsdb/admin.py b/src/webapp/grampsdb/admin.py index b9464775d..26c2567fd 100644 --- a/src/webapp/grampsdb/admin.py +++ b/src/webapp/grampsdb/admin.py @@ -24,7 +24,17 @@ from webapp.grampsdb.models import * from django.contrib import admin -for type_name in get_tables("all"): - admin.site.register(type_name[1]) +print dir(admin.ModelAdmin) + +class MyAdmin(admin.ModelAdmin): + def change_view(self, request, object_id, extra_context=None): + print "object_id:", object_id + result = super(MyAdmin, self).change_view(request, object_id, extra_context) + if not request.POST.has_key('_addanother') and not request.POST.has_key('_continue'): + result['Location'] = "/" + return result + +for type_name in get_tables("all"): + admin.site.register(type_name[1], MyAdmin) +admin.site.register(Profile, MyAdmin) -admin.site.register(Profile) diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index 1a23e0933..a2d7710ad 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -188,7 +188,8 @@ def process_report_run(request, handle): if "=" in pair: key, value = pair.split("=", 1) args[key] = value - if report.report_type == "textreport": + ############################################################################# + if report.report_type == "report": filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"]) run_report(db, handle, of=filename, **args) mimetype = 'application/%s' % args["off"] diff --git a/src/webapp/init.py b/src/webapp/init.py index c6bd90346..ecac45716 100644 --- a/src/webapp/init.py +++ b/src/webapp/init.py @@ -72,63 +72,63 @@ for table, entries in [("grampsdb.config", [(("name", '"Ahnentafel Report"'), ('gramps_id', '"R0001"'), ("handle", '"ancestor_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"birthday_report"'), ('gramps_id', '"R0002"'), ("handle", '"birthday_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"custom_text"'), ('gramps_id', '"R0003"'), ("handle", '"custom_text"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"descend_report"'), ('gramps_id', '"R0004"'), ("handle", '"descend_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"det_ancestor_report"'), ('gramps_id', '"R0005"'), ("handle", '"det_ancestor_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"det_descendant_report"'), ('gramps_id', '"R0006"'), ("handle", '"det_descendant_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"endofline_report"'), ('gramps_id', '"R0007"'), ("handle", '"endofline_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"family_group"'), ('gramps_id', '"R0008"'), ("handle", '"family_group"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"indiv_complete"'), ('gramps_id', '"R0009"'), ("handle", '"indiv_complete"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"kinship_report"'), ('gramps_id', '"R0010"'), ("handle", '"kinship_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"tag_report"'), ('gramps_id', '"R0011"'), ("handle", '"tag_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"number_of_ancestors_report"'), ('gramps_id', '"R0012"'), ("handle", '"number_of_ancestors_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"place_report"'), ('gramps_id', '"R0013"'), ("handle", '"place_report"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"simple_book_title"'), ('gramps_id', '"R0014"'), ("handle", '"simple_book_title"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"summary"'), ('gramps_id', '"R0015"'), ("handle", '"summary"'), - ("report_type", '"textreport"')), + ("report_type", '"report"')), (("name", '"Export"'), ('gramps_id', '"R0016"'), ("handle", '"gedcom_export"'), diff --git a/src/webapp/libdjango.py b/src/webapp/libdjango.py index e184a4190..6ae1ef2cd 100644 --- a/src/webapp/libdjango.py +++ b/src/webapp/libdjango.py @@ -310,6 +310,14 @@ class DjangoInterface(object): retval += [(tuple(markup.styled_text_tag_type), value, ss_list)] return retval + def get_tag(self, tag): + changed = totime(tag.last_changed) + return (str(tag.handle), + tag.name, + tag.color, + tag.priority, + changed) + def get_note(self, note): styled_text = [note.text, self.get_note_markup(note)] changed = totime(note.last_changed)