Changeset 5505


Ignore:
Timestamp:
28 Aug 2010, 06:35:39 (14 years ago)
Author:
Henrik Bettermann
Message:

implement Phone Widget and apply to application, first_time_login and personal_edit student front end

Location:
WAeUP_SRP/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Widgets.py

    r5186 r5505  
    99##from Products.CPSSchemas.Widget import CPSWidgetType
    1010from Products.CMFCore.utils import getToolByName
    11 from Products.CPSSchemas.BasicWidgets import CPSBooleanWidget, CPSWidget, CPSStringWidget, CPSEmailWidget,CPSImageWidget
     11from Products.CPSSchemas.BasicWidgets import CPSBooleanWidget, CPSWidget, CPSStringWidget, CPSEmailWidget,CPSImageWidget,CPSIntWidget
    1212from Products.CPSSchemas.BasicWidgets import CPSFileWidget, CPSPasswordWidget
    1313from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget
     
    25532553###)
    25542554
     2555class PhoneWidget(CPSIntWidget): ###(
     2556    """ Phone Widget"""
     2557    meta_type = "Phone Widget"
     2558   
     2559    def validate(self, datastructure, **kw):
     2560        """Validate datastructure and update datamodel."""
     2561
     2562        valid = CPSIntWidget.validate(self, datastructure, **kw)
     2563        if not valid:
     2564            return 0
     2565        else:
     2566            widget_id = self.getWidgetId()
     2567            value = datastructure[widget_id]
     2568            #import pdb;pdb.set_trace()
     2569            if value == '234':
     2570                value = ''
     2571                datamodel = datastructure.getDataModel()
     2572                datamodel[self.fields[0]] = value
     2573            elif value.startswith('2340'):
     2574                err = 'Wrong Nigerian phone format'
     2575                datastructure.setError(widget_id, err)
     2576                return 0
     2577            return 1
     2578
     2579    def render(self, mode, datastructure, **kw):
     2580        """Render in mode from datastructure."""
     2581        value = datastructure[self.getWidgetId()]
     2582        #import pdb;pdb.set_trace()
     2583        if mode == 'view':
     2584            if value == '':
     2585                return ''
     2586            else:
     2587                return '+' + escape(value)
     2588        elif mode == 'edit':
     2589            if value == '':
     2590                value = 234
     2591            tag = renderHtmlTag('input',
     2592                                 type='text',
     2593                                 name=self.getHtmlWidgetId(),
     2594                                 value=value)
     2595            return '<strong>+</strong>' + tag
     2596        raise RuntimeError('unknown mode %s' % mode)
     2597
     2598
     2599InitializeClass(PhoneWidget)
     2600
     2601widgetRegistry.register(PhoneWidget)
     2602
     2603
     2604
     2605
    25552606###########
    25562607
  • WAeUP_SRP/trunk/profiles/default/layouts/application_cest.xml

    r5170 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_cest_2.xml

    r3791 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_ct.xml

    r4241 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_dp.xml

    r5185 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_manage.xml

    r5258 r5505  
    448448    <property name="allow_resize">True</property>
    449449  </widget>
    450   <widget name="phone" meta_type="String Widget">
     450  <widget name="phone" meta_type="Phone Widget">
    451451    <property name="title">Phone</property>
    452452    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_pce.xml

    r3689 r5505  
    284284  <property name="allow_resize">True</property>
    285285 </widget>
    286  <widget name="phone" meta_type="String Widget">
     286 <widget name="phone" meta_type="Phone Widget">
    287287  <property name="title">Phone</property>
    288288  <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_pde.xml

    r4553 r5505  
    489489    <property name="allow_resize">True</property>
    490490  </widget>
    491   <widget name="phone" meta_type="String Widget">
     491  <widget name="phone" meta_type="Phone Widget">
    492492    <property name="title">Phone</property>
    493493    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_prence.xml

    r3689 r5505  
    428428    <property name="allow_resize">True</property>
    429429  </widget>
    430   <widget name="phone" meta_type="String Widget">
     430  <widget name="phone" meta_type="Phone Widget">
    431431    <property name="title">Phone</property>
    432432    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_pt.xml

    r4241 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_pume.xml

    r5256 r5505  
    281281  <property name="allow_resize">True</property>
    282282 </widget>
    283  <widget name="phone" meta_type="String Widget">
     283 <widget name="phone" meta_type="Phone Widget">
    284284  <property name="title">Phone</property>
    285285  <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_pume2.xml

    r5279 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_sandwich.xml

    r5174 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/application_sandwich2008.xml

    r5165 r5505  
    329329    <property name="allow_resize">True</property>
    330330  </widget>
    331   <widget name="phone" meta_type="String Widget">
     331  <widget name="phone" meta_type="Phone Widget">
    332332    <property name="title">Phone</property>
    333333    <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/student_firsttime_login.xml

    r4034 r5505  
    7373  <property name="check_digit">True</property>
    7474 </widget>
    75  <widget name="phone_nr" meta_type="String Widget">
     75 <widget name="phone_nr" meta_type="Phone Widget">
    7676  <property name="title">Phone Number</property>
    7777  <property name="fields">
     
    8585  </property>
    8686  <property name="hidden_readonly_layout_modes"/>
    87   <property name="display_width">15</property>
    88   <property name="size_max">15</property>
    8987 </widget>
    9088 <widget name="repeat_password" meta_type="Password Widget">
  • WAeUP_SRP/trunk/profiles/uniben/layouts/student_personal_fe.xml

    r5065 r5505  
    230230  <property name="hidden_readonly_layout_modes"/>
    231231 </widget>
    232  <widget name="next_kin_phone" meta_type="String Widget">
     232 <widget name="next_kin_phone" meta_type="Phone Widget">
    233233  <property name="title">Next of Kin Phone</property>
    234234  <property name="fields">
     
    296296  <property name="hidden_readonly_layout_modes"/>
    297297 </widget>
    298  <widget name="phone" meta_type="String Widget">
     298 <widget name="phone" meta_type="Phone Widget">
    299299  <property name="title">Phone</property>
    300300  <property name="fields">
     
    423423  <property name="hidden_readonly_layout_modes"/>
    424424 </widget>
    425  <widget name="sponsor_phone" meta_type="String Widget">
     425 <widget name="sponsor_phone" meta_type="Phone Widget">
    426426  <property name="title">Sponsor Phone</property>
    427427  <property name="fields">
Note: See TracChangeset for help on using the changeset viewer.