Changeset 422


Ignore:
Timestamp:
25 Aug 2006, 16:21:44 (18 years ago)
Author:
joachim
Message:

added check for space in Id

Location:
WAeUP_SRP/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r398 r422  
    2020i_home = Globals.INSTANCE_HOME
    2121MAX_TRANS = 1000
     22
     23def generateStudentId():
     24    import random
     25    r = random.random()
     26    return "%c%d" % (r.choice('ABCDEFGIJHKLMNOPQRSTUVWXYZ'),r.randint(99999,1000000))
     27   
     28   
    2229
    2330class StudentsFolder(CPSDocument): ###(
     
    4855            logger.error('Error reading %s.csv' % name)
    4956            return
    50         l = self.portal_catalog({'meta_type': "Student"})
    51         studs = {}
     57        l = self.portal_catalog({'meta_type': "StudentClearance",})
     58        matrics = []
    5259        for s in l:
    53             studs[s.id] = s.getObject()
     60            matrics.append(s.getObject().getContent().matric_no)
    5461        l = self.portal_catalog({'meta_type': "Certificate"})
    5562        certs = {}
    56         students_added = []
    5763        for c in l:
    5864            certs[c.id] = c.getObject()
     
    6773                continue
    6874            certcode = makeCertificateCode(student.get('CourseMajor'))
    69 ##            if sid in students_added:
    70 ##                em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student
    71 ##                logger.info(em)
    72 ##                no_import.write(em)
    73 ##                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
    74 ##                continue
    75             s = studs.get(sid,None)
    7675            if certcode not in certs.keys():
    7776                em = 'Certificate with ID %s %s not found\n' % (certcode, student.get('CourseMajor'))
     
    8988                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
    9089                continue
    91             if s is None:
     90            matric_no = student.get('MatricNo')
     91            if matric_no not in matrics:
     92                matrics.append(matric_no)
     93                sid = generateStudentId()
    9294                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
    93                 logger.info('Creating Student with ID %(MatricNo)s %(fullname)s' % student)
     95                logger.info('Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
    9496                students_folder.invokeFactory('Student', sid)
    9597                s = getattr(self,sid)
    96                 students_added.append(sid)
    97                 studs[sid] = s
    9898                s.invokeFactory('StudentPersonal','personal')
    9999                sp = s.personal
    100100                d = {'Title': 'Personal Data'}
    101                 d['matricel_no'] = student.get('MatricNo')
    102                 d['entry_reg_no'] = student.get('EntryRegNo')
    103                 d['fullname'] = student.get('fullname')
     101                s.invokeFactory('StudentClearance','clearance')
     102                sc = s.personal
     103                dc = {'Title': 'Clearance Data'}
     104                dc['matric_no'] = matric_no
     105                dc['jamb_reg_no'] = student.get('EntryRegNo')
     106                dc['lga'] = student.get('LGA')
     107                dc['nationality'] = student.get('Nationality')
     108                dc['email'] = student.get('Emailaddress')
    104109                d['firstname'] = student.get('FirstName')
    105110                d['middlename'] = student.get('MiddleName')
     
    107112                d['former_surname'] = student.get('FormerSurname')
    108113                d['sex'] = student.get('Sex') == 'F'
    109                 d['nationality'] = student.get('Nationality')
    110                 d['state'] = student.get('State')
    111                 d['lga'] = student.get('LGA')
    112                 d['street'] = student.get('PermanentAddress')
    113                 d['city'] = student.get('PermanentAddressCity')
     114                d['for_state'] = student.get('State')
     115                d['for_lga'] = student.get('LGA')
     116                d['perm_address'] = student.get('PermanentAddress')
     117                d['perm_city'] = student.get('PermanentAddressCity')
    114118                d['campus_address'] = student.get('CampusAddress')
    115119                d['phone'] = student.get('PhoneNumber')
    116                 d['email'] = student.get('Emailaddress')
    117120                sp.getContent().edit(mapping=d)
     121                sc.getContent().edit(mapping=dc)
    118122                #
    119123                # Study Course
     
    122126                sc = s.study_course
    123127                d = {}
    124                 d['matricel_no'] = student.get('MatricNo')
    125                 d['entry_reg_no'] = student.get('EntryRegNo')
    126                 d['faculty'] = student.get('Faculty')
    127                 d['department'] = student.get('Dept')
     128                #d['matricel_no'] = student.get('MatricNo')
     129                #d['entry_reg_no'] = student.get('EntryRegNo')
     130                #d['faculty'] = student.get('Faculty')
     131                #d['department'] = student.get('Dept')
    128132                d['course_major'] = certcode
    129133                css = student.get('CurrentSession') or '2004-2005'
     
    158162                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
    159163            if tr_count > MAX_TRANS:
    160                 #transaction.commit()
    161                 #em = '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Transaction commited\n' % student
     164                transaction.commit()
     165                em = 'Transaction commited\n' % student
    162166                logger.info(em)
    163167                tr_count = 0
  • WAeUP_SRP/trunk/Widgets.py

    r388 r422  
    151151       
    152152        valid = CPSStringWidget.validate(self, datastructure, **kw)
     153        id_pat_str = r"\S"
     154        inv_id_pat = compile(r"^%s$" % id_pat_str)
    153155        if not valid:
    154156            return 0
     
    157159            value = datastructure[widget_id].upper()
    158160            err = 0
    159             if hasattr(self.aq_parent,value):
     161            if value.split() > 1:
     162                err = 'Invalid Id (Id contains space(s)'
     163            elif hasattr(self.aq_parent,value):
    160164                err = 'An object with the Id %s already exists in this context' % (value)
    161165            if err:
  • WAeUP_SRP/trunk/profiles/default/layouts/department.xml

    r389 r422  
    3333   <element value="code"/>
    3434  </property>
     35  <property name="is_required">True</property>
    3536  <property name="label">Object ID</property>
    3637  <property name="label_edit">Object ID</property>
  • WAeUP_SRP/trunk/profiles/default/workflows.xml

    r384 r422  
    5757   <bound-workflow workflow_id="section_folder_wf"/>
    5858  </type>
    59   <type type_id="Jamb">
    60    <bound-workflow workflow_id="waeup_base_wf"/>
    61   </type>
    62   <type type_id="Members Workspace">
    63    <bound-workflow workflow_id="workspace_folder_wf"/>
    64   </type>
    65   <type type_id="Section">
    66    <bound-workflow workflow_id="section_folder_wf"/>
    67   </type>
    6859  <type type_id="Semester">
    6960   <bound-workflow workflow_id="section_folder_wf"/>
     
    7566   <bound-workflow workflow_id="waeup_base_wf"/>
    7667  </type>
    77   <type type_id="StudentElegibility">
    78    <bound-workflow workflow_id="waeup_base_wf"/>
     68  <type type_id="StudentClearance">
     69   <bound-workflow workflow_id="section_folder_wf"/>
    7970  </type>
    80   <type type_id="StudentEligibility">
    81    <bound-workflow workflow_id="waeup_base_wf"/>
     71  <type type_id="StudentAdmission">
     72   <bound-workflow workflow_id="section_folder_wf"/>
    8273  </type>
    8374  <type type_id="StudentPersonal">
Note: See TracChangeset for help on using the changeset viewer.