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
This commit is contained in:
Doug Blank 2012-06-01 16:00:24 +00:00
parent aaf600985c
commit 5763a57985
7 changed files with 59 additions and 19 deletions

View File

@ -50,6 +50,7 @@
#data {
border: 1px solid;
background-color: white;
color: brown;
}
{% endif %}
</style

View File

@ -1,4 +1,5 @@
{% extends "gramps-base.html" %}
{% load my_tags %}
{% block title %}{{sitename}} - user page {% endblock %}
{% block heading %}{{sitename}} - user page {% endblock %}
@ -32,6 +33,14 @@
</tr>
</table>
{% 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 %}
<em>User</em>
{% endif %}
</p>
{% endblock %}

View File

@ -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:

View File

@ -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)

View File

@ -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"]

View File

@ -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"'),

View File

@ -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)