diff --git a/src/data/templates/view_event_detail.html b/src/data/templates/view_event_detail.html index e61425af0..ef7a873d3 100644 --- a/src/data/templates/view_event_detail.html +++ b/src/data/templates/view_event_detail.html @@ -27,8 +27,8 @@ {{eventform.event_type.label}}: {% render eventform.event_type user action %} -Date: -{% render eventform.date user action %} +{{eventform.text.label}}: +{% render eventform.text user action %} Description: diff --git a/src/webapp/grampsdb/forms.py b/src/webapp/grampsdb/forms.py index 9b9714ca0..f945013df 100644 --- a/src/webapp/grampsdb/forms.py +++ b/src/webapp/grampsdb/forms.py @@ -133,31 +133,14 @@ class EventForm(forms.ModelForm): exclude = ["handle", "sortval", "month1", "year1", "day1", "newyear", "calendar", "modifier", "quality"] - def __init__(self, *args, **kwargs): - from webapp.utils import display_date - super(EventForm, self).__init__(*args, **kwargs) - - # Set the form fields based on the model object - if kwargs.has_key('instance'): - instance = kwargs['instance'] - sdate = display_date(instance) - if sdate != "0000-00-00": - self.initial['date'] = sdate - try: - self.data['date'] = self.initial['date'] - except: - pass - def clean(self): from webapp.utils import dp data = super(EventForm, self).clean() - dobj = dp(data.get('date')) + dobj = dp(data.get('text')) if not dobj.is_valid(): msg = u"Invalid date format" self._errors["date"] = self.error_class([msg]) - del data["date"] - else: - data["date"] = str(dobj) + del data["text"] return data def save(self, commit=True): @@ -165,12 +148,12 @@ class EventForm(forms.ModelForm): from webapp.libdjango import DjangoInterface dji = DjangoInterface() model = super(EventForm, self).save(commit=False) - dobj = dp(self.cleaned_data['date']) + dobj = dp(self.cleaned_data['text']) dji.add_date(model, dobj.serialize()) if commit: model.save() return model - date = forms.CharField(label="Date", + text = forms.CharField(label="Date", required=False, - widget=TextInput(attrs={'size':'30'})) + widget=TextInput(attrs={'size':'45'})) diff --git a/src/webapp/grampsdb/view/event.py b/src/webapp/grampsdb/view/event.py index bd0c1e101..f24475f80 100644 --- a/src/webapp/grampsdb/view/event.py +++ b/src/webapp/grampsdb/view/event.py @@ -26,7 +26,7 @@ from webapp.utils import _, boolean, update_last_changed from webapp.grampsdb.models import Event from webapp.grampsdb.forms import * from webapp.libdjango import DjangoInterface -import DateHandler +from gen.datehandler import displayer, parser ## Django Modules from django.shortcuts import get_object_or_404, render_to_response, redirect @@ -34,8 +34,8 @@ from django.template import Context, RequestContext ## Globals dji = DjangoInterface() -dd = DateHandler.displayer.display -dp = DateHandler.parser.parse +dd = displayer.display +dp = parser.parse def process_event(request, context, handle, action): # view, edit, save """ diff --git a/src/webapp/shell.py b/src/webapp/shell.py index dbee5f964..1a2749ade 100644 --- a/src/webapp/shell.py +++ b/src/webapp/shell.py @@ -11,13 +11,12 @@ from webapp.grampsdb.forms import * from webapp.dbdjango import DbDjango from webapp.reports import import_file from webapp.libdjango import DjangoInterface, totime, todate - -import DateHandler +from gen.datehandler import displayer, parser db = DbDjango() dji = DjangoInterface() -dd = DateHandler.displayer.display -dp = DateHandler.parser.parse +dd = displayer.display +dp = parser.parse #def Print(m): # print m diff --git a/src/webapp/utils.py b/src/webapp/utils.py index 7741a0232..641d65b11 100644 --- a/src/webapp/utils.py +++ b/src/webapp/utils.py @@ -56,7 +56,7 @@ from webapp.dbdjango import DbDjango from Simple import SimpleTable, SimpleAccess, make_basic_stylesheet import Utils import DbState -import gen.datehandler +from gen.datehandler import displayer, parser from gen.lib.date import Date as GDate, Today import gen.lib from gen.utils import get_birth_or_fallback, get_death_or_fallback @@ -97,8 +97,8 @@ util_tags = [ # #------------------------------------------------------------------------ dji = libdjango.DjangoInterface() -dd = DateHandler.displayer.display -dp = DateHandler.parser.parse +dd = displayer.display +dp = parser.parse db = DbDjango() def register_plugins():