Changeset 1175


Ignore:
Timestamp:
2 Jan 2007, 11:37:44 (18 years ago)
Author:
joachim
Message:

added Secret Widget and use it in display_session_results
if application object is present, don't ask for password again.

Location:
WAeUP_SRP/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Widgets.py

    r1169 r1175  
    141141widgetRegistry.register(CertificateCourseIdWidget)
    142142###)
    143 
    144143
    145144class CourseIdWidget(CPSStringWidget): ###(
     
    366365###)
    367366
     367class SecretWidget(CPSStringWidget): ###(
     368    """ Secret Widget"""
     369    meta_type = "Secret Widget"
     370    _properties = CPSStringWidget._properties + (
     371        {'id': 'reference', 'type': 'string', 'mode': 'w',
     372         'label': 'Reference Record'},
     373         {'id': 'check_fields', 'type': 'tokens', 'mode': 'w',
     374         'label': 'Fields to check'},
     375         )
     376    reference = "student"
     377    check_fields = ("Firstname", "Middlename","Lastname")
     378    def validate(self, datastructure, **kw):
     379        """Validate datastructure and update datamodel."""
     380        logger = logging.getLogger('Secret.Validate')
     381        valid = CPSStringWidget.validate(self, datastructure, **kw)
     382        #import pdb;pdb.set_trace()
     383        widget_id = self.getWidgetId()
     384        value = datastructure[widget_id].upper()
     385        err = 0
     386        if not valid:
     387            err = 'Invalid String'
     388        else:
     389            #import pdb;pdb.set_trace()
     390            record = datastructure[self.reference]
     391            found = False
     392            cvs = []
     393            for field in self.check_fields:
     394                cv = getattr(record,field).upper()
     395                cvs.append(cv)
     396                if cv  == value.upper():
     397                    found = True
     398                    break
     399            matric_no = record.matric_no
     400            name = " ".join(cvs)
     401            if not found:
     402                logger.info('"%(matric_no)s","mismatch", "%(value)s", "not in","%(name)s"' % vars())
     403                err = 'No Name does match.'
     404            else:
     405                logger.info('"%(matric_no)s","found", "%(value)s", "in","%(name)s"' % vars())
     406        if err:
     407            datastructure.setError(widget_id, err)
     408        else:
     409            datamodel = datastructure.getDataModel()
     410            datamodel[self.fields[0]] = value
     411        return not err
     412
     413InitializeClass(SecretWidget)
     414
     415widgetRegistry.register(SecretWidget)
     416###)
     417
    368418class MatricNoWidget(CPSStringWidget): ###(
    369419    """ MatricNo Widget"""
     
    372422        """Validate datastructure and update datamodel."""
    373423        valid = CPSStringWidget.validate(self, datastructure, **kw)
     424        logger = logging.getLogger('MatricNo.Validate')
    374425        #import pdb;pdb.set_trace()
    375426        returning = self.returning_import
  • WAeUP_SRP/trunk/profiles/default/layouts/student_session_results_search.xml

    r1169 r1175  
    1919  </property>
    2020  <property name="hidden_readonly_layout_modes"/>
     21 </widget>
     22 <widget name="secret" meta_type="Secret Widget">
     23  <property name="title">Secret Widget</property>
     24  <property name="fields">
     25   <element value="secret"/>
     26  </property>
     27  <property name="label">Enter Your Firstname,Middlename or Lastname</property>
     28  <property name="label_edit">Enter Your Firstname,Middlename or Lastname</property>
     29  <property name="readonly_layout_modes"/>
     30  <property name="hidden_layout_modes">
     31   <element value="edit"/>
     32  </property>
     33  <property name="hidden_readonly_layout_modes"/>
     34  <property name="check_fields">
     35   <element value="Firstname"/>
     36   <element value="Middlename"/>
     37   <element value="Lastname"/>
     38  </property>
     39  <property name="reference">student</property>
     40  <property name="display_width">10</property>
     41  <property name="size_max">10</property>
    2142 </widget>
    2243 <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
     
    104125  </row>
    105126  <row>
    106    <cell name="jamb_reg_no" />
     127   <cell name="secret" />
    107128  </row>
    108129  <row>
  • WAeUP_SRP/trunk/profiles/default/schemas/student_returning.xml

    r1158 r1175  
    33 <field name="email" meta_type="CPS String Field"/>
    44 <field name="phone_nr" meta_type="CPS String Field"/>
    5  <field name="jamb_reg_no" meta_type="CPS String Field"/>
     5 <field name="secret" meta_type="CPS String Field"/>
    66 <field name="matric_no" meta_type="CPS String Field"/>
    77 <field name="password" meta_type="CPS Password Field"/>
  • WAeUP_SRP/trunk/skins/waeup_student/createReturningStudent.py

    r1171 r1175  
    5252        return "MatricNo %s not found in Returning Table" % matric_no
    5353    student_brain = res[0]
    54     #sid,jamb_reg_no = context.waeup_tool.createOne(student_brain)
    55     sid,jamb_reg_no = context.createOne(student_brain)
     54    sid,jamb_reg_no = context.waeup_tool.createOne(student_brain)
    5655    logger.info('"%s","Created Student","%s", "%s" ' % (member,sid,matric_no))
    5756    return "Student MatricNo %s, StudentId %s Jamb %s created" % (matric_no,sid,jamb_reg_no)
  • WAeUP_SRP/trunk/skins/waeup_student/display_session_results.py

    r1166 r1175  
    6262#from Products.zdb import set_trace;set_trace()
    6363results = (sem1, sem2)
    64 return context.session_results_anon_view(student=ds.get('student'),
    65                                            results=results)
     64registered = None
     65student_rec = ds.get('student')
     66res = context.students_catalog(matric_no = student_rec.matric_no)
     67if res:
     68    student_id = res[0].id
     69    student_obj = getattr(context.portal_url.getPortalObject().campus.students,student_id,None)
     70    if student_obj and hasattr(student_obj,'application'):
     71        registered = student_id
     72   
     73return context.session_results_anon_view(student=student_rec,
     74                                           results=results,
     75                                           registered = registered)
    6676
  • WAeUP_SRP/trunk/skins/waeup_student/session_results_anon_view.pt

    r1174 r1175  
    11<metal:html tal:define="student options/student;
    2             results options/results"
     2            results options/results;
     3            registered options/registered"
    34            >
    45  <metal:body use-macro="here/main_template/macros/master">
     
    5253      </table>
    5354      <br />
    54       <form action="" method="post"
     55      <div tal:condition="registered">You have already set your Password, please
     56        <a href="" tal:attributes="href string:${context/portal_url}/login_student">login</a>
     57        with your UserId <span tal:replace="registered" />
     58      </div>
     59      <form tal:condition="not: registered" action="" method="post"
    5560            tal:attributes="action string:${context/portal_url}/set_access_data">
    5661        <input type="hidden" name="matric_no" tal:attributes="value student/matric_no" />
Note: See TracChangeset for help on using the changeset viewer.