* src/GenericFilter.py (HasAttribute.apply): Fix the rule.

(HasFamilyAttribute.apply): Fix the rule.
* src/Marriage.py (on_update_attr_clicked,on_add_attr_clicked):
Pass the window to the attribute editor.


svn: r4115
This commit is contained in:
Alex Roitman 2005-03-03 15:00:55 +00:00
parent b99f1b4019
commit 91bcc33a22
3 changed files with 32 additions and 21 deletions

View File

@ -1,3 +1,9 @@
2005-03-03 Alex Roitman <shura@alex.neuro.umn.edu>
* src/GenericFilter.py (HasAttribute.apply): Fix the rule.
(HasFamilyAttribute.apply): Fix the rule.
* src/Marriage.py (on_update_attr_clicked,on_add_attr_clicked):
Pass the window to the attribute editor.
2005-03-02 Don Allingham <dallingham@users.sourceforge.net> 2005-03-02 Don Allingham <dallingham@users.sourceforge.net>
* src/ChooseParents.py: use integers instead of strings for * src/ChooseParents.py: use integers instead of strings for
relationship types relationship types

View File

@ -1238,14 +1238,16 @@ class HasAttribute(Rule):
return 'Has the personal attribute' return 'Has the personal attribute'
def apply(self,db,p_id): def apply(self,db,p_id):
if not self.list[0]:
return 0
p = db.get_person_from_handle(p_id) p = db.get_person_from_handle(p_id)
for event in p.getAttributes(): for attr in p.get_attribute_list():
if self.list[0] and event.get_type() != self.list[0]: name_match = self.list[0] == attr.get_type()
return 0 value_match = self.list[1] and\
ev = event.get_value().upper() attr.get_value().upper().find(self.list[1].upper()) != -1
if self.list[1] and ev.find(self.list[1].upper())==-1: if name_match and value_match:
return 0 return 1
return 1 return 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -1261,17 +1263,16 @@ class HasFamilyAttribute(Rule):
return 'Has the family attribute' return 'Has the family attribute'
def apply(self,db,p_id): def apply(self,db,p_id):
if not self.list[0]:
return 0
p = db.get_person_from_handle(p_id) p = db.get_person_from_handle(p_id)
for f_id in p.get_family_handle_list(): for f_id in p.get_family_handle_list():
f = db.get_family_from_handle(f_id) f = db.get_family_from_handle(f_id)
for event in f.getAttributes(): for attr in f.get_attribute_list():
val = 1 name_match = self.list[0] == attr.get_type()
if self.list[0] and event.get_type() != self.list[0]: value_match = self.list[1] and\
val = 0 attr.get_value().upper().find(self.list[1].upper()) != -1
ev = event.get_value().upper() if name_match and value_match:
if self.list[1] and ev.find(self.list[1].upper())==-1:
val = 0
if val == 1:
return 1 return 1
return 0 return 0

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2004 Donald N. Allingham # Copyright (C) 2000-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modiy # This program is free software; you can redistribute it and/or modiy
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -20,8 +20,13 @@
# $Id$ # $Id$
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import pickle import pickle
import string from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -51,7 +56,6 @@ import GrampsKeys
import NameDisplay import NameDisplay
from QuestionDialog import QuestionDialog, WarningDialog, SaveDialog from QuestionDialog import QuestionDialog, WarningDialog, SaveDialog
from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -778,7 +782,7 @@ class Marriage:
name = NameDisplay.displayer.display(mother) name = NameDisplay.displayer.display(mother)
AttrEdit.AttributeEditor( AttrEdit.AttributeEditor(
self, attr, name, const.familyAttributes, self, attr, name, const.familyAttributes,
self.attr_edit_callback, self.update_sources) self.attr_edit_callback, self.window, self.update_sources)
def on_delete_attr_clicked(self,obj): def on_delete_attr_clicked(self,obj):
if Utils.delete_selected(obj,self.alist): if Utils.delete_selected(obj,self.alist):
@ -801,7 +805,7 @@ class Marriage:
name = NameDisplay.displayer.display(mother) name = NameDisplay.displayer.display(mother)
AttrEdit.AttributeEditor( AttrEdit.AttributeEditor(
self, None, name, const.familyAttributes, self, None, name, const.familyAttributes,
self.attr_edit_callback, self.update_sources) self.attr_edit_callback, self.window, self.update_sources)
def move_element(self,list,src,dest): def move_element(self,list,src,dest):
if src == -1: if src == -1:
@ -832,7 +836,7 @@ class Marriage:
def get_place(self,makenew,trans=None): def get_place(self,makenew,trans=None):
field = self.lds_place.child field = self.lds_place.child
text = string.strip(unicode(field.get_text())) text = unicode(field.get_text()).strip()
if text: if text:
if self.pmap.has_key(text): if self.pmap.has_key(text):
return self.db.get_place_from_handle(self.pmap[text]) return self.db.get_place_from_handle(self.pmap[text])