From 492971412e2b45762fc3f886cbf6c5a1b33cfc90 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 22 May 2003 03:37:33 +0000 Subject: [PATCH] Warning if non-date text is entered into date fields svn: r1571 --- gramps2/src/EditPerson.py | 29 ++++++++++++++++++++++++++++- gramps2/src/EventEdit.py | 13 +++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index c1dccff43..531266b62 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2003 Donald N. Allingham # # 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 @@ -53,6 +53,7 @@ import ListModel import RelLib from DateEdit import DateEdit from QuestionDialog import QuestionDialog, WarningDialog, ErrorDialog, SaveDialog +from Calendar import UNDEF from intl import gettext as _ @@ -1286,6 +1287,19 @@ class EditPerson: self.pmap[p[0]] = key self.birth.setDate(self.bdate.get_text()) + if self.birth.getDateObj().start.year == UNDEF: + if self.birth.getDateObj().start.month == UNDEF: + if self.birth.getDateObj().start.day == UNDEF: + if self.bdate.get_text(): + WarningDialog(_("Unrecognized date"), + _('The text "%s" you have entered into the date ' + 'field did not match any known date format and will ' + 'not be recorded.\n\n' + 'If you want to store textual description of this ' + 'date (such as "during War"), ' + 'click Edit... button and then ' + 'use the Note tab instead of the Date field.') + % self.bdate.get_text() ) self.birth.setPlace(self.get_place(self.bplace,1)) if not self.person.getBirth().are_equal(self.birth): @@ -1303,6 +1317,19 @@ class EditPerson: family.setChildList(new_order) self.death.setDate(self.ddate.get_text()) + if self.death.getDateObj().start.year == UNDEF: + if self.death.getDateObj().start.month == UNDEF: + if self.death.getDateObj().start.day == UNDEF: + if self.ddate.get_text(): + WarningDialog(_("Unrecognized date"), + _('The text "%s" you have entered into the date ' + 'field did not match any known date format and will ' + 'not be recorded.\n\n' + 'If you want to store textual description of this ' + 'date (such as "during War"), ' + 'click Edit... button and then ' + 'use the Note tab instead of the Date field.') + % self.ddate.get_text() ) self.death.setPlace(self.get_place(self.dplace,1)) if not self.person.getDeath().are_equal(self.death): diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index d2e9193de..ca3ecabd4 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -46,6 +46,7 @@ import Date from DateEdit import DateEdit from intl import gettext as _ +from QuestionDialog import WarningDialog #------------------------------------------------------------------------- # # EventEditor class @@ -203,6 +204,18 @@ class EventEditor: ename = self.name_field.get_text() self.date.set(self.date_field.get_text()) + if self.date.start.year == Calendar.UNDEF: + if self.date.start.month == Calendar.UNDEF: + if self.date.start.day == Calendar.UNDEF: + if self.date_field.get_text(): + WarningDialog(_("Unrecognized date"), + _('The text "%s" you have entered into the date ' + 'field did not match any known date format and will ' + 'not be recorded.\n\n' + 'If you want to store textual description of this ' + 'date (such as "during War"), ' + 'use the Note tab instead of the Date field.') + % self.date_field.get_text() ) ecause = self.cause_field.get_text() eplace_obj = self.get_place(self.place_field,1) buf = self.note_field.get_buffer()