From e336e5ce224f527cc4cae40901e0a45e62811100 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 20 Apr 2008 13:36:28 +0000 Subject: [PATCH] Added check for invalid birth and death dates svn: r10605 --- src/plugins/Verify.py | 59 ++++++++++++++++++++++++++++++++++++++-- src/plugins/verify.glade | 23 +++++++++++++++- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/plugins/Verify.py b/src/plugins/Verify.py index d90caf68b..0c4d69d82 100644 --- a/src/plugins/Verify.py +++ b/src/plugins/Verify.py @@ -286,6 +286,8 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback): self.options.handler.options_dict['oldunm']) self.top.get_widget("estimate").set_active( self.options.handler.options_dict['estimate_age']) + self.top.get_widget("invdate").set_active( + self.options.handler.options_dict['invdate']) self.show() @@ -329,9 +331,9 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback): "oldunm").get_value_as_int() self.options.handler.options_dict['estimate_age'] = \ - self.top.get_widget( - "estimate").get_active() - + self.top.get_widget("estimate").get_active() + self.options.handler.options_dict['invdate'] = \ + self.top.get_widget("invdate").get_active() try: self.vr = VerifyResults(self.dbstate, self.uistate, self.track) self.add_results = self.vr.add_results @@ -380,6 +382,7 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback): lngwdw = self.options.handler.options_dict['lngwdw'] oldunm = self.options.handler.options_dict['oldunm'] estimate_age = self.options.handler.options_dict['estimate_age'] + invdate = self.options.handler.options_dict['invdate'] self.vr.real_model.clear() @@ -403,6 +406,8 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback): OldUnmarried(self.db,person, oldunm,estimate_age), TooManyChildren(self.db,person,mxchilddad,mxchildmom), Disconnected(self.db,person), + InvalidBirthDate(self.db,person,invdate), + InvalidDeathDate(self.db,person,invdate), ] for rule in rule_list: @@ -736,6 +741,7 @@ class VerifyOptions(Tool.ToolOptions): 'lngwdw' : 30, 'oldunm' : 99, 'estimate_age' : 0, + 'invdate' : 1, } self.options_help = { 'oldage' : ("=num","Maximum age","Age in years"), @@ -771,6 +777,9 @@ class VerifyOptions(Tool.ToolOptions): 'estimate_age' : ("=0/1","Whether to estimate missing dates", ["Do not estimate","Estimate dates"], True), + 'invdate' : ("=0/1","Whether to check for invalid dates" + "Do not identify invalid dates", + "Identify invalid dates", True), } #------------------------------------------------------------------------- @@ -1509,6 +1518,50 @@ class Disconnected(PersonRule): def get_message(self): return _("Disconnected individual") +class InvalidBirthDate(PersonRule): + ID = 29 + SEVERITY = Rule.ERROR + def __init__(self, db, person, invdate): + PersonRule.__init__(self, db, person) + self._invdate = invdate + + def broken(self): + if not self._invdate: return False # should we check? + # if so, let's get the birth date + person = self.obj + birth_ref = person.get_birth_ref() + if birth_ref: + birth_event = self.db.get_event_from_handle(birth_ref.ref) + birth_date = birth_event.get_date_object() + if birth_date and not birth_date.get_valid(): + return True + return False + + def get_message(self): + return _("Invalid birth date") + +class InvalidDeathDate(PersonRule): + ID = 30 + SEVERITY = Rule.ERROR + def __init__(self, db, person, invdate): + PersonRule.__init__(self, db, person) + self._invdate = invdate + + def broken(self): + if not self._invdate: return False # should we check? + # if so, let's get the death date + person = self.obj + death_ref = person.get_death_ref() + if death_ref: + death_event = self.db.get_event_from_handle(death_ref.ref) + death_date = death_event.get_date_object() + if death_date and not death_date.get_valid(): + return True + return False + + def get_message(self): + return _("Invalid death date") + #------------------------------------------------------------------------- # # diff --git a/src/plugins/verify.glade b/src/plugins/verify.glade index a32b43d58..38fca79ea 100644 --- a/src/plugins/verify.glade +++ b/src/plugins/verify.glade @@ -127,7 +127,7 @@ 12 True - 7 + 8 2 False 6 @@ -454,6 +454,27 @@ + + + + True + True + _Identify invalid dates + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 2 + 7 + 8 + + + False