Changeset 3988 for WAeUP_SRP/trunk/patches
- Timestamp:
- 28 Feb 2009, 10:17:03 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/patches/PatchExtendedWidgetsCPSDateTimeWidget.py
r3673 r3988 10 10 field_id = self.fields[0] 11 11 widget_id = self.getWidgetId() 12 if datastructure.has_key(widget_id + '_date'): 13 date = datastructure[widget_id + '_date'].strip() 14 else: 15 date = datastructure[widget_id].strip() 16 if datastructure.has_key(widget_id + '_hour'): 17 hour = datastructure[widget_id + '_hour'].strip() 18 else: 19 hour = self.time_hour_default 20 if datastructure.has_key(widget_id + '_minute'): 21 minute = datastructure[widget_id + '_minute'].strip() 22 else: 23 minute = self.time_minutes_default 24 25 if not (date): 26 if self.is_required: 27 datastructure[widget_id] = '' 28 datastructure.setError(widget_id, 'cpsschemas_err_required') 29 return 0 30 else: 31 datamodel[field_id] = None 32 return 1 33 #import pdb;pdb.set_trace() 34 if self.view_format.startswith('iso8601'): 35 if re.match(r'^[0-9]+-[0-9]{2}-[0-9]{2}', date) is not None: 36 y, m, d = date.split('-') 37 else: 12 13 if self.view_format == 'import': 14 try: 15 dt = datastructure[widget_id].strip() 16 date,time,dummy = dt.split() 17 y,m,d = date.split('/') 18 hour,minute,second = time.split(':') 19 except: 38 20 datastructure.setError(widget_id, 'cpsschemas_err_date') 39 21 return 0 22 if not (date): 23 if self.is_required: 24 datastructure[widget_id] = '' 25 datastructure.setError(widget_id, 'cpsschemas_err_required') 26 return 0 27 else: 28 datamodel[field_id] = None 29 return 1 40 30 else: 41 if re.match(r'^[0-9]?[0-9][/,\-,\.][0-9]?[0-9][/,\-,\.][0-9]{2,4}$', date) is not None: 42 d, m, y = re.split(r'[/,\-,\.]',date) # always use d/m/y and use /,- or . as separator 43 #d, m, y = date.split('/') # always use d/m/y 44 # locale = self.translation_service.getSelectedLanguage() 45 # if False and locale in ('en', 'hu'): 46 # m, d, y = date.split('/') 47 # else: 31 if datastructure.has_key(widget_id + '_date'): 32 date = datastructure[widget_id + '_date'].strip() 48 33 else: 49 datastructure.setError(widget_id, 'cpsschemas_err_date') 50 return 0 34 date = datastructure[widget_id].strip() 35 if datastructure.has_key(widget_id + '_hour'): 36 hour = datastructure[widget_id + '_hour'].strip() 37 else: 38 hour = self.time_hour_default 39 if datastructure.has_key(widget_id + '_minute'): 40 minute = datastructure[widget_id + '_minute'].strip() 41 else: 42 minute = self.time_minutes_default 43 44 if not (date): 45 if self.is_required: 46 datastructure[widget_id] = '' 47 datastructure.setError(widget_id, 'cpsschemas_err_required') 48 return 0 49 else: 50 datamodel[field_id] = None 51 return 1 52 53 #import pdb;pdb.set_trace() 54 if self.view_format.startswith('iso8601'): 55 if re.match(r'^[0-9]+-[0-9]{2}-[0-9]{2}', date) is not None: 56 y, m, d = date.split('-') 57 else: 58 datastructure.setError(widget_id, 'cpsschemas_err_date') 59 return 0 60 else: 61 if re.match(r'^[0-9]?[0-9][/,\-,\.][0-9]?[0-9][/,\-,\.][0-9]{2,4}$', date) is not None: 62 d, m, y = re.split(r'[/,\-,\.]',date) # always use d/m/y and use /,- or . as separator 63 #d, m, y = date.split('/') # always use d/m/y 64 # locale = self.translation_service.getSelectedLanguage() 65 # if False and locale in ('en', 'hu'): 66 # m, d, y = date.split('/') 67 # else: 68 else: 69 datastructure.setError(widget_id, 'cpsschemas_err_date') 70 return 0 51 71 52 72 try:
Note: See TracChangeset for help on using the changeset viewer.