Changeset 511 for WAeUP_SRP/trunk


Ignore:
Timestamp:
13 Sep 2006, 06:47:55 (18 years ago)
Author:
joachim
Message:

pin checking and login for JAMB students

Location:
WAeUP_SRP/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r502 r511  
    2222MAX_TRANS = 1000
    2323
    24 def generateStudentId():
     24def generateStudentId(letter):
    2525    import random
    2626    r = random
    27     return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
     27    if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
     28        letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
     29    return "%c%d" % (letter,r.randint(99999,1000000))
     30    #return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
    2831
    2932def getStudentByRegNo(self,reg_no):
     
    294297        import transaction
    295298        tr_count = 0
    296         name = 'SampleJAMBDataII'
     299        name = 'SampleJAMBDataII_short'
     300        wftool = self.portal_workflow
    297301        no_import = False
    298302        if not no_import:
     
    317321                no_import.write('%(REG-NO)s,%(NAME)s,%(SEX)s,%(STATE)s,%(LGA)s,%(ENG-SCORE)s,%(SUBJ1)s,%(SUBJ1-SCORE)s,%(SUBJ2)s,%(SUBJ2-SCORE)s,%(SUBJ3)s,%(SUBJ3-SCORE)s,%(AGGREGATE)s,%(UNIV1)s,%(FACULTY1)s,%(COURSE1)s,%(UNIV2)s,%(FACULTY2)s,%(COURSE2)s\n' % jamb)
    318322                continue
    319             sid = generateStudentId()
     323            jamb_name = jamb.get("NAME")
     324            names = jamb_name.split()
     325            letter = names[-1][0].upper()
     326            sid = generateStudentId(letter)
    320327            #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
    321328            not_created = True
     
    325332                    not_created = False
    326333                except BadRequest:
    327                     sid = generateStudentId()
     334                    sid = generateStudentId(letter)
    328335            logger.info('%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars())
    329             s = getattr(self,sid)
    330             self.portal_registration.addMember(sid,
    331                                                'uNsEt' ,
    332                                                roles=('Member',
    333                                                       'Student',))
    334             s.invokeFactory('StudentApplication','application')
     336            student = getattr(self,sid)
     337            student.invokeFactory('StudentApplication','application')
    335338            da = {'Title': 'Application Data'}
    336 ##            s.invokeFactory('StudentPersonal','personal')
    337 ##            sp = s.personal
    338 ##            d = {'Title': 'Personal Data'}
    339 ##            s.invokeFactory('StudentClearance','clearance')
    340 ##            sc = s.clearance
    341 ##            dc = {'Title': 'Clearance Data'}
    342339            da["jamb_reg_no"] = jamb.get("REG-NO")
    343             da["jamb_lastname"] = jamb.get("NAME")
    344 ##            d["lastname"] = jamb.get("NAME")
     340            da["jamb_lastname"] = jamb_name
    345341            da["jamb_sex"] = jamb.get("SEX")
    346342            da["jamb_state"] = jamb.get("STATE")
     
    351347            da["jamb_first_uni"] = jamb.get("UNIV1")
    352348            da["jamb_second_uni"] = jamb.get("UNIV2")
    353 ##            s.personal.getContent().edit(mapping=d)
    354             s.application.getContent().edit(mapping=da)
    355             s.application.getContent().content_status_modify(workflow_action="open")
    356             s.application.manage_setLocalRoles(s_id, ['Owner',])
     349            app = student.application
     350            app_doc = app.getContent()
     351            app_doc.edit(mapping=da)
     352            wftool.doActionFor(app,'open',dest_container=app)
     353            app.manage_setLocalRoles(sid, ['Owner',])
     354            student.getContent().createSubObjects()
    357355        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
    358356    ###)
    359357
    360358
     359    security.declareProtected(View,"fixOwnership")
     360    def fixOwnership(self):
     361        """fix Ownership"""
     362        for s in self.portal_catalog(meta_type = 'Student'):
     363            student = s.getObject()
     364            sid = s.getId
     365            import pdb;pdb.set_trace()
     366            student.application.manage_setLocalRoles(sid, ['Owner',])
     367            student.personal.manage_setLocalRoles(sid, ['Owner',])
     368           
    361369    security.declareProtected(View,"Title")
    362370    def Title(self):
     
    393401            return "%s" % (content.jamb_lastname)
    394402        return self.title
     403
     404    security.declarePrivate('makeStudentMember') ###(
     405    def makeStudentMember(self,sid,password='uNsEt'):
     406        """make the student a member"""
     407        membership = self.portal_membership
     408        membership.addMember(sid,
     409                             password ,
     410                             roles=('Member',
     411                                     'Student',
     412                                     'Owner'),
     413                             domains='',
     414                             properties = None,)
     415        member = membership.getMemberById(sid)
     416        self.portal_registration.afterAdd(member, sid, password, None)
     417        self.manage_setLocalRoles(sid, ['Owner',])
     418
     419###)
     420
     421    security.declareProtected(View,'createSubObjects') ###(
     422    def createSubObjects(self):
     423        """make the student a member"""
     424        dp = {'Title': 'Personal Data'}
     425        names = self.application.getContent().jamb_lastname.split()
     426        if len(names) == 3:
     427            dp['firstname'] = names[0].capitalize()
     428            dp['middlename'] = names[1].capitalize()
     429            dp['lastname'] = names[2].capitalize()
     430        elif len(names) == 2:
     431            dp['firstname'] = names[0].capitalize()
     432            dp['lastname'] = names[1].capitalize()
     433        else:
     434            dp['lastname'] = app_doc.jamb_lastname
     435            dp['sex'] = app_doc.jamb_sex == 'F'
     436            dp['lga'] = "%s/%s" % (app_doc.jamb_state,app_doc.jamb_lga )
     437        proxy = self.aq_parent
     438        proxy.invokeFactory('StudentPersonal','personal')
     439        per = proxy.personal
     440        per_doc = per.getContent()
     441        per.manage_setLocalRoles(self.getId(), ['Owner',])
     442        self.portal_workflow.doActionFor(per,'open',dest_container=per)
     443        per_doc.edit(mapping = dp)
     444       
     445###)
    395446
    396447InitializeClass(Student)
  • WAeUP_SRP/trunk/Widgets.py

    r502 r511  
    316316        pin = "%(p)s%(b)s%(n)s" % vars()
    317317        ref = datastructure[self.reference]
    318         import pdb;pdb.set_trace()
     318        #import pdb;pdb.set_trace()
    319319        ok = pins.searchAndSetRecord(pin,ref)
    320320        while 1:
     
    333333                if ok == 2:
    334334                    break
     335                student.getContent().makeStudentMember(s_id,password=pin[4:])
     336                #student.getContent().createSubObjects()
    335337            break
    336338        if err:
  • WAeUP_SRP/trunk/__init__.py

    r488 r511  
    1111from Products.CPSCore.interfaces import ICPSSite
    1212
     13import PatchCPSWorkflowWorkflowDefinition
     14import PatchCatalogToolXMLAdapter
    1315# Only for CPS 3.4.1. In 3.4.2 and later this should be fixed.
    1416import PatchCPSDefaultImportExport
    15 import PatchCatalogToolXMLAdapter
    1617
    1718import Products.WAeUP_SRP.WAeUPPermissions
  • WAeUP_SRP/trunk/profiles/default/rolemap.xml

    r502 r511  
    22<rolemap>
    33  <roles>
     4    <role name="Staff"/>
    45    <role name="Student"/>
    56    <role name="SectionReader"/>
  • WAeUP_SRP/trunk/skins/waeup_default/process_waeup_login.py

    r506 r511  
    1313    if "Manager" in member.getRoles():
    1414        return
    15 return
    1615member_id = str(member)
    1716student = getattr(context.students,member_id)
    1817application = student.application
    19 student.invokeFactory('StudentPersonal','personal')
    20 apdoc = application.getContent()
    21 names = apdoc.jamb_lastname.split()
    22 dp = {}
    23 if len(names) == 3:
    24     dp['firstname'] = names[0].capitalize()
    25     dp['middlename'] = names[1].capitalize()
    26     dp['lastname'] = names[2].capitalize()
    27 elif len(names) == 2:
    28     dp['firstname'] = names[0].capitalize()
    29     dp['lastname'] = names[1].capitalize()
    30 else:
    31     dp['lastname'] = apdoc.jamb_lastname
    32     dp['sex'] = apdoc.jamb_sex == 'F'
    33     dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga )
    34 student.personal.getContent().edit(mapping = dp)
    3518##student.content_status_modify(workflow_action="enter_application_pin")
    36 
    3719da = {}
    38 da['app_ac_pin'] = request.get('pin')
     20pin = request.get('pin')
     21da['app_ac_pin'] = pin
    3922da['app_ac_date'] = current
    40 apdoc.edit(mapping = da)
    41 
     23application.getContent().edit(mapping = da)
    4224return response.redirect("%s/application_form" % student.application.absolute_url())
    43 
    44 ##ma = getattr(context,member_id)
    45 ##jkw = {'application_sc_pin': sc_pin}
    46 ##jamb = getattr(ma,'JAMB')
    47 ##jamb.getContent().edit(mapping=jkw)
    48 ###pdid = 'personal%s' % member_id
    49 ##pdid = 'PERSONAL'
    50 ##ma.invokeFactory('StudentPersonal', pdid)
    51 ##pd = getattr(ma,pdid)
    52 ##pkw = {}
    53 ##jc = jamb.getContent()
    54 ##pkw['sex'] = getattr(jc,'sex')
    55 ##pkw['firstname'] = getattr(jc,'firstname')
    56 ##pkw['middlename'] = getattr(jc,'middlename')
    57 ##pkw['lastname'] = getattr(jc,'lastname')
    58 ##pkw['aggregate'] = getattr(jc,'aggregate')
    59 ##pkw['faculty'] = getattr(jc,'faculty')
    60 ##pkw['course'] = getattr(jc,'course')
    61 ##pkw['age'] = getattr(jc,'age')
    62 ##pkw['jamb_results'] = getattr(jc,'exam_results')
    63 ##pkw['jamb_aggregate'] = getattr(jc,'aggregate')
    64 ##pkw['jamb_listing_date'] = getattr(jc,'listing_date')
    65 ##pkw['state'] = getattr(jc,'state')
    66 ##
    67 ##pd.getContent().edit(mapping=pkw)
    68 ##context.notifyCPSDocumentCreation(ob=pd)
    69 ##
    70 ##pdid = 'DOCUMENTS'
    71 ##ma.invokeFactory('StudentDocuments', pdid)
    72 ##pd = getattr(ma,pdid)
    73 ##context.notifyCPSDocumentCreation(ob=pd)
    74 ##
    75 ##pdid = 'ELIGIBILITY'
    76 ##ma.invokeFactory('StudentEligibility', pdid)
    77 ##pd = getattr(ma,pdid)
    78 ##pd.getContent().edit(mapping=pkw)
    79 ##context.notifyCPSDocumentCreation(ob=pd)
    80 ##
    81 ###return ma.personal_addon(REQUEST=context.REQUEST)
    82 
  • WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py

    r502 r511  
    4545elif psm == 'valid':
    4646    s_id = ds.get('s_id')
     47    pin = str(ds.get('app_ac_pin'))
    4748    return context.REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=%s&pin=%s"
    48           % (context.absolute_url(),s_id,'uNsEt',ds.get('app_ac_pin')))
     49          % (context.absolute_url(),s_id,pin.split('-')[2],pin))
    4950   
    5051##    jamb_id = ds.get('jamb_reg_no')
  • WAeUP_SRP/trunk/skins/waeup_student/portlet_student_workflow_display.pt

    r509 r511  
    1313<table class="registration">
    1414 
     15  <span tal:condition="python:1">
     16    <tr>
     17      <td class="active"><a href="apply"
     18                            tal:attributes="href string:${context/absolute_url}/students/apply_admission">
     19        Apply for PUME</a></td>
     20    </tr>
     21  </span>
    1522  <span tal:condition="python:path('info/review_state')=='application_pin_entered'">
    1623  <tr><td class="active">Admission started</td></tr>
Note: See TracChangeset for help on using the changeset viewer.