From 096694439e5fd04ae1366615f5408ba71a7b3659 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 7 Dec 2012 12:28:02 +0000 Subject: [PATCH] Added note reference controls (order, delete, edit ref); working on infrastructure to add notes to names, etc. svn: r20773 --- gramps/data/templates/view_name_detail.html | 2 +- gramps/webapp/grampsdb/view/note.py | 7 ++++++ gramps/webapp/grampsdb/views.py | 4 +++ gramps/webapp/urls.py | 2 ++ gramps/webapp/utils.py | 28 ++++++++++++++++++--- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/gramps/data/templates/view_name_detail.html b/gramps/data/templates/view_name_detail.html index b3aceb49a..e995a4f0c 100644 --- a/gramps/data/templates/view_name_detail.html +++ b/gramps/data/templates/view_name_detail.html @@ -115,7 +115,7 @@
- {% note_table nameform.model user action "/person/%s/name/%s/note" person.handle nameform.model.order %} + {% note_table nameform.model user action "/note/$act/person/%s/name/%s" person.handle nameform.model.order %}
diff --git a/gramps/webapp/grampsdb/view/note.py b/gramps/webapp/grampsdb/view/note.py index c816ccf49..5ccfe8cde 100644 --- a/gramps/webapp/grampsdb/view/note.py +++ b/gramps/webapp/grampsdb/view/note.py @@ -37,6 +37,13 @@ dji = DjangoInterface() db = DbDjango() snf = StyledNoteFormatter(db) +# add a note to a person: +# /note/add/person/c51759195496de06da3ca5ba2c1 + +def process_note_on_name(request, action, handle, order): + # add, edit, delete + raise Exception("testing") + def process_note(request, context, handle, act, add_to=None): # view, edit, save """ Process act on person. Can return a redirect. diff --git a/gramps/webapp/grampsdb/views.py b/gramps/webapp/grampsdb/views.py index aca1dc472..e00b7d1c2 100644 --- a/gramps/webapp/grampsdb/views.py +++ b/gramps/webapp/grampsdb/views.py @@ -1365,6 +1365,7 @@ def process_list_item(request, view, handle, act, item, index): "eventref": "#tab-events", "citationref": "#tab-citations", "repositoryref": "#tab-repositories", + "noteref": "#tab-notes", "attribute": "#tab-attributes", "media": "#tab-media", "lds": "#tab-lds", @@ -1394,6 +1395,9 @@ def process_list_item(request, view, handle, act, item, index): elif item == "repositoryref": refs = dji.RepositoryRef.filter(object_id=obj.id, object_type=obj_type).order_by("order") + elif item == "noteref": + refs = dji.NoteRef.filter(object_id=obj.id, + object_type=obj_type).order_by("order") elif item == "parentfamily": refs = dji.MyParentFamilies.filter(person=obj).order_by("order") elif item == "family": diff --git a/gramps/webapp/urls.py b/gramps/webapp/urls.py index 7d074c510..c9adbe0e2 100644 --- a/gramps/webapp/urls.py +++ b/gramps/webapp/urls.py @@ -96,6 +96,8 @@ urlpatterns += patterns('', (r'^family/(?P(\w+))/(?P(\w+))/child/(?P(\w+))$', process_child), (r'^(?P(\w+))/(?P(\w+))/(?P(\w+))/(?P(\w+))/(?P(\w+))$', process_list_item), + (r'^note/(?P(\w+))/person/(?P(\w+))/name/(?P(\w+))$', + process_note_on_name), ) # In urls: diff --git a/gramps/webapp/utils.py b/gramps/webapp/utils.py index 86404737b..ec289df49 100644 --- a/gramps/webapp/utils.py +++ b/gramps/webapp/utils.py @@ -648,19 +648,28 @@ def note_table(obj, user, act, url=None, *args): cssid = "tab-notes" table = Table("note_table") table.columns( + "", _("ID"), _("Type"), _("Note")) + table.column_widths = [11, 10, 20, 59] if user.is_authenticated() or obj.public: obj_type = ContentType.objects.get_for_model(obj) note_refs = dji.NoteRef.filter(object_type=obj_type, - object_id=obj.id) + object_id=obj.id).order_by("order") + links = [] + count = 1 for note_ref in note_refs: note = note_ref.ref_object - table.row(note, + table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "", + note.gramps_id, str(note.note_type), - note.text[:50]) + note.text[:50] + ) + links.append(('URL', note_ref.get_url())) has_data = True + count += 1 + table.links(links) retval += """
""" if user.is_superuser and url and act == "view": retval += make_button(_("+Add New Note"), (url % args).replace("$act", "add")) @@ -668,7 +677,18 @@ def note_table(obj, user, act, url=None, *args): else: retval += nbsp("") # to keep tabs same height retval += """
""" - retval += table.get_html() + text = table.get_html() + text = text.replace("{{", """
""") + text = text.replace("}}", """
""") + if user.is_authenticated() or obj.public: + count = 1 + for note_ref in note_refs: + item = obj.__class__.__name__.lower() + text = text.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/noteref/%d" % (item, obj.handle, count))) + text = text.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/noteref/%d" % (item, obj.handle, count))) + text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/noteref/%d" % (item, obj.handle, count))) + count += 1 + retval += text if has_data: retval += """ \n""" % cssid return retval