# HG changeset patch # User Brian Neal # Date 1271008689 0 # Node ID 7e3ed3eb9b990b33411b147776fbd951bafd74cc # Parent 2baadae33f2eafb307cda307dca205ff2666deb4 Fix #71: problems with editing existing gcalendar dates; the date format wasn't what the datepicker expected. diff -r 2baadae33f2e -r 7e3ed3eb9b99 gpp/gcalendar/forms.py --- a/gpp/gcalendar/forms.py Sat Apr 10 04:32:24 2010 +0000 +++ b/gpp/gcalendar/forms.py Sun Apr 11 17:58:09 2010 +0000 @@ -72,6 +72,7 @@ description = forms.CharField(required=False, widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) + DATE_FORMAT = '%m/%d/%Y' # must match the jQuery UI datepicker config TIME_FORMAT = '%H:%M' DEFAULT_START_TIME = '19:00' DEFAULT_END_TIME = '20:00' @@ -97,7 +98,7 @@ if len(args) == 0: # no POST arguments if instance is None: - init_day = datetime.date.today().strftime('%m/%d/%Y') + init_day = datetime.date.today().strftime(self.DATE_FORMAT) if 'start_date' not in initial: initial['start_date'] = init_day if 'end_date' not in initial: @@ -107,6 +108,8 @@ if 'end_time' not in initial: initial['end_time'] = self.DEFAULT_END_TIME else: + initial['start_date'] = instance.start_date.strftime(self.DATE_FORMAT) + initial['end_date'] = instance.end_date.strftime(self.DATE_FORMAT) if instance.all_day: initial['start_time'] = self.DEFAULT_START_TIME initial['end_time'] = self.DEFAULT_END_TIME diff -r 2baadae33f2e -r 7e3ed3eb9b99 media/js/gcalendar.js --- a/media/js/gcalendar.js Sat Apr 10 04:32:24 2010 +0000 +++ b/media/js/gcalendar.js Sun Apr 11 17:58:09 2010 +0000 @@ -1,6 +1,6 @@ $(document).ready(function() { $('#id_start_date').datepicker({constrainInput: true, - dateFormat: 'yy-mm-dd', + dateFormat: 'mm/dd/yy', onClose: function () { var end = $('#id_end_date'); if (this.value > end.val()) @@ -10,7 +10,7 @@ } }); $('#id_end_date').datepicker({constrainInput: true, - dateFormat: 'yy-mm-dd', + dateFormat: 'mm/dd/yy', onClose: function () { var start = $('#id_start_date'); if (this.value < start.val())