Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form references[v52] #265

Open
wants to merge 4 commits into
base: maintenance/gramps51
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Form/editform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Copyright (C) 2009-2015 Nick Hall
# Copyright (C) 2011 Gary Burton
# Copyright (C) 2019-2020 Steve Youngs
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -51,9 +52,10 @@
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.datehandler import get_date, displayer
from form import ORDER_ATTR, GROOM, BRIDE
from form import (get_form_id, get_form_date, get_form_type, get_form_headings,
get_form_sections, get_section_title, get_section_type,
get_section_columns, get_form_citation)
from form import (get_form_id, get_form_reference, get_form_date,
get_form_type, get_form_headings, get_form_sections,
get_section_title, get_section_type, get_section_columns,
get_form_citation)
from entrygrid import EntryGrid

#------------------------------------------------------------------------
Expand Down Expand Up @@ -286,6 +288,13 @@ def __populate_gui(self, event):
event_type.set_from_xml_str(get_form_type(form_id))
self.event.set_type(event_type)

# Set reference iff this is a new form
if not event.get_handle():
form_reference = get_form_reference(form_id)
if form_reference:
ref_entry = self.widgets['ref_entry']
ref_entry.set_text(form_reference)

# Set date
form_date = get_form_date(form_id)
date_text = self.widgets['date_text']
Expand Down
16 changes: 16 additions & 0 deletions Form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009-2015 Nick Hall
# Copyright (C) 2019-2020 Steve Youngs
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -96,6 +97,7 @@ class Form():
A class to read form definitions from an XML file.
"""
def __init__(self):
self.__references = {}
self.__dates = {}
self.__headings = {}
self.__sections = {}
Expand All @@ -118,6 +120,10 @@ def __load_definitions(self, definition_file):
id = form.attributes['id'].value
self.__names[id] = form.attributes['title'].value
self.__types[id] = form.attributes['type'].value
if 'reference' in form.attributes:
self.__references[id] = form.attributes['reference'].value
else:
self.__references[id] = None
if 'date' in form.attributes:
self.__dates[id] = form.attributes['date'].value
else:
Expand Down Expand Up @@ -173,6 +179,10 @@ def get_title(self, form_id):
""" Return the title for a given form. """
return self.__names[form_id]

def get_reference(self, form_id):
""" Return the reference for a given form. """
return self.__references[form_id]

def get_date(self, form_id):
""" Return a textual date for a given form. """
return self.__dates[form_id]
Expand Down Expand Up @@ -220,6 +230,12 @@ def get_form_title(form_id):
"""
return FORM.get_title(form_id)

def get_form_reference(form_id):
"""
Return the reference for a given form.
"""
return FORM.get_reference(form_id)

