* src/ChooseParents.py: build an exclusion list of those

obviously not the parents
* src/EditPerson.py: allow ID value to be edited
* src/RelLib.py: Add try_to_find_from_gramps_id
* src/ImageSelect.py: catch OSError


svn: r3253
This commit is contained in:
Don Allingham 2004-07-09 04:31:43 +00:00
parent 3c108b27b7
commit 1333c80f7f
5 changed files with 46 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2004-07-08 Don Allingham <dallingham@users.sourceforge.net>
* src/ChooseParents.py: build an exclusion list of those
obviously not the parents
* src/EditPerson.py: allow ID value to be edited
* src/RelLib.py: Add try_to_find_from_gramps_id
* src/ImageSelect.py: catch OSError
2004-07-02 Alex Roitman <shura@alex.neuro.umn.edu> 2004-07-02 Alex Roitman <shura@alex.neuro.umn.edu>
* src/DbPrompter.py (SaveAsDbPrompter.change_suggested_name): * src/DbPrompter.py (SaveAsDbPrompter.change_suggested_name):
Add method; (SaveAsDbPrompter.chooser): Make dialog a class attribute. Add method; (SaveAsDbPrompter.chooser): Make dialog a class attribute.

View File

@ -118,7 +118,8 @@ class ChooseParents:
self.glade = gtk.glade.XML(const.gladeFile,"familyDialog","gramps") self.glade = gtk.glade.XML(const.gladeFile,"familyDialog","gramps")
self.top = self.glade.get_widget("familyDialog") self.top = self.glade.get_widget("familyDialog")
self.title_text = _("Choose the Parents of %s") % GrampsCfg.nameof(self.person) self.title_text = _("Choose the Parents of %s") % \
GrampsCfg.nameof(self.person)
Utils.set_titles(self.top,self.glade.get_widget('title'), Utils.set_titles(self.top,self.glade.get_widget('title'),
self.title_text,_('Choose Parents')) self.title_text,_('Choose Parents'))
@ -249,14 +250,20 @@ class ChooseParents:
def likely_father_filter(self,person): def likely_father_filter(self,person):
if person.get_gender() != RelLib.Person.male: if person.get_gender() != RelLib.Person.male:
return 0 return 0
if self.exclude.has_key(person.get_id()):
return 0
return self.likely_filter(person) return self.likely_filter(person)
def likely_mother_filter(self,person): def likely_mother_filter(self,person):
if person.get_gender() != RelLib.Person.female: if person.get_gender() != RelLib.Person.female:
return 0 return 0
if self.exclude.has_key(person.get_id()):
return 0
return self.likely_filter(person) return self.likely_filter(person)
def likely_filter(self,person): def likely_filter(self,person):
if person.get_id() == self.person.get_id():
return 0
birth_event = self.db.find_event_from_id(person.get_birth_id()) birth_event = self.db.find_event_from_id(person.get_birth_id())
if birth_event: if birth_event:
pbday = birth_event.get_date_object() pbday = birth_event.get_date_object()
@ -296,12 +303,22 @@ class ChooseParents:
return 0 return 0
return 1 return 1
def build_exclude_list(self):
self.exclude = { self.person.get_id() : 1 }
for family_id in self.person.get_family_id_list():
fam = self.db.find_family_from_id(family_id)
for id in [fam.get_father_id(), fam.get_mother_id()] + \
fam.get_child_id_list():
if id:
self.exclude[id] = 1
def redrawf(self): def redrawf(self):
"""Redraws the potential father list""" """Redraws the potential father list"""
self.father_nsort = PeopleModel.PeopleModel(self.db) self.father_nsort = PeopleModel.PeopleModel(self.db)
self.father_nsort.rebuild_data() self.father_nsort.rebuild_data()
self.father_nsort.reset_visible() self.father_nsort.reset_visible()
self.build_exclude_list()
for pid in self.db.get_person_keys(): for pid in self.db.get_person_keys():
person = self.db.try_to_find_person_from_id(pid) person = self.db.try_to_find_person_from_id(pid)
visible = self.father_filter(person) visible = self.father_filter(person)
@ -323,6 +340,7 @@ class ChooseParents:
self.mother_nsort = PeopleModel.PeopleModel(self.db) self.mother_nsort = PeopleModel.PeopleModel(self.db)
self.mother_nsort.rebuild_data() self.mother_nsort.rebuild_data()
self.mother_nsort.reset_visible() self.mother_nsort.reset_visible()
self.build_exclude_list()
for pid in self.db.get_person_keys(): for pid in self.db.get_person_keys():
person = self.db.try_to_find_person_from_id(pid) person = self.db.try_to_find_person_from_id(pid)

