Mercurial > public > sg101
comparison gpp/gcalendar/forms.py @ 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 | 5b69d6e01fd4 |
children | d77e0dc772ad |
comparison
equal
deleted
inserted
replaced
197:2baadae33f2e | 198:7e3ed3eb9b99 |
---|---|
70 time_zone = forms.CharField(required=False, widget=forms.HiddenInput()) | 70 time_zone = forms.CharField(required=False, widget=forms.HiddenInput()) |
71 where = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': 60})) | 71 where = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': 60})) |
72 description = forms.CharField(required=False, | 72 description = forms.CharField(required=False, |
73 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) | 73 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) |
74 | 74 |
75 DATE_FORMAT = '%m/%d/%Y' # must match the jQuery UI datepicker config | |
75 TIME_FORMAT = '%H:%M' | 76 TIME_FORMAT = '%H:%M' |
76 DEFAULT_START_TIME = '19:00' | 77 DEFAULT_START_TIME = '19:00' |
77 DEFAULT_END_TIME = '20:00' | 78 DEFAULT_END_TIME = '20:00' |
78 | 79 |
79 class Meta: | 80 class Meta: |
95 initial = kwargs.get('initial', {}) | 96 initial = kwargs.get('initial', {}) |
96 instance = kwargs.get('instance', None) | 97 instance = kwargs.get('instance', None) |
97 | 98 |
98 if len(args) == 0: # no POST arguments | 99 if len(args) == 0: # no POST arguments |
99 if instance is None: | 100 if instance is None: |
100 init_day = datetime.date.today().strftime('%m/%d/%Y') | 101 init_day = datetime.date.today().strftime(self.DATE_FORMAT) |
101 if 'start_date' not in initial: | 102 if 'start_date' not in initial: |
102 initial['start_date'] = init_day | 103 initial['start_date'] = init_day |
103 if 'end_date' not in initial: | 104 if 'end_date' not in initial: |
104 initial['end_date'] = init_day | 105 initial['end_date'] = init_day |
105 if 'start_time' not in initial: | 106 if 'start_time' not in initial: |
106 initial['start_time'] = self.DEFAULT_START_TIME | 107 initial['start_time'] = self.DEFAULT_START_TIME |
107 if 'end_time' not in initial: | 108 if 'end_time' not in initial: |
108 initial['end_time'] = self.DEFAULT_END_TIME | 109 initial['end_time'] = self.DEFAULT_END_TIME |
109 else: | 110 else: |
111 initial['start_date'] = instance.start_date.strftime(self.DATE_FORMAT) | |
112 initial['end_date'] = instance.end_date.strftime(self.DATE_FORMAT) | |
110 if instance.all_day: | 113 if instance.all_day: |
111 initial['start_time'] = self.DEFAULT_START_TIME | 114 initial['start_time'] = self.DEFAULT_START_TIME |
112 initial['end_time'] = self.DEFAULT_END_TIME | 115 initial['end_time'] = self.DEFAULT_END_TIME |
113 else: | 116 else: |
114 if 'start_time' not in initial: | 117 if 'start_time' not in initial: |