GEPS 006: Add Locality to researcher

svn: r16082
This commit is contained in:
Nick Hall 2010-10-29 23:11:08 +00:00
parent 8f37b38c73
commit 9c14d3b487
12 changed files with 164 additions and 93 deletions

View File

@ -1219,27 +1219,29 @@ def get_translations():
#
#-------------------------------------------------------------------------
def get_researcher():
import gen.lib
import config
n = config.get('researcher.researcher-name')
a = config.get('researcher.researcher-addr')
c = config.get('researcher.researcher-city')
s = config.get('researcher.researcher-state')
ct = config.get('researcher.researcher-country')
p = config.get('researcher.researcher-postal')
ph = config.get('researcher.researcher-phone')
e = config.get('researcher.researcher-email')
"""
Return a new database owner with the default values from the config file.
"""
name = config.get('researcher.researcher-name')
address = config.get('researcher.researcher-addr')
locality = config.get('researcher.researcher-locality')
city = config.get('researcher.researcher-city')
state = config.get('researcher.researcher-state')
country = config.get('researcher.researcher-country')
post_code = config.get('researcher.researcher-postal')
phone = config.get('researcher.researcher-phone')
email = config.get('researcher.researcher-email')
owner = gen.lib.Researcher()
owner.set_name(n)
owner.set_address(a)
owner.set_city(c)
owner.set_state(s)
owner.set_country(ct)
owner.set_postal_code(p)
owner.set_phone(ph)
owner.set_email(e)
owner.set_name(name)
owner.set_address(address)
owner.set_locality(locality)
owner.set_city(city)
owner.set_state(state)
owner.set_country(country)
owner.set_postal_code(post_code)
owner.set_phone(phone)
owner.set_email(email)
return owner

View File

@ -286,6 +286,7 @@ register('preferences.last-view', '')
register('preferences.last-views', [])
register('researcher.researcher-addr', '')
register('researcher.researcher-locality', '')
register('researcher.researcher-city', '')
register('researcher.researcher-country', '')
register('researcher.researcher-email', '')

View File

