Changeset 204 for waeup_product/trunk/Widgets.py
- Timestamp:
- 16 May 2006, 12:50:17 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup_product/trunk/Widgets.py
r199 r204 55 55 """ ScratchcardPin Widget""" 56 56 meta_type = "Scratchcard Pin Widget" 57 valid_pins = ['123456 ',58 '234567 ',59 '345678 ',60 '456789 ',57 valid_pins = ['12345678', 58 '23456789', 59 '34567890', 60 '45678901', 61 61 ] 62 62 … … 71 71 value = datastructure[widget_id] 72 72 err = 0 73 #import pdb; pdb.set_trace() 73 74 if not value in self.valid_pins: 74 75 err = 'invalid Pin' … … 83 84 widgetRegistry.register(ScratchcardPinWidget) 84 85 85 ##class ScratchcardPinWidgetType(CPSWidgetType):86 ## """Scratchcard Pin widget type."""87 ## meta_type = "Scratchcard Pin Widget Type"88 ## cls = ScratchcardPinWidget89 86 90 87 ###) … … 92 89 ########### 93 90 94 ##WidgetTypeRegistry.register(StudentIdWidgetType)95 ##WidgetTypeRegistry.register(ScratchcardPinWidgetType)96 97 ##class MyProjectWeekDateTimeWidget(CPSDateTimeWidget): ###(98 ## """ """99 ## meta_type = "MyProject Week Date Time Widget"100 ##101 ## def validate(self, datastructure, **kw):102 ## """Validate datastructure and update datamodel."""103 ##104 ## valid = CPSDateTimeWidget.validate(self, datastructure, **kw)105 ## if not valid:106 ## return 0107 ## else:108 ## widget_id = self.getWidgetId()109 ## value = datastructure[widget_id]110 ## err = 0111 ## if value.dow() in (6, 0):112 ## err = 'Cette date ne correspond pas à un jour de semaine'113 ##114 ## if err:115 ## datastructure.setError(widget_id, err)116 ##117 ## return not err118 ##119 ##InitializeClass(MyProjectWeekDateTimeWidget)120 121 ##class MyProjectWeekDateTimeWidgetType(CPSWidgetType):122 ## """MyProject Week DateTime widget type."""123 ## meta_type = "MyProject Week Date Time Widget Type"124 ## cls = MyProjectWeekDateTimeWidget125 ##126 ##InitializeClass(MyProjectWeekDateTimeWidgetType)127 ##class MyProjectRestrictedStringWidget(CPSStringWidget):128 ## """ """129 ## meta_type = "MyProject Restricted String Widget"130 ##131 ## def validate(self, datastructure, **kw):132 ## """Validate datastructure and update datamodel."""133 ##134 ## valid = CPSStringWidget.validate(self, datastructure, **kw)135 ## if not valid:136 ## return 0137 ## else:138 ## widget_id = self.getWidgetId()139 ## value = datastructure[widget_id]140 ## err = 0141 ## if not (len(value) == 5 and value.isupper() and value.isalpha()):142 ## err = 'Cette chaîne ne correspond pas au format imposé'143 ##144 ## if err:145 ## datastructure.setError(widget_id, err)146 ## else:147 ## datamodel = datastructure.getDataModel()148 ## datamodel[self.fields[0]] = value149 ##150 ## return not err151 ##152 ##InitializeClass(MyProjectRestrictedStringWidget)153 ##154 ##class MyProjectRestrictedStringWidgetType(CPSWidgetType):155 ## """MyProject Restricted String widget type."""156 ## meta_type = "MyProject Restricted String Widget Type"157 ## cls = MyProjectRestrictedStringWidget158 ##159 ##InitializeClass(MyProjectRestrictedStringWidgetType)160 ##161 ##162 ##class MyProjectRestrictedEmailWidget(CPSEmailWidget):163 ## """ """164 ## meta_type = "MyProject Restricted Email Widget"165 ##166 ## email_myproject_pat = compile(r"^([-\w_+])+\.([-\w_+])+@myproject\.fr$")167 ##168 ## def validate(self, datastructure, **kw):169 ## """Validate datastructure and update datamodel."""170 ##171 ## valid = CPSEmailWidget.validate(self, datastructure, **kw)172 ## if not valid:173 ## return 0174 ## else:175 ## widget_id = self.getWidgetId()176 ## err, v = self._extractValue(datastructure[widget_id])177 ## LOG('MyProject: MyProjectWidgets.py', DEBUG, "Valeur de v : %s" % v)178 ## if not err and kw.get('layout_mode') != 'search' and \179 ## v and not self.email_myproject_pat.match(v):180 ## err = 'cpsschemas_err_email'181 ##182 ## if err:183 ## datastructure.setError(widget_id, err)184 ## else:185 ## datamodel = datastructure.getDataModel()186 ## datamodel[self.fields[0]] = v187 ##188 ## return not err189 ##190 ## def render(self, mode, datastructure, **kw):191 ## """Render in mode from datastructure."""192 ## return CPSStringWidget.render(self, mode, datastructure, **kw)193 ##194 ##InitializeClass(MyProjectRestrictedEmailWidget)195 ##196 ##class MyProjectRestrictedEmailWidgetType(CPSWidgetType):197 ## """MyProject Restricted String widget type."""198 ## meta_type = "MyProject Restricted Email Widget Type"199 ## cls = MyProjectRestrictedEmailWidget200 ##201 ##InitializeClass(MyProjectRestrictedEmailWidgetType)202 ##203 ##class MyProjectVisitTitleWidget(CPSStringWidget):204 ## """ """205 ## meta_type = "MyProject Visit Title Widget"206 ##207 ## def validate(self, datastructure, **kw):208 ## """Validate datastructure and update datamodel."""209 ##210 ## widget_id = self.getWidgetId()211 ## err = 0212 ## curr_date = DateTime()213 ## date = "%d.%d.%d" % (curr_date.day(), curr_date.month(), curr_date.year())214 ## user = getSecurityManager().getUser()215 ## value = 'Demande de visite du %s par %s' % (date,216 ## self.portal_directories.members.getEntry(user.getId()).get('fullname'))217 ## datamodel = datastructure.getDataModel()218 ## datamodel[self.fields[0]] = value219 ##220 ## return not err221 ##222 ## def render(self, mode, datastructure, **kw):223 ## return ''224 ##225 ##InitializeClass(MyProjectVisitTitleWidget)226 ##227 ##class MyProjectVisitTitleWidgetType(CPSWidgetType):228 ## """MyProject Visit Title widget type."""229 ## meta_type = "MyProject Visit Title Widget Type"230 ## cls = MyProjectVisitTitleWidget231 ##232 ##InitializeClass(MyProjectVisitTitleWidgetType)233 234 #####################################################################################235 236 ##WidgetTypeRegistry.register(MyProjectWeekDateTimeWidgetType)237 ##WidgetTypeRegistry.register(MyProjectRestrictedStringWidgetType)238 ##WidgetTypeRegistry.register(MyProjectRestrictedEmailWidgetType)239 ##WidgetTypeRegistry.register(MyProjectVisitTitleWidgetType)240 ##241 242 ###)
Note: See TracChangeset for help on using the changeset viewer.