Citation refinements
svn: r18584
This commit is contained in:
		@@ -923,6 +923,9 @@ class SimpleAccess(object):
 | 
			
		||||
                    return "%s: %s [%s]" % (_(object_class), 
 | 
			
		||||
                                            self.title(obj), 
 | 
			
		||||
                                            self.gid(obj))
 | 
			
		||||
                elif isinstance(obj, gen.lib.Citation):
 | 
			
		||||
                    return "%s: [%s]" % (_(object_class), 
 | 
			
		||||
                                            self.gid(obj))
 | 
			
		||||
                elif isinstance(obj, gen.lib.Place):
 | 
			
		||||
                    return "%s: %s [%s]" % (_(object_class), 
 | 
			
		||||
                                            place_name(self.dbase, 
 | 
			
		||||
@@ -965,10 +968,10 @@ class SimpleAccess(object):
 | 
			
		||||
            return "%s and %s" % (mother_text, father_text)
 | 
			
		||||
        elif isinstance(obj, gen.lib.MediaObject):
 | 
			
		||||
            return obj.desc
 | 
			
		||||
        elif isinstance(obj, gen.lib.Citation):
 | 
			
		||||
            return obj.gramps_id
 | 
			
		||||
        elif isinstance(obj, gen.lib.Source):
 | 
			
		||||
            return self.title(obj)
 | 
			
		||||
        elif isinstance(obj, gen.lib.Citation):
 | 
			
		||||
            return self.page(obj)
 | 
			
		||||
        elif isinstance(obj, gen.lib.Place):
 | 
			
		||||
            return place_name(self.dbase, obj.handle)
 | 
			
		||||
        elif isinstance(obj, gen.lib.Repository):
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,7 @@ class SimpleTable(object):
 | 
			
		||||
                if (objclass == 'Filter' and 
 | 
			
		||||
                    handle[0] in ['Person', 'Family', 'Place', 'Event',
 | 
			
		||||
                                  'Repository', 'Note', 'MediaObject',
 | 
			
		||||
                                  'Source']):
 | 
			
		||||
                                  'Citation', 'Source']):
 | 
			
		||||
                    menu_item = gtk.MenuItem(_("See data not in Filter"))
 | 
			
		||||
                    menu_item.connect("activate", 
 | 
			
		||||
                      lambda widget: self.show_not_in_filter(handle[0]))
 | 
			
		||||