@ -97,6 +97,7 @@ class Researcher(LocationBase):
def set_from(self, other_researcher):
"""Set all attributes from another instance."""
self.street = other_researcher.street
self.locality = other_researcher.locality
self.city = other_researcher.city
self.county = other_researcher.county
self.state = other_researcher.state
@ -110,6 +111,6 @@ class Researcher(LocationBase):
def get(self):
return [getattr(self, value) for value in
['name', 'addr', 'city', 'state',
['name', 'addr', 'locality', 'city', 'state',
'country', 'postal', 'phone', 'email']
]

View File

@ -426,12 +426,13 @@ class GrampsPreferences(ConfigureDialog):
table.set_row_spacings(6)
self.add_entry(table, _('Name'), 0, 'researcher.researcher-name')
self.add_entry(table, _('Address'), 1, 'researcher.researcher-addr')
self.add_entry(table, _('City'), 2, 'researcher.researcher-city')
self.add_entry(table, _('State/Province'), 3, 'researcher.researcher-state')
self.add_entry(table, _('Country'), 4, 'researcher.researcher-country')
self.add_entry(table, _('ZIP/Postal Code'), 5, 'researcher.researcher-postal')
self.add_entry(table, _('Phone'), 6, 'researcher.researcher-phone')
self.add_entry(table, _('Email'), 7, 'researcher.researcher-email')
self.add_entry(table, _('Locality'), 2, 'researcher.researcher-locality')
self.add_entry(table, _('City'), 3, 'researcher.researcher-city')
self.add_entry(table, _('State/County'), 4, 'researcher.researcher-state')
self.add_entry(table, _('Country'), 5, 'researcher.researcher-country')
self.add_entry(table, _('ZIP/Postal Code'), 6, 'researcher.researcher-postal')
self.add_entry(table, _('Phone'), 7, 'researcher.researcher-phone')
self.add_entry(table, _('Email'), 8, 'researcher.researcher-email')
return _('Researcher'), table
def add_prefix_panel(self, configdialog):

View File

@ -63,11 +63,11 @@ class RepositoryModel(FlatBaseModel):
self.column_type,
self.column_home_url,
self.column_street,
self.column_postal_code,
self.column_locality,
self.column_city,
self.column_county,
self.column_state,
self.column_country,
self.column_postal_code,
self.column_email,
self.column_search_url,
self.column_change,
@ -81,11 +81,11 @@ class RepositoryModel(FlatBaseModel):
self.column_type,
self.column_home_url,
self.column_street,
self.column_postal_code,
self.column_locality,
self.column_city,
self.column_county,
self.column_state,
self.column_country,
self.column_postal_code,
self.column_email,
self.column_search_url,
self.sort_change,
@ -132,12 +132,12 @@ class RepositoryModel(FlatBaseModel):
except:
return u''
def column_county(self,data):
def column_locality(self,data):
try:
if data[5]:
addr = gen.lib.Address()
addr.unserialize(data[5][0])
return addr.get_county()
return addr.get_locality()
else:
return u''
except:

View File

@ -382,6 +382,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(2, "CONT", "%s, %s %s" % (city, state, post))
else:
self.__writeln(2, "CONT", u"Not Provided")
if addr:
self.__writeln(2, "ADR1", addr)
if adr2:
self.__writeln(2, "ADR2", adr2)
if city:
@ -683,6 +685,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(1, 'RESI')
self.__date(2, addr.get_date_object())
self.__writeln(2, "ADDR", addr.get_street())
if addr.get_street():
self.__writeln(3, 'ADR1', addr.get_street())
if addr.get_locality():
self.__writeln(3, 'ADR2', addr.get_locality())
if addr.get_city():
@ -1011,6 +1015,8 @@ class GedcomWriter(UpdateCallback):
self.__writeln(1, 'NAME', repo.get_name())
for addr in repo.get_address_list():
self.__writeln(1, "ADDR", addr.get_street())
if addr.get_street():
self.__writeln(2, 'ADR1', addr.get_street())
if addr.get_locality():
self.__writeln(2, 'ADR2', addr.get_locality())
if addr.get_city():
@ -1367,6 +1373,8 @@ class GedcomWriter(UpdateCallback):
location = place.get_main_location()
if location and not location.is_empty():
self.__writeln(level, "ADDR", location.get_street())
if location.get_street():
self.__writeln(level + 1, 'ADR1', location.get_street())
if location.get_locality():
self.__writeln(level + 1, 'ADR2', location.get_locality())
if location.get_city():

View File

@ -221,6 +221,7 @@ class GrampsXmlWriter(UpdateCallback):
self.g.write(" <researcher>\n")
self.write_line("resname", owner.get_name(),3)
self.write_line("resaddr", owner.get_address(),3)
self.write_line("reslocality", owner.get_locality(),3)
self.write_line("rescity", owner.get_city(),3)
self.write_line("resstate", owner.get_state(),3)
self.write_line("rescountry", owner.get_country(),3)

View File

@ -533,10 +533,11 @@ class GrampsParser(UpdateCallback):
"postal": (None, self.stop_postal),
"range": (self.start_range, None),
"researcher": (None, self.stop_research),
"resname": (None, self.stop_resname ),
"resaddr": (None, self.stop_resaddr ),
"rescity": (None, self.stop_rescity ),
"resstate": (None, self.stop_resstate ),
"resname": (None, self.stop_resname),
"resaddr": (None, self.stop_resaddr),
"reslocality": (None, self.stop_reslocality),
"rescity": (None, self.stop_rescity),
"resstate": (None, self.stop_resstate),
"rescountry": (None, self.stop_rescountry),
"respostal": (None, self.stop_respostal),
"resphone": (None, self.stop_resphone),
@ -2442,6 +2443,7 @@ class GrampsParser(UpdateCallback):
def stop_research(self, tag):
self.owner.set_name(self.resname)
self.owner.set_address(self.resaddr)
self.owner.set_locality(self.reslocality)
self.owner.set_city(self.rescity)
self.owner.set_state(self.resstate)
self.owner.set_country(self.rescon)
@ -2455,6 +2457,9 @@ class GrampsParser(UpdateCallback):
def stop_resaddr(self, tag):
self.resaddr = tag
def stop_reslocality(self, tag):
self.reslocality = tag
def stop_rescity(self, tag):
self.rescity = tag

View File

@ -2036,7 +2036,7 @@ class GedcomParser(UpdateCallback):
self.parse_loc_tbl = {
TOKEN_ADDR : self.__location_addr,
TOKEN_ADR1 : self.__location_addr,
TOKEN_ADR1 : self.__location_adr1,
TOKEN_ADR2 : self.__location_adr2,
TOKEN_DATE : self.__location_date,
TOKEN_CITY : self.__location_city,
@ -2136,6 +2136,7 @@ class GedcomParser(UpdateCallback):
self.parse_addr_tbl = {
TOKEN_DATE : self.__address_date,
TOKEN_ADR1 : self.__address_adr1,
TOKEN_ADR2 : self.__address_adr2,
TOKEN_CITY : self.__address_city,
TOKEN_STAE : self.__address_state,
@ -4644,6 +4645,17 @@ class GedcomParser(UpdateCallback):
"""
state.addr.set_date_object(line.data)
def __address_adr1(self, line, state):
"""
Parses the ADR1 line of an ADDR tag
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
state.addr.set_street(line.data)
def __address_adr2(self, line, state):
"""
Parses the ADR2 line of an ADDR tag
@ -5348,6 +5360,17 @@ class GedcomParser(UpdateCallback):
state.location = gen.lib.Location()
state.location.set_date_object(line.data)
def __location_adr1(self, line, state):
"""
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
if not state.location:
state.location = gen.lib.Location()
state.location.set_street(line.data)
def __location_adr2(self, line, state):
"""
@param line: The current line in GedLine format

View File

@ -4,6 +4,7 @@
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2010 Nick Hall
#
# 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
@ -62,6 +63,7 @@ WIKI_HELP_SEC = _('manual|Edit_Database_Owner_Information...')
config_keys = (
'researcher.researcher-name',
'researcher.researcher-addr',
'researcher.researcher-locality',
'researcher.researcher-city',
'researcher.researcher-state',
'researcher.researcher-country',
@ -122,14 +124,15 @@ class OwnerEditor(tool.Tool, ManagedWindow.ManagedWindow):
self.entries = []
entry = [
("entry1", self.owner.set_name, self.owner.get_name),
("entry2", self.owner.set_address, self.owner.get_address),
("entry3", self.owner.set_city, self.owner.get_city),
("entry4", self.owner.set_state, self.owner.get_state),
("entry5", self.owner.set_country, self.owner.get_country),
("entry6", self.owner.set_postal_code, self.owner.get_postal_code),
("entry7", self.owner.set_phone, self.owner.get_phone),
("entry8", self.owner.set_email, self.owner.get_email),
("name", self.owner.set_name, self.owner.get_name),
("address", self.owner.set_address, self.owner.get_address),
("locality", self.owner.set_locality, self.owner.get_locality),
("city", self.owner.set_city, self.owner.get_city),
("state", self.owner.set_state, self.owner.get_state),
("country", self.owner.set_country, self.owner.get_country),
("zip", self.owner.set_postal_code, self.owner.get_postal_code),
("phone", self.owner.set_phone, self.owner.get_phone),
("email", self.owner.set_email, self.owner.get_email),
]
for (name,set_fn,get_fn) in entry:

View File

@ -29,7 +29,7 @@
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="n_rows">8</property>
<property name="n_rows">9</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
@ -48,7 +48,7 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Address:</property>
<property name="label" translatable="yes">Street:</property>
</object>
<packing>
<property name="top_attach">1</property>
@ -64,8 +64,8 @@
<property name="label" translatable="yes">City:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -74,11 +74,11 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">State/Province:</property>
<property name="label" translatable="yes">State/County:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -90,8 +90,8 @@
<property name="label" translatable="yes">Country:</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -103,8 +103,8 @@
<property name="label" translatable="yes">ZIP/Postal Code:</property>
</object>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -116,8 +116,8 @@
<property name="label" translatable="yes">Phone:</property>
</object>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -129,14 +129,14 @@
<property name="label" translatable="yes">Email:</property>
</object>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry1">
<object class="GtkEntry" id="name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -148,7 +148,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry2">
<object class="GtkEntry" id="address">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -162,21 +162,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry4">
<object class="GtkEntry" id="city">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -190,7 +176,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry5">
<object class="GtkEntry" id="state">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -204,7 +190,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry6">
<object class="GtkEntry" id="country">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -218,7 +204,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry7">
<object class="GtkEntry" id="zip">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -232,7 +218,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="entry8">
<object class="GtkEntry" id="phone">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
@ -245,6 +231,47 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="email">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Locality:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="locality">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@ -69,11 +69,11 @@ class RepositoryView(ListView):
COL_TYPE = 2
COL_URL = 3
COL_STREET = 4
COL_ZIP = 5
COL_LOCALITY = 5
COL_CITY = 6
COL_COUNTY = 7
COL_STATE = 8
COL_COUNTRY = 9
COL_STATE = 7
COL_COUNTRY = 8
COL_ZIP = 9
COL_EMAIL = 10
COL_SURL = 11
COL_CHAN = 12
@ -84,11 +84,11 @@ class RepositoryView(ListView):
_('Type'),
_('Home URL'),
_('Street'),
_('ZIP/Postal Code'),
_('Locality'),
_('City'),
_('County'),
_('State'),
_('State/County'),
_('Country'),
_('ZIP/Postal Code'),
_('Email'),
_('Search URL'),
_('Last Changed'),
@ -97,11 +97,10 @@ class RepositoryView(ListView):
CONFIGSETTINGS = (
('columns.visible', [COL_NAME, COL_ID, COL_TYPE, COL_URL, COL_STREET,
]),
('columns.rank', [COL_NAME, COL_ID, COL_ZIP, COL_CITY, COL_TYPE,
COL_URL, COL_STREET, COL_COUNTY, COL_STATE,
COL_COUNTRY, COL_EMAIL, COL_SURL,
COL_CHAN]),
('columns.size', [200, 75, 100, 100, 100, 250, 100, 100, 100,
('columns.rank', [COL_NAME, COL_ID, COL_TYPE, COL_URL, COL_STREET,
COL_LOCALITY, COL_CITY, COL_STATE, COL_COUNTRY,
COL_ZIP, COL_EMAIL, COL_SURL, COL_CHAN]),
('columns.size', [200, 75, 100, 250, 100, 100, 100, 100, 100,
100, 100, 100, 100])
)
ADD_MSG = _("Add a new repository")