Changeset 1319 for WAeUP_SRP/trunk


Ignore:
Timestamp:
18 Jan 2007, 23:09:04 (18 years ago)
Author:
joachim
Message:

A profiles/default/vocabularies/student_transfer_types.xml
A profiles/default/layouts/student_transfer.xml
M profiles/default/vocabularies.xml
M profiles/default/layouts.xml
AM skins/waeup_student/request_transfer.py
AM skins/waeup_student/request_transfer_form.pt
for request transfer
M profiles/default/students_catalog.xml
entry_mode index (in zmi)
M Students.py
fixEntryModeForReturning + fixAllEntryModeForReturning
M WAeUPTool.py
makeStudent fixed

Location:
WAeUP_SRP/trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r1289 r1319  
    617617        name = 'Admitted'
    618618        no_import = []
    619         s = ','.join(['"(%s)"' % fn for fn in csv_fields])
     619        s = ','.join(['"%s"' % fn for fn in csv_fields])
    620620        no_import.append('"Error",%s' % s)
    621621        format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields])
     
    841841        if len(res) > 0:
    842842            regs = [s.matric_no for s in res]
     843        #import pdb;pdb.set_trace()
    843844        for student in returning:
    844845            if start:
    845846                start = False
    846847                logger.info('start loading from %s.csv' % name)
    847                 s = ','.join(['"(%s)"' % fn for fn in student.keys()])
     848                s = ','.join(['"%s"' % fn for fn in student.keys()])
    848849                imported.append(s)
    849850                no_import.append('%s,"Error"' % s)
     
    851852                format_error = format + ',"%(Error)s"'
    852853                no_certificate = "no certificate %s" % format
    853             matric_no = student.get('matric_no').upper()
    854             student['matric_no'] = matric_no
     854            student['matric_no'] = matric_no = student.get('matric_no').upper()
     855            student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper()
     856            student['Permanent_Address'] = perm_address = student.get('Permanent Address')
    855857            if matric_no == '':
    856858                student['Error'] = "Empty matric_no"
     
    869871                table.addRecord(**student)
    870872            except ValueError:
    871                 #import pdb;pdb.set_trace()
    872873                student['Error'] = "Duplicate"
    873874                no_import.append( format_error % student)
     
    897898    ###)
    898899
    899 
    900 
     900    security.declareProtected(ModifyPortalContent,"fixAllEntryModeForReturning")###(
     901    def fixAllEntryModeForReturning(self):
     902        "read all Returning*.csv"
     903        ipath = "%s/import/" % i_home
     904        names = os.listdir(ipath)
     905        #import pdb;pdb.set_trace()
     906        for name in names:
     907            head,tail = os.path.splitext(name)
     908            if head.startswith('Returning')\
     909               and tail == '.csv'\
     910               and name.find('imported') < 0:
     911                self.fixEntryModeForReturning(csv_file=head)
     912
     913    security.declareProtected(ModifyPortalContent,"fixEntryModeForReturning")###(
     914    def fixEntryModeForReturning(self,csv_file=None):
     915        """load Returning Studentdata from CSV values"""
     916        import transaction
     917        import random
     918        wftool = self.portal_workflow
     919        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     920        students_folder = self.portal_url.getPortalObject().campus.students
     921        tr_count = 1
     922        total = 0
     923        if csv_file is None:
     924            name = 'Returning'
     925        else:
     926            name = csv_file
     927        table = self.returning_import
     928        st_cat = self.students_catalog
     929        no_import = []
     930        logger = logging.getLogger('getEntryMode.%s' % name)
     931        try:
     932            returning = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     933        except:
     934            logger.error('Error reading %s.csv' % name)
     935            return
     936        start = True
     937        for student in returning:
     938            if start:
     939                start = False
     940                logger.info('start loading from %s.csv' % name)
     941                s = ','.join(['"(%s)"' % fn for fn in student.keys()])
     942                no_import.append('%s,"Error"' % s)
     943                format = ','.join(['"%%(%s)s"' % fn for fn in student.keys()])
     944                format_error = format + ',"%(Error)s"'
     945            matric_no = student.get('matric_no')
     946            if not matric_no:
     947                continue
     948            matric_no = matric_no.upper()
     949            student['matric_no'] = matric_no
     950            if matric_no == '':
     951                continue
     952            if not table(matric_no = matric_no):
     953                student['Error'] = "Not imported yet"
     954                no_import.append( format_error % student)
     955                continue
     956            student_id = None
     957            app = None
     958            per = None
     959            if st_cat(matric_no = matric_no):
     960                student_id = st_cat(matric_no = matric_no)[0].id
     961                app = getattr(getattr(students_folder,student_id),'application',None)
     962                if app is not None:
     963                    app_doc = app.getContent()
     964                per = getattr(getattr(students_folder,student_id),'personal',None)
     965                if per is not None:
     966                    per_doc = per.getContent()
     967            student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper()
     968            student['Permanent_Address'] = perm_address = student.get('Permanent Address')
     969            entry_mode = student['Mode of Entry']
     970            if not entry_mode:
     971                student['Error'] = "'Mode of Entry' empty"
     972                no_import.append( format_error % student)
     973                continue
     974            try:
     975                table.modifyRecord(matric_no = matric_no,
     976                                   Mode_of_Entry = entry_mode,
     977                                   Permanent_Address = perm_address)
     978            except KeyError:
     979                student['Error'] = "Not found in returning_import"
     980                no_import.append( format_error % student)
     981                continue
     982            if student_id is not None:
     983                try:
     984                    st_cat.modifyRecord(id = student_id,
     985                                        entry_mode=entry_mode)
     986                except KeyError:
     987                    student['Error'] = "Not found in students_catalog"
     988                    no_import.append( format_error % student)
     989                    continue
     990            if app is not None:
     991                da = {}
     992                da['entry_mode'] = entry_mode
     993                app_doc.edit(mapping=da)
     994            if per is not None:
     995                dp = {}
     996                dp['perm_address'] = entry_mode
     997                per_doc.edit(mapping=dp)
     998            tr_count += 1
     999            if tr_count > 1000:
     1000                if len(no_import) > 0:
     1001                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
     1002                             '\n'.join(no_import) + '\n')
     1003                    no_import = []
     1004                em = '%d transactions commited total %s\n' % (tr_count,total)
     1005                transaction.commit()
     1006                regs = []
     1007                logger.info(em)
     1008                total += tr_count
     1009                tr_count = 0
     1010        open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
     1011                                                '\n'.join(no_import))
     1012        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     1013    ###)
    9011014
    9021015    security.declareProtected(ModifyPortalContent,"updateReturningStudents")###(
     
    9931106        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
    9941107    ###)
    995 
    996 
    997 
    9981108
    9991109    security.declareProtected(ModifyPortalContent,"importResults")###(
  • WAeUP_SRP/trunk/WAeUPTool.py

    r1287 r1319  
    182182            student = res[0]
    183183        logger.info('"%s", "creating Datastructure"' % student_id)
    184 
    185184        #student should not be allowed to perform this transition
    186185        #wftool = self.portal_workflow
    187186        #wftool.doActionFor(student,'return')
    188 
    189187        certcode_org = student.Coursemajorcode
    190188        certcode = makeCertificateCode(certcode_org)
  • WAeUP_SRP/trunk/profiles/default/layouts.xml

    r1274 r1319  
    3333 <object name="student_search" meta_type="CPS Layout"/>
    3434 <object name="student_study_level" meta_type="CPS Layout"/>
     35 <object name="student_transfer" meta_type="CPS Layout"/>
    3536 <object name="study_level" meta_type="CPS Layout"/>
    3637 <object name="university" meta_type="CPS Layout"/>
  • WAeUP_SRP/trunk/profiles/default/students_catalog.xml

    r1291 r1319  
    2525  <indexed_attr value="faculty"/>
    2626 </index>
     27 <index name="entry_mode" meta_type="KeywordIndex">
     28  <indexed_attr value="entry_mode"/>
     29 </index>
    2730 <index name="department" meta_type="KeywordIndex">
    2831  <indexed_attr value="department"/>
  • WAeUP_SRP/trunk/profiles/default/vocabularies.xml

    r1002 r1319  
    2121 <object name="pin_prefixes" meta_type="CPS Vocabulary"/>
    2222 <object name="student_search_mode" meta_type="CPS Vocabulary"/>
     23 <object name="student_transfer_types" meta_type="CPS Vocabulary"/>
    2324 <object name="scratch_card_search_mode" meta_type="CPS Vocabulary"/>
    2425 <object name="student_status_voc" meta_type="CPS Vocabulary"/>
Note: See TracChangeset for help on using the changeset viewer.