Added note reference controls (order, delete, edit ref); working on infrastructure to add notes to names, etc.
svn: r20773
This commit is contained in:
parent
8203d2f49f
commit
096694439e
@ -115,7 +115,7 @@
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom
|
||||
ui-tabs-hide" id="tab-notes" style="background-color: #f4f0ec;">
|
||||
{% 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 %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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":
|
||||
|
@ -96,6 +96,8 @@ urlpatterns += patterns('',
|
||||
(r'^family/(?P<handle>(\w+))/(?P<act>(\w+))/child/(?P<child>(\w+))$', process_child),
|
||||
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/(?P<act>(\w+))/(?P<item>(\w+))/(?P<index>(\w+))$',
|
||||
process_list_item),
|
||||
(r'^note/(?P<action>(\w+))/person/(?P<handle>(\w+))/name/(?P<order>(\w+))$',
|
||||
process_note_on_name),
|
||||
)
|
||||
|
||||
# In urls:
|
||||
|
@ -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 += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
|
||||
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 += """</div>"""
|
||||
retval += table.get_html()
|
||||
text = table.get_html()
|
||||
text = text.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
|
||||
text = text.replace("}}", """</div>""")
|
||||
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 += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
return retval
|
||||
|
Loading…
Reference in New Issue
Block a user