Changeset 966


Ignore:
Timestamp:
29 Nov 2006, 14:26:31 (18 years ago)
Author:
joachim
Message:

created new catalog pumeresults for pumeresult checking
modified pume_anon_view and pume_anon_slip to use it.

Location:
WAeUP_SRP/trunk
Files:
1 added
11 edited
3 copied

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r964 r966  
    2222i_home = Globals.INSTANCE_HOME
    2323MAX_TRANS = 100
     24import DateTime
    2425
    2526def makeCertificateCode(code): ###(
     
    245246    security.declareProtected(ModifyPortalContent,"loadPumeResultsFromCSV")###(
    246247    def loadPumeResultsFromCSV(self):
     248        """load Fulltime Studentdata from CSV values into pumeresults catalog"""
     249        import transaction
     250        import random
     251        from pdb import set_trace
     252        csv_d = {'jamb_reg_no': "RegNumber",
     253                 'status': "Admission Status",
     254                 'name': "Name",
     255                 'score': "Score",
     256                 'sex': "Sex",
     257                 'faculty': "Faculty",
     258                 'department': "Dept",
     259                 'course': "Course",
     260                 'course_code_org': "Course Code",
     261                 }
     262        csv_fields = [f[1] for f in csv_d.items()]
     263        tr_count = 0
     264        total = 0
     265        #name = 'pume_results'
     266        name = 'pup'
     267        no_import = []
     268        s = ','.join(['"(%s)"' % fn for fn in csv_fields])
     269        no_import.append('%s' % s)
     270        open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
     271                    '\n'.join(no_import))
     272        no_import = []
     273        logger = logging.getLogger('%s_import' % name)
     274        starttime = DateTime.now()
     275        logger.info('Start loading from %s.csv' % name)
     276        try:
     277            result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     278        except:
     279            logger.error('Error reading %s.csv' % name)
     280            return
     281        pume = self.portal_pumeresults
     282        format = ','.join(['"%%(%s)s"' % fn for fn in csv_fields])
     283        eduplicate = '"dupplicate",%s' % format
     284        for jamb in result:
     285            dict = {}
     286            #set_trace()
     287            for f,fn in csv_d.items():
     288                dict[f] = jamb.get(csv_d[f])
     289            try:
     290                pume.addRecord(**dict)
     291            except ValueError:
     292                logger.info(eduplicate % jamb)
     293                #em = 'Student with REG-NO %(jamb_reg_no)s already exists\n' % dict
     294                #logger.info(em)
     295                no_import.append(eduplicate % jamb)
     296        logger.info('End loading from %s.csv' % name)
     297        if len(no_import) > 1:
     298            open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write(
     299            '\n'.join(no_import))
     300        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     301
     302    security.declareProtected(ModifyPortalContent,"createNewStudents")###(
     303    def createNewStudents(self):
    247304        """load Fulltime Studentdata from CSV values"""
    248305        import transaction
     
    263320                 #'batch': "Batch",
    264321                 #'serial': "SerialNo",
    265                  #'jamb_score': "JambScore",
     322                 'jamb_score': "Score",
    266323                 #'omitted':"Omitted",
    267324                 #'search_key': "SearchKey",
     
    290347        no_import = []
    291348        s = ','.join(['"(%s)"' % fn for fn in csv_fields])
    292         no_import.append('%s\n' % s)
     349        no_import.append('%s' % s)
     350        open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
     351                    '\n'.join(no_import))
     352        no_import = []
    293353        logger = logging.getLogger('%s_import' % name)
    294354        logger.info('Start loading from %s.csv' % name)
     
    327387            jamb_name = jamb.get(csv_d['jamb_lastname'])
    328388            jamb_name.replace('>','')
     389            jamb_name.replace('<','')
    329390            names = jamb_name.split()
    330391            letter = names[-1][0].upper()
     
    341402            student = getattr(self,sid)
    342403            student.manage_setLocalRoles(sid, ['Owner',])
    343             student.invokeFactory('StudentClearance','clearance')
    344             #wftool.doActionFor(student.clearance,'open')
    345             dp = {'Title': 'Clearance/Eligibility Record'}
    346             student.clearance.manage_setLocalRoles(sid, ['Owner',])
    347404            student.invokeFactory('StudentPume','pume')
    348405            dp = {'Title': 'Pume Data'}
     
    353410                         'jamb_sex',
    354411                         #'jamb_state',
    355                          #'jamb_score',
     412                         'jamb_score',
    356413                         'jamb_first_cos',
    357414                         'jamb_sex',
     
    376433            #wftool.doActionFor(pume,'close')
    377434            pume.manage_setLocalRoles(sid, ['Owner',])
    378             student.getContent().createSubObjects()
     435            #student.getContent().createSubObjects()
     436            names = jamb_name.split()
     437            dp = {}
     438            if len(names) == 3:
     439                dp['firstname'] = names[0].capitalize()
     440                dp['middlename'] = names[1].capitalize()
     441                dp['lastname'] = names[2].capitalize()
     442            elif len(names) == 2:
     443                dp['firstname'] = names[0].capitalize()
     444                dp['lastname'] = names[1].capitalize()
     445            else:
     446                dp['lastname'] = jamb_name
     447            dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'
     448            student.invokeFactory('StudentPersonal','personal')
     449            per = student.personal
     450            per_doc = per.getContent()
     451            per_doc.edit(mapping = dp)
     452            per.manage_setLocalRoles(sid, ['Owner',])
    379453            if jamb.get(csv_d['stud_status']) == "Admitted":
    380454                wftool.doActionFor(student,'pume_pass')
     
    384458                wftool.doActionFor(student,'reject_admission')
    385459                continue
     460            #
     461            # Clearance
     462            #
     463            student.invokeFactory('StudentClearance','clearance')
     464            #wftool.doActionFor(student.clearance,'open')
     465            dp = {'Title': 'Clearance/Eligibility Record'}
     466            student.clearance.manage_setLocalRoles(sid, ['Owner',])
    386467            #
    387468            # Study Course
     
    408489            study_course.getContent().edit(mapping=dsc)
    409490            if tr_count > MAX_TRANS:
     491                if len(no_import) > 1:
     492                    open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write(
     493                             '\n'.join(no_import))
     494                    no_import = []
    410495                em = '%d transactions commited\n' % tr_count
    411496                transaction.commit()
     
    413498                total += tr_count
    414499                tr_count = 0
    415         if len(no_import) > 1:
    416             open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
    417                      '\n'.join(no_import))
    418500        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
    419501    ###)
  • WAeUP_SRP/trunk/WAeUPTables.py

    r952 r966  
     1#-*- mode: python; mode: fold -*-
    12# (C) Copyright 2005 AixtraWare <http://aixtraware.de>
    23# Author: Joachim Schmitz <js@aixtraware.de>
     
    166167InitializeClass(PinTable)
    167168
     169class PumeResultsTable(WAeUPTable):
     170
     171    meta_type = 'WAeUP PumeResults Tool'
     172    name = "pumeresults"
     173    key = "jamb_reg_no"
     174    def __init__(self):
     175        WAeUPTable.__init__(self, 'portal_pumeresults')
     176
     177
     178InitializeClass(PumeResultsTable)
     179
    168180# BBB:
    169181AccomodationTable = AccommodationTable
  • WAeUP_SRP/trunk/Widgets.py

    r952 r966  
    288288    letters = 2
    289289    letters_str = "L"*letters
    290 
    291290    def validate(self, datastructure, **kw):
    292291        """Validate datastructure and update datamodel."""
     
    294293        valid = CPSStringWidget.validate(self, datastructure, **kw)
    295294        #import pdb;pdb.set_trace()
     295        pumeresults = self.portal_pumeresults
    296296        if not valid:
    297297            return 0
     
    303303                err = 'Invalid number, the expected format is: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
    304304            else:
    305                 s = getStudentByRegNo(self,value)
    306                 if s is None:
     305                #s = getStudentByRegNo(self,value)
     306                pume = pumeresults(jamb_reg_no = value)
     307                if pume is None:
    307308                    err = 'No Student with JAMB-Reg-No %s' % (value)
    308309                else:
    309                     s_id = s.getId()
    310                     datastructure['s_id'] = s_id
     310                    datastructure['pume'] = pume[0]
    311311            if err:
    312312                datastructure.setError(widget_id, err)
  • WAeUP_SRP/trunk/exportimport.py

    r963 r966  
    9999    importWAeUPTable(site.portal_accommodation, '', context,'accommodation')
    100100    importWAeUPTable(site.portal_pins, '', context,'pins')
     101    importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults')
    101102
    102103from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
  • WAeUP_SRP/trunk/profiles/default/toolset.xml

    r828 r966  
    55 <required tool_id="portal_pins"
    66           class="Products.WAeUP_SRP.WAeUPTables.PinTable"/>
     7 <required tool_id="portal_pumeresults"
     8           class="Products.WAeUP_SRP.WAeUPTables.PumeResultsTable"/>
    79 <required tool_id="waeup_tool"
    810           class="Products.WAeUP_SRP.WAeUPTool.WAeUPTool"/>
  • WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py

    r892 r966  
    4444                                 )
    4545elif psm == 'valid':
    46     url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id'])
    47     return REQUEST.RESPONSE.redirect(url)
    48 
    49 
    50 return
    51 
    52 
     46    return context.pume_anon_view(pume=ds['pume'])
     47##    url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id'])
     48##    return REQUEST.RESPONSE.redirect(url)
  • WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py

    r913 r966  
    4848info['app'] = student.application
    4949info['app_doc'] = student.application.getContent()
    50 info['per'] = student.personal
    51 info['per_doc'] = student.personal.getContent()
     50info['per'] = getattr(student,'personal',None)
     51info['sex'] = 'male'
     52if info['per'] is not None:
     53    info['per_doc'] = student.personal.getContent()
     54    if info['per_doc'].sex:
     55        info['sex'] = 'female'
     56else:
     57    if info['app_doc'].jamb_sex == "F":
     58        info['sex'] = 'female'
    5259course = getattr(student,'study_course',None)
    53 #
    5460info['course'] = course
    5561if course:
    5662    info['course_doc'] = student.study_course.getContent()
    57 info['sex'] = 'male'
    58 if info['per_doc'].sex:
    59     info['sex'] = 'female'
    6063#
    6164acco = getattr(student,'accommodation_2006',None)
  • WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt

    r805 r966  
    1 <metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
    2                         pume_doc python: context.getContent()">
     1<metal:html tal:define="pume python:context.portal_pumeresults(jamb_reg_no=request.get('nr'))[0]">
    32  <metal:body use-macro="here/main_template/macros/master">
    43    <metal:main fill-slot="main">
    5       <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
    6                             <span tal:content="app_doc/jamb_lastname" /></h3>
    7 
    8       <br />
    9       <span tal:omit-tag=""
    10             tal:content="structure python: app_doc.render(proxy=app_doc,
    11             layout_mode='view_info',
    12             layout_id='student_application_fe')"
    13             />
    14       <span tal:condition="python:1" tal:omit-tag=""
    15             tal:content="structure python: pume_doc.render(proxy=pume_doc,
    16             layout_mode='view_slip',
    17             layout_id='student_pume_fe')"
    18             />
     4        <h3>PUME Results of <span tal:content="pume/name" /></h3>
     5                           
     6       <br />                           
     7       <table>
     8        <tr>
     9          <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td>
     10        </tr>
     11        <tr>
     12          <th>Name</th><td tal:content="pume/name"></td>
     13        </tr>
     14        <tr>
     15          <th>Score</th><td tal:content="pume/score"></td>
     16        </tr>
     17        <tr>
     18          <th>Status</th><td tal:content="pume/status"></td>
     19        </tr>
     20        <tr>
     21          <th>Course Requested</th><td tal:content="pume/course"></td>
     22        </tr>
     23      </table>
    1924    </metal:main>
    2025  </metal:body>
  • WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt

    r826 r966  
    1 <metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
    2                         pume_doc python: context.getContent()">
     1<metal:html tal:define="pume options/pume">
    32  <metal:body use-macro="here/main_template/macros/master">
    43    <metal:main fill-slot="main">
    5 
    6            
    74        <div style="text-align: right">
    8         <a href="" target="slip" tal:attributes="href string:pume_anon_slip"
     5        <a href="" target="slip" tal:attributes="href string:pume_anon_slip?nr=${pume/jamb_reg_no}"
    96            onclick="javascript:window.open('','slip','width=600, height=700, directories=no, toolbar=no, location=no, menubar=yes, scrollbars=yes, status=no, resizable=no, dependent=no')">
    107            <img tal:attributes="src string:${here/portal_url}/actionicon_print.png" />
     
    1310        </div>
    1411
    15         <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
    16                             <span tal:content="app_doc/jamb_lastname" /></h3>
     12        <h3>PUME Results of <span tal:content="pume/name" /></h3>
    1713                           
    1814       <br />                           
    19 
    20         <span tal:omit-tag=""
    21               tal:content="structure python: app_doc.render(proxy=app_doc,
    22               layout_mode='view_info',
    23               layout_id='student_application_fe')"
    24               />       
    25         <span tal:omit-tag=""
    26               tal:content="structure python: pume_doc.render(proxy=pume_doc,
    27               layout_mode='view_slip',
    28               layout_id='student_pume_fe')"
    29               />
    30 
     15       <table>
     16        <tr>
     17          <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td>
     18        </tr>
     19        <tr>
     20          <th>Name</th><td tal:content="pume/name"></td>
     21        </tr>
     22        <tr>
     23          <th>Score</th><td tal:content="pume/score"></td>
     24        </tr>
     25        <tr>
     26          <th>Status</th><td tal:content="pume/status"></td>
     27        </tr>
     28        <tr>
     29          <th>Course Requested</th><td tal:content="pume/course"></td>
     30        </tr>
     31      </table>
    3132    </metal:main>
    3233  </metal:body>
  • WAeUP_SRP/trunk/skins/waeup_student/search_students.py

    r920 r966  
    5454        'search_string': ''
    5555        }
    56 
     56#from Products.zdb import set_trace
     57#set_trace()
    5758rend,psm,ds = lt.renderLayout(layout_id= 'student_search',
    5859                      schema_id= 'student_search',
     
    7071                             allowed = True,
    7172                             )
     73#set_trace()
    7274what = ds.get('search_mode')
    7375state = ds.get('review_state')
  • WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt

    r920 r966  
    5858                       tal:content="student/id"></a></td>   
    5959                <td>
    60                   <span tal:replace="python: student['per_doc'].firstname" />
    61                   <span tal:replace="python: student['per_doc'].middlename" />
    62                   <span tal:replace="python: student['per_doc'].lastname" />
     60                  <span tal:replace="student/name" />
    6361                </td>   
    6462                <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td>   
     
    6967                          onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
    7068                          >[change state]</a></td>
    71                        
    72                        
    73                        
    74                        
    7569                <td tal:condition="not: options/co_view|nothing"><span tal:replace="student/review_state" /></td>   
    7670              </tr>
Note: See TracChangeset for help on using the changeset viewer.