4383: Error while attempt to edit family
2521: Problem with erroneous birth date in using the family editor. We show validation error on date > next year, and don't crash on large year anymore svn: r16468
This commit is contained in:
parent
db30ca661f
commit
c2e353a72b
@ -62,7 +62,7 @@ import gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import sgettext as _
|
||||
from gen.lib import Date
|
||||
from gen.lib.date import Date, NextYear
|
||||
import DateHandler
|
||||
import const
|
||||
import GrampsDisplay
|
||||
@ -150,6 +150,9 @@ class DateEdit(object):
|
||||
# if text could not be parsed it is assumed invalid
|
||||
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
||||
return ValidationError(_('Bad Date'))
|
||||
elif (self.date_obj.to_calendar(calendar_name=Date.CAL_GREGORIAN) >
|
||||
NextYear()):
|
||||
return ValidationError(_('Date more than one year in the future'))
|
||||
|
||||
def invoke_date_editor(self, obj):
|
||||
"""
|
||||
|
@ -1742,6 +1742,16 @@ def Today():
|
||||
current_date.set_yr_mon_day(*time.localtime(time.time())[0:3])
|
||||
return current_date
|
||||
|
||||
def NextYear():
|
||||
"""
|
||||
Returns a Date object set to next year
|
||||
"""
|
||||
import time
|
||||
next_year = Date()
|
||||
thisyear = time.localtime(time.time())
|
||||
next_year.set_yr_mon_day(thisyear[0]+1, thisyear[1], thisyear[3])
|
||||
return next_year
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Date Functions
|
||||
|
@ -51,7 +51,7 @@ class ChildModel(gtk.ListStore):
|
||||
def __init__(self, family, db):
|
||||
self.family = family
|
||||
gtk.ListStore.__init__(self, int, str, str, str, str, str,
|
||||
str, str, str, str, str, str, int, int)
|
||||
str, str, str, str, str, str, str, str)
|
||||
self.db = db
|
||||
index = 1
|
||||
for child_ref in self.get_data():
|
||||
@ -89,12 +89,18 @@ class ChildModel(gtk.ListStore):
|
||||
return u""
|
||||
|
||||
def column_birth_sort(self, data):
|
||||
"""
|
||||
Return a sort key to use for the birth column.
|
||||
As python int can be larger than C int, we cast int
|
||||
to a string of 10 long prepended with 0 as needed.
|
||||
This gives correct string sort for years in the millenia around today
|
||||
"""
|
||||
event_ref = data.get_birth_ref()
|
||||
if event_ref and event_ref.ref:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
return event.get_date_object().get_sort_value()
|
||||
return '%012d' % event.get_date_object().get_sort_value()
|
||||
else:
|
||||
return 0
|
||||
return '%012d' % 0
|
||||
|
||||
def column_death_day(self, data):
|
||||
event_ref = data.get_death_ref()
|
||||
@ -105,12 +111,18 @@ class ChildModel(gtk.ListStore):
|
||||
return u""
|
||||
|
||||
def column_death_sort(self, data):
|
||||
"""
|
||||
Return a sort key to use for the death column.
|
||||
As python int can be larger than C int, we cast int
|
||||
to a string of 10 long prepended with 0 as needed.
|
||||
This gives correct string sort for years in the millenia around today
|
||||
"""
|
||||
event_ref = data.get_death_ref()
|
||||
if event_ref and event_ref.ref:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
return event.get_date_object().get_sort_value()
|
||||
return '%012d' % event.get_date_object().get_sort_value()
|
||||
else:
|
||||
return 0
|
||||
return '%012d' % 0
|
||||
|
||||
def column_birth_place(self, data):
|
||||
event_ref = data.get_birth_ref()
|
||||
|
Loading…
Reference in New Issue
Block a user