From a7e5ecbadfdd489f36f66e39da179a769e2651f4 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Tue, 25 Jun 2013 09:20:16 +0000 Subject: [PATCH] GEP 18: add date from cite in reference part of citation svn: r22602 --- data/evidencestyle/evidence_style.csv | 58 +++++++------- gramps/gen/lib/srctemplate.py | 77 +++++++++++-------- .../gui/editors/displaytabs/srctemplatetab.py | 55 +++++++++++-- gramps/gui/editors/editsource.py | 13 ++-- 4 files changed, 131 insertions(+), 72 deletions(-) diff --git a/data/evidencestyle/evidence_style.csv b/data/evidencestyle/evidence_style.csv index a495dfddb..81e2549a0 100644 --- a/data/evidencestyle/evidence_style.csv +++ b/data/evidencestyle/evidence_style.csv @@ -75,8 +75,8 @@ ;;;;;;;;"[COLLECTION]";;".";"P";;;;;; ;;;;;;;;"[REPOSITORY]";;",";"P";;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";"P";"LOC";;;;; -5;"EE Archives & Artifacts";"Archived Material";"Manuscript Records";"Series, emphasis on";"F";"ESM97";;"[AUTHOR]";"Author (Grantor)";"to";;"GS";;;;; -;;;;;;;;"[RECIPIENT]";;",";;"GS";;;;; +5;"EE Archives & Artifacts";"Archived Material";"Manuscript Records";"Series, emphasis on";"F";"ESM97";;"[AUTHOR]";"Author (Grantor)";;;"GS";;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;"GS";;;;; ;;;;;;;;"[ID]";"Record ID";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";";";;;;;;; ;;;;;;;;"[FILE NO.]";;",";;;;;;; @@ -86,8 +86,8 @@ ;;;;;;;;"[COLLECTION]";;",";;;;;;; ;;;;;;;;"[REPOSITORY]";;",";;;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";;"LOC";;;;; -5;"EE Archives & Artifacts";"Archived Material";"Manuscript Records";"Series, emphasis on";"S";"ESM97";;"[AUTHOR]";;"to";;"S";;;;; -;;;;;;;;"[RECIPIENT]";;",";;"S";;;;; +5;"EE Archives & Artifacts";"Archived Material";"Manuscript Records";"Series, emphasis on";"S";"ESM97";;"[AUTHOR]";;;;"S";;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;"S";;;;; ;;;;;;;;"[ID]";"Record ID";",";;;;;;; ;;;;;;;;"[DATE]";;",";;"YEAR";;;;; ;;;;;;;;"[SERIES]";;",";;;;;;; @@ -134,8 +134,8 @@ 8;"EE Archives & Artifacts";"Archived Material";"Research Report";;"L";"ESM100";;"[AUTHOR]";;",";"A";"SG";;;;; ;;;;;;;;"[PROFESSIONAL CREDENTIALS]";;".";"A";;;;;; ;;;;;;;;"[TITLE]";"Report Title";".";"T";;"Quoted";;;; -;;;;;;;;"[TYPE]";"Item Type";"to";"P";;;;;; -;;;;;;;;"[RECIPIENT]";;".";"P";;;;;; +;;;;;;;;"[TYPE]";"Item Type";;"P";;;;;; +;;;;;;;" to";"[RECIPIENT]";;".";"P";;;;;; ;;;;;;;;"[DATE]";"Report Date";".";"P";;;;;; ;;;;;;;;"[COLLECTION]";;",";"P";;;;;; ;;;;;;;;"[REPOSITORY]";;",";"P";;;;;; @@ -144,8 +144,8 @@ ;;;;;;;;"[PROFESSIONAL CREDENTIALS]";;",";;;;;;; ;;;;;;;;"[TITLE]";"Report Title";",";;;"Quoted";;;; ;;;;;;;"p.";"[PAGE]";"Page(s)";";";;;;;;; -;;;;;;;;"[TYPE]";"Item Type";"to";;;;;;; -;;;;;;;;"[RECIPIENT]";;",";;;;;;; +;;;;;;;;"[TYPE]";"Item Type";;;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[DATE]";"Report Date";";";;;;;;; ;;;;;;;;"[COLLECTION]";;",";;;;;;; ;;;;;;;;"[REPOSITORY]";;",";;;;;;; @@ -309,7 +309,7 @@ ;;;;;;;;"[ID]";"Item ID";",";;;;;;; 17;"EE Archives & Artifacts";"Private Holdings";"Historic letter";;"L";"ESM109";;"[AUTHOR]";"Writer";;"A";"SG";;;;; ;;;;;;;"(";"[ADDRESS]";"Writer's Address";")";"P";"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;".";"T";;;;;; +;;;;;;;" to";"[RECIPIENT]";;".";"T";;;;;; ;;;;;;;;"[TYPE]";"Item Type";".";"T";;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";"P";;;;;; ;;;;;;;;"[REPOSITORY]";"Current or Last Known Owner";",";"P";;;;;; @@ -317,15 +317,15 @@ ;;;;;;;;"[YEAR]";"Year Owned";".";"P";;;;;; 17;"EE Archives & Artifacts";"Private Holdings";"Historic letter";;"F";"ESM109";;"[AUTHOR]";"Writer";;;"GS";;;;; ;;;;;;;"(";"[ADDRESS]";"Writer's Address";")";;"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";";";;;;;;; ;;;;;;;;"[REPOSITORY]";"Current or Last Known Owner";",";;;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;",";;"LOC";;;;; ;;;;;;;;"[YEAR]";"Year Owned";".";;;;;;; ;;;;;;;;"[RESEARCH COMMENT]";"Descriptive Detail/Evaluation";".";;;;;;; -17;"EE Archives & Artifacts";"Private Holdings";"Historic letter";;"S";"ESM109";;"[AUTHOR]";"Writer";"to";;"GS";;;;; -;;;;;;;;"[RECIPIENT]";;",";;;;;;; +17;"EE Archives & Artifacts";"Private Holdings";"Historic letter";;"S";"ESM109";;"[AUTHOR]";"Writer";;;"GS";;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;;;;;; 18;"EE Archives & Artifacts";"Private Holdings";"Interview tape & transcript";;"L";"ESM110";;"[AUTHOR]";"Person Interviewed";".";"A";"SG";;;;; ;;;;;;;;"[LOCATION]";;".";"T";;;;;; @@ -354,7 +354,7 @@ ;;;;;;;;"[REPOSITORY ADDRESS]";;".";"P";"LOC";;;;; ;;;;;;;;"[YEAR]";"Year Owned";".";"P";;;;;; 19;"EE Archives & Artifacts";"Private Holdings";"Legal document, unrecorded";;"F";"ESM111";;"[AUTHOR]";"Author (Grantor)";",";;;;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[ID]";"Record ID";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";";";;;;;;; ;;;;;;;;"[FORMAT]";"Item Format";",";;;;;;; @@ -364,7 +364,7 @@ ;;;;;;;;"[YEAR]";"Year Owned";".";;;;;;; ;;;;;;;;"[RESEARCH COMMENT]";"Descriptive Detail/Evaluation";".";;;;;;; 19;"EE Archives & Artifacts";"Private Holdings";"Legal document, unrecorded";;"S";"ESM111";;"[AUTHOR]";"Author (Grantor)";;;;;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[ID]";"Record ID";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;"YEAR";;;;; 20;"EE Archives & Artifacts";"Private Holdings";"Personal correspondence";;"L";"ESM112";;"[COLLECTION]";;".";"T";;;;;; @@ -373,7 +373,7 @@ 20;"EE Archives & Artifacts";"Private Holdings";"Personal correspondence";;"F";"ESM112";;"[AUTHOR]";"Writer";",";;"GS";;;;; ;;;;;;;;"[AFFILIATION]";"Writer's Affiliation";",";;;;;;; ;;;;;;;;"[ADDRESS]";"Writer's Address";",";;"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";",";;;;;;; ;;;;;;;;"[SUBJECT]";;";";;;;;;; @@ -383,14 +383,14 @@ ;;;;;;;;"[REPOSITORY]";"Owner";",";;;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";;"LOC";;;;; 20;"EE Archives & Artifacts";"Private Holdings";"Personal correspondence";;"S";"ESM112";;"[AUTHOR]";"Writer";;;"S";;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;;;;;; 21;"EE Archives & Artifacts";"Private Holdings";"Personal e-mail";;"L";"ESM113";;"[COLLECTION]";;".";"T";;;;;; ;;;;;;;;"[REPOSITORY]";"Owner";",";"P";;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";"P";"LOC";;;;; 21;"EE Archives & Artifacts";"Private Holdings";"Personal e-mail";;"F";"ESM113";;"[AUTHOR]";"Writer";",";;"GS";;;;; ;;;;;;;;"[ADDRESS]";"Writer's Address";",";;"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";",";;;;;;; ;;;;;;;;"[SUBJECT]";;",";;;;;;; @@ -400,14 +400,14 @@ ;;;;;;;;"[REPOSITORY]";"Owner";",";;;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;".";;"LOC";;;;; 21;"EE Archives & Artifacts";"Private Holdings";"Personal e-mail";;"S";"ESM113";;"[AUTHOR]";"Writer";;;"S";;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;;;;;; 22;"EE Archives & Artifacts";"Private Holdings";"Research Report";;"L";"ESM114";;"[AUTHOR]";;",";"A";"SG";;;;; ;;;;;;;;"[PROFESSIONAL CREDENTIALS]";;".";"A";;;;;; ;;;;;;;;"[TITLE]";"Report Title";".";"T";;"Quoted";;;; -;;;;;;;;"[TYPE]";"Item Type";"to";"T";;;;;; -;;;;;;;;"[RECIPIENT]";;;"T";;;;;; +;;;;;;;;"[TYPE]";"Item Type";;"T";;;;;; +;;;;;;;" to";"[RECIPIENT]";;;"T";;;;;; ;;;;;;;;"[ADDRESS]";"Recipient Address";",";;;;"Privacy";;; ;;;;;;;;"[LOCATION]";"Recipient Location";",";"P";;;;;; ;;;;;;;;"[REPORT DATE]";;".";"P";;;;;; @@ -418,8 +418,8 @@ ;;;;;;;;"[PROFESSIONAL CREDENTIALS]";;",";;;;;;; ;;;;;;;;"[TITLE]";"Report Title";",";;;"Quoted";;;; ;;;;;;;;"[PAGE]";"Page(s)";";";;;;;;; -;;;;;;;;"[TYPE]";"Item Type";"to";;;;;;; -;;;;;;;;"[RECIPIENT]";;",";;;;;;; +;;;;;;;;"[TYPE]";"Item Type";;;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[ADDRESS]";"Recipient Address";;;;;"Privacy";;; ;;;;;;;;"[LOCATION]";"Recipient Location";",";;;;;;; ;;;;;;;;"[REPORT DATE]";;";";;;;;;; @@ -486,7 +486,7 @@ ;;;;;;;;"[COLLECTION]";;".";;;;;;; 26;"EE Business & institutional Records";"Corporate Records";"Extract supplied by staff";;"L";"ESM163";;"[AUTHOR]";"Writer";;"A";;;;;; ;;;;;;;"(";"[ADDRESS]";"Writer's Address";")";"P";"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;".";"T";;;;;; +;;;;;;;" to";"[RECIPIENT]";;".";"T";;;;;; ;;;;;;;;"[TYPE]";"Item Type";".";"T";;;;;; ;;;;;;;;"[DATE RANGE]";"Record Date Range";".";"P";;;;;; ;;;;;;;;"[REPOSITORY]";"Owner";",";"P";;;;;; @@ -494,7 +494,7 @@ ;;;;;;;;"[YEAR]";;".";"P";;;;;; 26;"EE Business & institutional Records";"Corporate Records";"Extract supplied by staff";;"F";"ESM163";;"[AUTHOR]";"Writer";;;;;;;; ;;;;;;;"(";"[ADDRESS]";"Writer's Address";")";;"PRIVLOC";;"Privacy";;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";",";;;;;;; ;;;;;;;;"[SUBJECT]";"Owner";";";;;;;;; @@ -502,7 +502,7 @@ ;;;;;;;;"[REPOSITORY ADDRESS]";;",";;"LOC";;;;; ;;;;;;;;"[YEAR]";;".";;;;;;; 26;"EE Business & institutional Records";"Corporate Records";"Extract supplied by staff";;"S";"ESM163";;"[AUTHOR]";"Writer";;;;;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;;;;;; 27;"EE Business & institutional Records";"Corporate Records";"Microfilm";;"L";"ESM164";;"[COLLECTION]";;".";"T";;;;;; ;;;;;;;;"[SERIES]";;".";"T";;;;;; @@ -705,7 +705,7 @@ ;;;;;;;;"[INSTITUTION]";;",";;;;;;; ;;;;;;;;"[LOCATION]";"Location of Institution";";";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";;;;;;;; -;;;;;;;"to";"[RECIPIENT]";;";";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;";";;;;;;; ;;;;;;;;"[REPOSITORY]";"Record Holder";",";;;;;;; ;;;;;;;;"[REPOSITORY ADDRESS]";;",";;"LOC";;;;; ;;;;;;;;"[YEAR]";"When Held";".";;;;;;; @@ -726,18 +726,18 @@ ;;;;;;;;"[TYPE]";"Record Type";".";;;;;;; 40;"EE Cemetery Records";"Cemetery Office Records";"Office records";"supplied by staff";"L";"ESM210";;"[AUTHOR]";"Cemetery (Author)";;"A";;;;;; ;;;;;;;"(";"[LOCATION]";;")";"P";;;;;; -;;;;;;;"to";"[RECIPIENT]";;".";"T";;;;;; +;;;;;;;" to";"[RECIPIENT]";;".";"T";;;;;; ;;;;;;;;"[TYPE]";"Item Type";".";"T";;;;;; ;;;;;;;;"[YEAR]";"Year(s)";".";"T";;;;;; 40;"EE Cemetery Records";"Cemetery Office Records";"Office records";"supplied by staff";"F";"ESM210";;"[AUTHOR]";"Cemetery (Author)";;;;;;;; ;;;;;;;"(";"[LOCATION]";;")";;;;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[TYPE]";"Item Type";",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";",";;;;;;; ;;;;;;;;"[SUBJECT]";"Subject or nature of data provided";".";;;;;;; 40;"EE Cemetery Records";"Cemetery Office Records";"Office records";"supplied by staff";"S";"ESM210";;"[AUTHOR]";"Cemetery (Author)";;;;;;;; ;;;;;;;"(";"[LOCATION]";;")";;"LOC";;;;; -;;;;;;;"to";"[RECIPIENT]";;",";;;;;;; +;;;;;;;" to";"[RECIPIENT]";;",";;;;;;; ;;;;;;;;"[DATE]";"Record Date(s)";".";;;;;;; 41;"EE Cemetery Records";"Cemetery Office Records";"Online images";;"L";"ESM211";;"[AUTHOR]";"Creator";".";"A";;;;;; ;;;;;;;;"[WEBSITE]";;".";"T";;"Italics";;;; diff --git a/gramps/gen/lib/srctemplate.py b/gramps/gen/lib/srctemplate.py index 5a77fc602..b251a67c3 100644 --- a/gramps/gen/lib/srctemplate.py +++ b/gramps/gen/lib/srctemplate.py @@ -38,6 +38,7 @@ _ = glocale.translation.gettext # #------------------------------------------------------------------------- from .srcattrtype import * +from .date import Date #------------------------------------------------------------------------- # @@ -91,7 +92,7 @@ class SrcTemplate(object): """ UNKNOWN = -1 CUSTOM = 0 - + #SRCTEMPLATE has some predefined values which map to citation styles ESM100 = 17 ESM101 = 18 @@ -454,9 +455,9 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.TITLE, _('Report Title'), '.', STYLE_QUOTE, False, False, EMPTY, GED_TITLE, None, None), - ('', SrcAttributeType.TYPE, _('Item Type'), 'to', EMPTY, False, False, EMPTY, GED_PUBINF, + ('', SrcAttributeType.TYPE, _('Item Type'), '', EMPTY, False, False, EMPTY, GED_PUBINF, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_PUBINF, + (' to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_PUBINF, None, None), ('', SrcAttributeType.DATE, _('Report Date'), '.', EMPTY, False, False, EMPTY, GED_PUBINF, None, None), @@ -476,9 +477,9 @@ class SrcTemplate(object): None, None), ('p.', SrcAttributeType.PAGE, _('Page(s)'), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.TYPE, _('Item Type'), 'to', EMPTY, False, False, EMPTY, EMPTY, + ('', SrcAttributeType.TYPE, _('Item Type'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.DATE, _('Report Date'), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -876,7 +877,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ')', EMPTY, True, False, EMPTY, GED_PUBINF, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, + (' to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), @@ -894,7 +895,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ')', EMPTY, True, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -910,9 +911,9 @@ class SrcTemplate(object): None, None), ], REF_TYPE_S: [ - ('', SrcAttributeType.AUTHOR, _('Writer'), 'to', EMPTY, False, False, EMPTY, EMPTY, + ('', SrcAttributeType.AUTHOR, _('Writer'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.DATE, _('Record Date(s)'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -984,7 +985,7 @@ class SrcTemplate(object): REF_TYPE_F: [ ('', SrcAttributeType.AUTHOR, _('Author (Grantor)'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.ID, _('Record ID'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1006,7 +1007,7 @@ class SrcTemplate(object): REF_TYPE_S: [ ('', SrcAttributeType.AUTHOR, _('Author (Grantor)'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.ID, _('Record ID'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1030,7 +1031,7 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ',', EMPTY, True, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1052,7 +1053,7 @@ class SrcTemplate(object): REF_TYPE_S: [ ('', SrcAttributeType.AUTHOR, _('Writer'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.DATE, _('Record Date(s)'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1072,7 +1073,7 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ',', EMPTY, True, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1094,7 +1095,7 @@ class SrcTemplate(object): REF_TYPE_S: [ ('', SrcAttributeType.AUTHOR, _('Writer'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1110,9 +1111,9 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.TITLE, _('Report Title'), '.', STYLE_QUOTE, False, False, EMPTY, GED_TITLE, None, None), - ('', SrcAttributeType.TYPE, _('Item Type'), 'to', EMPTY, False, False, EMPTY, GED_TITLE, + ('', SrcAttributeType.TYPE, _('Item Type'), '', EMPTY, False, False, EMPTY, GED_TITLE, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), '', EMPTY, False, False, EMPTY, GED_TITLE, + (' to', SrcAttributeType.RECIPIENT, _(''), '', EMPTY, False, False, EMPTY, GED_TITLE, None, None), ('', SrcAttributeType.ADDRESS, _('Recipient Address'), ',', EMPTY, True, False, EMPTY, EMPTY, None, None), @@ -1136,9 +1137,9 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.PAGE, _('Page(s)'), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.TYPE, _('Item Type'), 'to', EMPTY, False, False, EMPTY, EMPTY, + ('', SrcAttributeType.TYPE, _('Item Type'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.ADDRESS, _('Recipient Address'), '', EMPTY, True, False, EMPTY, EMPTY, None, None), @@ -1302,7 +1303,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ')', EMPTY, True, False, EMPTY, GED_PUBINF, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, + (' to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), @@ -1320,7 +1321,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.ADDRESS, _('Writer\'s Address'), ')', EMPTY, True, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1338,7 +1339,7 @@ class SrcTemplate(object): REF_TYPE_S: [ ('', SrcAttributeType.AUTHOR, _('Writer'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.DATE, _('Record Date(s)'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1838,7 +1839,7 @@ class SrcTemplate(object): None, None), ('', SrcAttributeType.DATE, _('Record Date(s)'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ';', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.REPOSITORY, _('Record Holder'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1894,7 +1895,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.LOCATION, _(''), ')', EMPTY, False, False, EMPTY, GED_PUBINF, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, + (' to', SrcAttributeType.RECIPIENT, _(''), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), '.', EMPTY, False, False, EMPTY, GED_TITLE, None, None), @@ -1906,7 +1907,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.LOCATION, _(''), ')', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.TYPE, _('Item Type'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -1920,7 +1921,7 @@ class SrcTemplate(object): None, None), ('(', SrcAttributeType.LOCATION, _(''), ')', EMPTY, False, False, SHORTERALG_LOC, EMPTY, None, None), - ('to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.DATE, _('Record Date(s)'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -7960,9 +7961,9 @@ class SrcTemplate(object): None, None), ], REF_TYPE_F: [ - ('', SrcAttributeType.AUTHOR, _('Author (Grantor)'), 'to', EMPTY, False, False, EMPTY, EMPTY, + ('', SrcAttributeType.AUTHOR, _('Author (Grantor)'), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.ID, _('Record ID'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -7984,9 +7985,9 @@ class SrcTemplate(object): None, None), ], REF_TYPE_S: [ - ('', SrcAttributeType.AUTHOR, _(''), 'to', EMPTY, False, False, EMPTY, EMPTY, + ('', SrcAttributeType.AUTHOR, _(''), '', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, + (' to', SrcAttributeType.RECIPIENT, _(''), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', SrcAttributeType.ID, _('Record ID'), ',', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -8190,17 +8191,20 @@ class SrcTemplate(object): raise NotImplementedError self.template_key = template_key - def set_attr_list(self, attr_list, attr_list_citation=None): + def set_attr_list(self, attr_list, attr_list_citation=None, date_citation=None): """ Set the attribute list of this template. Setting once for different references saves some time. attr_list should be the source attribute list If citation given, citation attributes overrule source attributes for the Full and Short references + The citation date is not stored as attribute, so pass Date() object via + date_citation if a date is known. """ self.empty() self.attr_list = attr_list or [] self.attr_list_cite = attr_list_citation or [] + self.date_citation = date_citation # store attributes in a dict last to first. this overwrites data so first # attribute will be the one taken if duplicates are present for attr in self.attr_list[::-1]: @@ -8260,6 +8264,10 @@ class SrcTemplate(object): else: self.attrmap[key] = (None, attr.get_value(), None) + if self.date_citation: + #we store the date of the citation in attrmap + key = SrcAttributeType.DATE + self.attrmap[key] = (None, self.date_citation, None) def reference_L(self, attr_list=None): """ @@ -8349,6 +8357,9 @@ class SrcTemplate(object): #we apply the shortening algorithm ## TODO: not implemented yet pass + #if field is a Date object, we now convert to string + if isinstance(field, Date): + field = str(field) if field.strip(): fieldadded[-1] = True ref[-1] += ldeltodo @@ -8395,7 +8406,7 @@ class SrcTemplate(object): curval = ref[-1] if len(curval) and curval[-1] == '.': pass - elif len(curval) and curval[-1] == ',': + elif len(curval) and curval[-1] in [',', ';']: ref[-1] = ref[-1][:-1] + rdel else: ref[-1] = ref[-1] + rdel @@ -8403,7 +8414,7 @@ class SrcTemplate(object): fieldadded[-1] = False elif len(rdel) and rdel[0] == ',': curval = ref[-1] - if len(curval) and curval[-1] == '.': + if len(curval) and curval[-1] in ['.', ';']: pass elif len(curval) and curval[-1] == ',': pass diff --git a/gramps/gui/editors/displaytabs/srctemplatetab.py b/gramps/gui/editors/displaytabs/srctemplatetab.py index 3f056ae67..e43310e5b 100644 --- a/gramps/gui/editors/displaytabs/srctemplatetab.py +++ b/gramps/gui/editors/displaytabs/srctemplatetab.py @@ -47,7 +47,8 @@ from gramps.gen.lib import SrcAttribute, SrcTemplate from gramps.gen.plug.report.utils import get_address_ref_str from ...autocomp import StandardCustomSelector from ...widgets.srctemplatetreeview import SrcTemplateTreeView -from ...widgets import UndoableEntry, MonitoredEntryIndicator +from ...widgets import (UndoableEntry, MonitoredEntryIndicator, MonitoredDate, + ValidatableMaskedEntry) from .grampstab import GrampsTab #------------------------------------------------------------------------- @@ -92,8 +93,8 @@ class SrcTemplateTab(GrampsTab): self._set_label(show_image=False) widget.connect('key_press_event', self.key_pressed) - self.tmplfields = TemplateFields(self.dbstate.db, - self.glade.get_object('gridfields'), + self.tmplfields = TemplateFields(self.dbstate.db, self.uistate, + self.track, self.glade.get_object('gridfields'), self.src, None, self.callback_src_changed, None) self.autotitle = self.glade.get_object("autotitle_checkbtn") #self.vbox_fields_label = self.glade.get_object('fields_01') @@ -174,8 +175,8 @@ class TemplateFields(object): Class to manage fields of a source template. Can be used on source and on citation level. """ - def __init__(self, db, grid, src, cite, callback_src_changed, - callback_cite_changed): + def __init__(self, db, uistate, track, grid, src, cite, + callback_src_changed, callback_cite_changed): """ grid: The Gtk.Grid that should hold the fields src : The source to which the fields belong @@ -183,6 +184,8 @@ class TemplateFields(object): """ self.gridfields = grid self.db = db + self.uistate = uistate + self.track = track self.src = src self.cite = cite self.callback_src_changed = callback_src_changed @@ -191,6 +194,7 @@ class TemplateFields(object): #storage self.lbls = [] self.inpts = [] + self.btns = [] self.monentry = [] def reset_template_fields(self, index): @@ -212,9 +216,12 @@ class TemplateFields(object): self.gridfields.remove(inpt) for mon in self.monentry: del mon + for btn in self.btns: + self.gridfields.remove(btn) self.lbls = [] self.inpts = [] self.monentry = [] + self.btns = [] row = 1 # now add new fields fieldsL = [] @@ -313,6 +320,10 @@ class TemplateFields(object): SrcAttributeType.REPOSITORY_ADDRESS, SrcAttributeType.REPOSITORY_CALL_NUMBER]: self._add_repo_entry(srcattrtype, row) + elif self.cite and srcattrtype == SrcAttributeType.DATE: + #the DATE on level citation is not an attribute but stored + #as date in the citation + self._add_cite_date(row) else: #setup entry self._add_normal_entry(srcattrtype, row, hint, tooltip) @@ -339,6 +350,30 @@ class TemplateFields(object): read_only=self.db.readonly, parameter=srcattrtype) + def _add_cite_date(self, row): + """ + Add the entry corresponding to the date field on citation level + """ + inpt = ValidatableMaskedEntry() + inpt.set_halign(Gtk.Align.FILL) + inpt.set_hexpand(True) + inpt.set_tooltip_text("The date of the entry in the source you are" + " referencing with this citation. E.g. the date a house was visited" + " during a census , or the date an entry was made in a" + " birth log/registry") + self.gridfields.attach(inpt, 1, row-1, 1, 1) + self.inpts.append(inpt) + btn = self.make_btn('gramps-date') + self.gridfields.attach(btn, 2, row-1, 1, 1) + self.btns.append(btn) + MonitoredDate( + inpt, + btn, + self.cite.get_date_object(), + self.uistate, + self.track, + self.db.readonly) + def _add_repo_entry(self, srcattrtype, row): """ Add a field that obtains info from repository @@ -375,6 +410,16 @@ class TemplateFields(object): self.gridfields.attach(lbl, 1, row-1, 1, 1) self.lbls.append(lbl) + def make_btn(self, stockid): + """ + Create a button for use with a stock image + """ + image = Gtk.Image.new_from_stock('gramps-date', Gtk.IconSize.MENU) + btn = Gtk.Button() + btn.set_image(image) + btn.set_always_show_image(True) + return btn + def get_src_field(self, srcattrtype): return self.__get_field(srcattrtype, self.src) diff --git a/gramps/gui/editors/editsource.py b/gramps/gui/editors/editsource.py index 51d33203e..c4272fffd 100644 --- a/gramps/gui/editors/editsource.py +++ b/gramps/gui/editors/editsource.py @@ -361,10 +361,12 @@ class EditSource(EditPrimary): #set new attrlist in template if self.citation_loaded: citeattr = self.citation.get_attribute_list() + citedate = self.citation.get_date_object() else: citeattr = None - self.srctemp.set_attr_list(self.obj.get_attribute_list(), citeattr) - + citedate = None + self.srctemp.set_attr_list(self.obj.get_attribute_list(), citeattr, + citedate) #set fields with the template self.refL.set_text(self.srctemp.reference_L()) @@ -503,8 +505,8 @@ class EditSource(EditPrimary): self._add_tab(notebook_ref, self.reftab) self.track_ref_for_deletion("reftab") #reftab contains the citation template fields - self.tmplfields = TemplateFields(self.dbstate.db, - self.glade.get_object('grid_citefields'), + self.tmplfields = TemplateFields(self.dbstate.db, self.uistate, + self.track, self.glade.get_object('grid_citefields'), self.obj, self.citation, None, self.callback_cite_changed) self.tmplfields.reset_template_fields(self.obj.get_source_template()[0]) @@ -821,6 +823,8 @@ class EditSource(EditPrimary): #error in database, link to citation handle that does not exist raise Exception self.citation.unserialize(newcite.serialize()) + #we have a citation: + self.citation_loaded = True if not self.citation_ready: self._setup_citation_fields() self._create_citation_tabbed_pages() @@ -830,7 +834,6 @@ class EditSource(EditPrimary): self.tmplfields.reset_template_fields(self.obj.get_source_template()[0]) self.cinf.set_visible(True) self.btnclose_cite.set_sensitive(True) - self.citation_loaded = True self.notebook_ref.set_visible(True) def citation_changed(self):