changeset 198:7e3ed3eb9b99

Fix #71: problems with editing existing gcalendar dates; the date format wasn't what the datepicker expected.
author Brian Neal <bgneal@gmail.com>
date Sun, 11 Apr 2010 17:58:09 +0000
parents 2baadae33f2e
children 217119c87a06
files gpp/gcalendar/forms.py media/js/gcalendar.js
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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())