View File

@ -289,7 +289,7 @@ class EditPerson:
build_dropdown(self.surname,self.db.get_surnames()) build_dropdown(self.surname,self.db.get_surnames())
self.gid.set_text(person.get_gramps_id()) self.gid.set_text(person.get_gramps_id())
self.gid.set_editable(GrampsCfg.id_edit) self.gid.set_editable(1)
self.lds_baptism = RelLib.LdsOrd(self.person.get_lds_baptism()) self.lds_baptism = RelLib.LdsOrd(self.person.get_lds_baptism())
self.lds_endowment = RelLib.LdsOrd(self.person.get_lds_endowment()) self.lds_endowment = RelLib.LdsOrd(self.person.get_lds_endowment())
@ -1450,14 +1450,11 @@ class EditPerson:
self.birth.set_place_id(self.get_place(self.bplace,1)) self.birth.set_place_id(self.get_place(self.bplace,1))
if idval != self.person.get_gramps_id(): if idval != self.person.get_gramps_id():
m = self.db.get_person_keys() person = self.db.try_to_find_person_from_gramps_id(idval)
if not m.has_key(idval): if not person:
if m.has_key(self.person.get_gramps_id()):
del m[self.person.get_gramps_id()]
m[idval] = self.person
self.person.set_gramps_id(idval) self.person.set_gramps_id(idval)
else: else:
n = GrampsCfg.nameof(m[idval]) n = GrampsCfg.nameof(person)
msg1 = _("GRAMPS ID value was not changed.") msg1 = _("GRAMPS ID value was not changed.")
msg2 = _("You have attempted to change the GRAMPS ID to a value " msg2 = _("You have attempted to change the GRAMPS ID to a value "
"of %(grampsid)s. This value is already used by %(person)s.") % { "of %(grampsid)s. This value is already used by %(person)s.") % {

View File

@ -492,7 +492,7 @@ class Gallery(ImageSelect):
u = urllib.URLopener() u = urllib.URLopener()
try: try:
tfile,headers = u.retrieve(d) tfile,headers = u.retrieve(d)
except IOError, msg: except (IOError,OSError), msg:
t = _("Could not import %s") % d t = _("Could not import %s") % d
ErrorDialog(t,str(msg)) ErrorDialog(t,str(msg))
return return
@ -1233,3 +1233,4 @@ class DeleteMediaQuery:
self.db.add_transaction(trans,_("Remove Media Object")) self.db.add_transaction(trans,_("Remove Media Object"))
if self.update: if self.update:
self.update() self.update()

View File

@ -1196,7 +1196,7 @@ class Person(SourceNote):
self.urls, self.urls,
self.lds_bapt, self.lds_endow, self.lds_seal, self.lds_bapt, self.lds_endow, self.lds_seal,
self.complete, self.source_list, self.note) = data self.complete, self.source_list, self.note) = data
def set_complete(self,val): def set_complete(self,val):
self.complete = val self.complete = val
@ -2984,6 +2984,18 @@ class GrampsDB:
else: else:
return None return None
def try_to_find_person_from_gramps_id(self,val):
"""finds a Person in the database from the passed gramps' ID.
If no such Person exists, a new Person is added to the database."""
data = self.idtrans.get(str(val))
if data:
person = Person()
person.unserialize(cPickle.loads(data))
return person
else:
return None
def find_person_from_gramps_id(self,val,trans): def find_person_from_gramps_id(self,val,trans):
"""finds a Person in the database from the passed gramps' ID. """finds a Person in the database from the passed gramps' ID.
If no such Person exists, a new Person is added to the database.""" If no such Person exists, a new Person is added to the database."""