@@ -178,7 +178,7 @@ class SimpleTable(object):
 | 
			
		||||
        """
 | 
			
		||||
        Handle events on tables. obj is a treeview
 | 
			
		||||
        """
 | 
			
		||||
        from gui.editors import (EditPerson, EditEvent, EditFamily, EditSource,
 | 
			
		||||
        from gui.editors import (EditPerson, EditEvent, EditFamily, EditCitation, EditSource,
 | 
			
		||||
                                 EditPlace, EditRepository, EditNote, EditMedia)
 | 
			
		||||
        selection = obj.get_selection()
 | 
			
		||||
        store, paths = selection.get_selected_rows()
 | 
			
		||||
@@ -219,6 +219,15 @@ class SimpleTable(object):
 | 
			
		||||
                        return True # handled event
 | 
			
		||||
                    except Errors.WindowActiveError:
 | 
			
		||||
                        pass
 | 
			
		||||
            elif objclass == 'Citation':
 | 
			
		||||
                ref = self.access.dbase.get_citation_from_handle(handle)
 | 
			
		||||
                if ref:
 | 
			
		||||
                    try:
 | 
			
		||||
                        EditCitation(self.simpledoc.doc.dbstate, 
 | 
			
		||||
                                     self.simpledoc.doc.uistate, [], ref)
 | 
			
		||||
                        return True # handled event
 | 
			
		||||
                    except Errors.WindowActiveError:
 | 
			
		||||
                        pass
 | 
			
		||||
            elif objclass == 'Source':
 | 
			
		||||
                ref = self.access.dbase.get_source_from_handle(handle)
 | 
			
		||||
                if ref:
 | 
			
		||||
@@ -349,14 +358,14 @@ class SimpleTable(object):
 | 
			
		||||
                retval.append(self.access.describe(item))
 | 
			
		||||
                if (self.__link_col == col or link is None):
 | 
			
		||||
                    link = ('Family', item.handle)
 | 
			
		||||
            elif isinstance(item, gen.lib.Source): 
 | 
			
		||||
                retval.append(self.access.describe(item))
 | 
			
		||||
                if (self.__link_col == col or link is None):
 | 
			
		||||
                    link = ('Source', item.handle)
 | 
			
		||||
            elif isinstance(item, gen.lib.Citation): 
 | 
			
		||||
                retval.append(self.access.describe(item))
 | 
			
		||||
                if (self.__link_col == col or link is None):
 | 
			
		||||
                    link = ('Citation', item.handle)
 | 
			
		||||
            elif isinstance(item, gen.lib.Source): 
 | 
			
		||||
                retval.append(self.access.describe(item))
 | 
			
		||||
                if (self.__link_col == col or link is None):
 | 
			
		||||
                    link = ('Source', item.handle)
 | 
			
		||||
            elif isinstance(item, gen.lib.Event):
 | 
			
		||||
                retval.append(self.access.describe(item))
 | 
			
		||||
                if (self.__link_col == col or link is None):
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@
 | 
			
		||||
  <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
 | 
			
		||||
    <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-events">Events</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-names">Names</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-sources">Sources</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-citations">Citations</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-attributes">Attributes</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-addresses">Addresses</a></li>
 | 
			
		||||
    <li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
 | 
			
		||||
@@ -95,8 +95,8 @@
 | 
			
		||||
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names">
 | 
			
		||||
    {% name_table person user action "/person/%s/name" person.handle %}
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
 | 
			
		||||
    {% source_table person user action "/person/%s/source" person.handle %}
 | 
			
		||||
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-citations">
 | 
			
		||||
    {% citation_table person user action "/person/%s/citation" person.handle %}
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
 | 
			
		||||
    {% attribute_table person user action "/person/%s/attribute" person.handle %}
 | 
			
		||||
 
 | 
			
		||||
@@ -257,8 +257,8 @@ def name_table(obj, user, action, url=None, *args):
 | 
			
		||||
        links = []
 | 
			
		||||
        for name in obj.name_set.all().order_by("order"):
 | 
			
		||||
            obj_type = ContentType.objects.get_for_model(name)
 | 
			
		||||
            sourceq = dji.SourceRef.filter(object_type=obj_type,
 | 
			
		||||
                                           object_id=name.id).count() > 0
 | 
			
		||||
            citationq = dji.CitationRef.filter(object_type=obj_type,
 | 
			
		||||
                                               object_id=name.id).count() > 0
 | 
			
		||||
            note_refs = dji.NoteRef.filter(object_type=obj_type,
 | 
			
		||||
                                           object_id=name.id)
 | 
			
		||||
            note = ""
 | 
			
		||||
@@ -270,7 +270,7 @@ def name_table(obj, user, action, url=None, *args):
 | 
			
		||||
            table.row(make_name(name, user),
 | 
			
		||||
                      str(name.name_type) + ["", " (preferred)"][int(name.preferred)],
 | 
			
		||||
                      name.group_as,
 | 
			
		||||
                      ["No", "Yes"][sourceq],
 | 
			
		||||
                      ["No", "Yes"][citationq],
 | 
			
		||||
                      note)
 | 
			
		||||
            links.append(('URL', 
 | 
			
		||||
                          # url is "/person/%s/name"
 | 
			
		||||
@@ -292,15 +292,17 @@ def source_table(obj, user, action, url=None, *args):
 | 
			
		||||
                  _("Page"))
 | 
			
		||||
    if user.is_authenticated():
 | 
			
		||||
        obj_type = ContentType.objects.get_for_model(obj)
 | 
			
		||||
        source_refs = dji.SourceRef.filter(object_type=obj_type,
 | 
			
		||||
                                           object_id=obj.id)
 | 
			
		||||
        for source_ref in source_refs:
 | 
			
		||||
            source = table.db.get_source_from_handle(source_ref.ref_object.handle)
 | 
			
		||||
            table.row(source,
 | 
			
		||||
                      source_ref.ref_object.title,
 | 
			
		||||
                      source_ref.ref_object.author,
 | 
			
		||||
                      source_ref.page,
 | 
			
		||||
                      )
 | 
			
		||||
        citation_refs = dji.CitationRef.filter(object_type=obj_type,
 | 
			
		||||
                                             object_id=obj.id)
 | 
			
		||||
        for citation_ref in citation_refs:
 | 
			
		||||
            if citation_ref.citation:
 | 
			
		||||
                if citation_ref.citation.source:
 | 
			
		||||
                    source = citation_ref.citation.source
 | 
			
		||||
                    table.row(source,
 | 
			
		||||
                              source_ref.ref_object.title,
 | 
			
		||||
                              source_ref.ref_object.author,
 | 
			
		||||
                              source_ref.page,
 | 
			
		||||
                              )
 | 
			
		||||
    retval += table.get_html()
 | 
			
		||||
    if user.is_authenticated() and url and action == "view":
 | 
			
		||||
        retval += make_button(_("Add source"), (url + "/add") % args)
 | 
			
		||||
@@ -319,11 +321,12 @@ def citation_table(obj, user, action, url=None, *args):
 | 
			
		||||
        citation_refs = dji.CitationRef.filter(object_type=obj_type,
 | 
			
		||||
                                               object_id=obj.id)
 | 
			
		||||
        for citation_ref in citation_refs:
 | 
			
		||||
            citation = table.db.get_citation_from_handle(citation_ref.citation.handle)
 | 
			
		||||
            table.row(citation,
 | 
			
		||||
                      citation.confidence,
 | 
			
		||||
                      citation.page,
 | 
			
		||||
                      )
 | 
			
		||||
            if citation_ref.citation:
 | 
			
		||||
                citation = citation_ref.citation
 | 
			
		||||
                table.row(citation,
 | 
			
		||||
                          str(citation.confidence),
 | 
			
		||||
                          str(citation.page),
 | 
			
		||||
                          )
 | 
			
		||||
    retval += table.get_html()
 | 
			
		||||
    if user.is_authenticated() and url and action == "view":
 | 
			
		||||
        retval += make_button(_("Add citation"), (url + "/add") % args)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user