def get_form_date(form_id):
"""
Return the date for a given form.
Expand Down
30 changes: 15 additions & 15 deletions Form/form_gb.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<forms>
<form id='UKBirth' type='Birth' title='English Birth Certificate'>
<form id='UKBirth' type='Birth' title='English Birth Certificate' reference='Registration District: , Registration Sub-District: , Register Book of Births Number: , Entry Number: '>
<heading>
<_attribute>Certificate Number</_attribute>
</heading>
Expand Down Expand Up @@ -62,7 +62,7 @@
</column>
</section>
</form>
<form id='UKMarriage' type='Marriage' title='English Marriage Certificate'>
<form id='UKMarriage' type='Marriage' title='English Marriage Certificate' reference='Registration District: , Register Book of Marriages Number: , Entry Number: '>
<heading>
<_attribute>Certificate Number</_attribute>
</heading>
Expand Down Expand Up @@ -127,7 +127,7 @@
</column>
</section>
</form>
<form id='UKDeath' type='Death' title='English Death Certificate'>
<form id='UKDeath' type='Death' title='English Death Certificate' reference='Registration District: , Registration Sub-District: , Register Book of Deaths Number: , Entry Number: '>
<heading>
<_attribute>Certificate Number</_attribute>
</heading>
Expand Down Expand Up @@ -192,7 +192,7 @@
</column>
</section>
</form>
<form id='UK1841' type='Census' title='1841 England and Wales Census' date='6 Jun 1841'>
<form id='UK1841' type='Census' title='1841 England and Wales Census' date='6 Jun 1841' reference='Department: HO, Series: 107, Piece: , Book: , Folio: , Page: '>
<heading>
<_attribute>City or Borough</_attribute>
</heading>
Expand Down Expand Up @@ -222,7 +222,7 @@
</column>
</section>
</form>
<form id='UK1851' type='Census' title='1851 England and Wales Census' date='30 Mar 1851'>
<form id='UK1851' type='Census' title='1851 England and Wales Census' date='30 Mar 1851' reference='Department: HO, Series: 107, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Parish or Township</_attribute>
</heading>
Expand Down Expand Up @@ -273,7 +273,7 @@
</column>
</section>
</form>
<form id='UK1861' type='Census' title='1861 England and Wales Census' date='7 Apr 1861'>
<form id='UK1861' type='Census' title='1861 England and Wales Census' date='7 Apr 1861' reference='Department: RG, Series: 9, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Parish or Township</_attribute>
</heading>
Expand Down Expand Up @@ -330,7 +330,7 @@
</column>
</section>
</form>
<form id='UK1871' type='Census' title='1871 England and Wales Census' date='2 Apr 1871'>
<form id='UK1871' type='Census' title='1871 England and Wales Census' date='2 Apr 1871' reference='Department: RG, Series: 10, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Civil Parish or Township</_attribute>
</heading>
Expand Down Expand Up @@ -396,7 +396,7 @@
</column>
</section>
</form>
<form id='UK1881' type='Census' title='1881 England and Wales Census' date='3 Apr 1881'>
<form id='UK1881' type='Census' title='1881 England and Wales Census' date='3 Apr 1881' reference='Department: RG, Series: 11, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Civil Parish or Township</_attribute>
</heading>
Expand Down Expand Up @@ -462,7 +462,7 @@
</column>
</section>
</form>
<form id='UK1891' type='Census' title='1891 England Census' date='5 Apr 1891'>
<form id='UK1891' type='Census' title='1891 England Census' date='5 Apr 1891' reference='Department: RG, Series: 12, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Administrative County</_attribute>
</heading>
Expand Down Expand Up @@ -543,7 +543,7 @@
</column>
</section>
</form>
<form id='UK1901' type='Census' title='1901 England Census' date='31 Mar 1901'>
<form id='UK1901' type='Census' title='1901 England Census' date='31 Mar 1901' reference='Department: RG, Series: 13, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Administrative County</_attribute>
</heading>
Expand Down Expand Up @@ -619,7 +619,7 @@
</column>
</section>
</form>
<form id='UK1911' type='Census' title='1911 England Census' date='2 Apr 1911'>
<form id='UK1911' type='Census' title='1911 England Census' date='2 Apr 1911' reference='Department: RG, Series: 14, Piece: , Schedule: '>
<heading>
<_attribute>Registration District</_attribute>
</heading>
Expand Down Expand Up @@ -710,7 +710,7 @@
</column>
</section>
</form>
<form id='UK1939' type='Census' title='1939 England and Wales Register' date='29 Sep 1939'>
<form id='UK1939' type='Census' title='1939 England and Wales Register' date='29 Sep 1939' reference='Department: RG, Series: 101, Piece: , Item: , Schedule: '>
<heading>
<_attribute>E.D. Letter Code</_attribute>
</heading>
Expand Down Expand Up @@ -757,7 +757,7 @@
</column>
</section>
</form>
<form id='CY1891' type='Census' title='1891 Wales Census' date='5 Apr 1891'>
<form id='CY1891' type='Census' title='1891 Wales Census' date='5 Apr 1891' reference='Department: RG, Series: 12, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Civil Parish</_attribute>
</heading>
Expand Down Expand Up @@ -831,7 +831,7 @@
</column>
</section>
</form>
<form id='CY1901' type='Census' title='1901 Wales Census' date='31 Mar 1901'>
<form id='CY1901' type='Census' title='1901 Wales Census' date='31 Mar 1901' reference='Department: RG, Series: 13, Piece: , Folio: , Page: , Schedule: '>
<heading>
<_attribute>Civil Parish</_attribute>
</heading>
Expand Down Expand Up @@ -899,7 +899,7 @@
</column>
</section>
</form>
<form id='CY1911' type='Census' title='1911 Wales Census' date='2 Apr 1911'>
<form id='CY1911' type='Census' title='1911 Wales Census' date='2 Apr 1911' reference='Department: RG, Series: 14, Piece: , Schedule: '>
<section role='Primary' type='multi'>
<column>
<_attribute>Name</_attribute>
Expand Down