Changeset 361


Ignore:
Timestamp:
30 Jul 2006, 06:12:00 (18 years ago)
Author:
joachim
Message:

student import startet

Location:
WAeUP_SRP/trunk
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Academics.py

    r351 r361  
    2222p_home = Globals.package_home(globals())
    2323i_home = Globals.INSTANCE_HOME
     24
     25def makeCertificateCode(code):
     26    code = code.replace('.','')
     27    code = code.replace('(','')
     28    code = code.replace(')','')
     29    code = code.replace('/','')
     30    code = code.replace(' ','')
     31    code = code.replace('_','')
     32    return code
    2433
    2534class AcademicsFolder(CPSDocument): ###(
     
    272281            dep = deps[depid]
    273282            certificates = dep.certificates
    274             code = certificate.get('CertCode')
    275             code = code.replace('.','')
    276             code = code.replace('(','')
    277             code = code.replace(')','')
    278             code = code.replace('/','')
    279             code = code.replace(' ','')
    280             code = code.replace('_','')
     283            code = makeCertificateCode(certificate.get('CertCode'))
    281284            certificate_id = code
    282285            c = getattr(certificates,certificate_id,None)
  • WAeUP_SRP/trunk/Students.py

    r200 r361  
    1313from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
    1414from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
    15 ##class StudentsFolder(BaseBTreeFolder): ###(
    16 ##    """
    17 ##    WAeUP container for the various WAeUP containers data
    18 ##    """
    19 ##    meta_type = 'Students Folder'
    20 ##    portal_type = meta_type
    21 ##    security = ClassSecurityInfo()
    22 ##
    23 ##
    24 ##InitializeClass(StudentsFolder)
    25 
    26 ##def addStudentsFolder(container, id, REQUEST=None, **kw):
    27 ##    """Add a Student."""
    28 ##    ob = StudentsFolder(id, **kw)
    29 ##    return CPSBase_adder(container, ob, REQUEST=REQUEST)
    30 #####)
     15from Products.WAeUP_SRP.Academics import makeCertificateCode
     16
     17class StudentsFolder(CPSDocument): ###(
     18    """
     19    WAeUP container for the various WAeUP containers data
     20    """
     21    meta_type = 'Students Folder'
     22    portal_type = meta_type
     23    security = ClassSecurityInfo()
     24
     25    security.declareProtected(ModifyPortalContent,"loadFullTimeStudentsFromCSV")###(
     26    def loadFullTimeStudentsFromCSV(self):
     27        """load Fulltime Studentdata from CSV values"""
     28        #return
     29        name = 'short_full_time'
     30        no_import = False
     31        logger = logging.getLogger('%s_import' % name)
     32        logger.info('Start loading from %s.csv' % name)
     33        students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()
     34        try:
     35            students = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     36        except:
     37            logger.error('Error reading %s.csv' % name)
     38            return
     39        l = self.portal_catalog({'meta_type': "Student"})
     40        studs = {}
     41        for s in l:
     42            studs[s.id] = s.getObject()
     43        l = self.portal_catalog({'meta_type': "Certificate"})
     44        certs = {}
     45        for c in l:
     46            certs[s.id] = c.getObject()
     47        for student in students:
     48            logger.info('processing "%(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"' % student)
     49            sid = student.get('MatricNo')
     50            certcode = makeCertificateCode(student.get('CourseMajor'))
     51            s = studs.get(sid,None)
     52            if certcode not in certs.keys():
     53                em = 'Certificate with ID %s %s not found' % (certcode, student.get('CourseMajor'))
     54                if not no_import:
     55                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
     56                    no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
     57                logger.info(em)
     58                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"' % student)
     59                continue
     60            if s is None:
     61                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
     62                logger.info('Creating Student with ID %(MatricNo)s %(fullname)s' % faculty)
     63                students_folder.invokeFactory('Student', sid)
     64                s = getattr(self,sid)
     65                s.invokeFactory('StudentPersonal','personal')
     66                sp = getattr(self,sid)
     67                d = {'Title': 'Personal Data'}
     68                d['fullname'] = student.get('fullname')
     69                d['firstname'] = student.get('FirstName')
     70                d['middlename'] = student.get('MiddleName')
     71                d['lastname'] = student.get('LastName')
     72                d['former_surname'] = student.get('FormerSurname')
     73                d['sex'] = student.get('Sex') == 'M'
     74                d['nationality'] = student.get('Nationality')
     75                d['state'] = student.get('State')
     76                d['lga'] = student.get('LGA')
     77                d['street'] = student.get('PermanentAddress')
     78                d['city'] = student.get('PermanentAddressCity')
     79                d['campus_address'] = student.get('CampusAddress')
     80                d['phone'] = student.get('PhoneNumber')
     81                d['email'] = student.get('EmailAddress')
     82                f.getContent().edit(mapping=d)
     83            else:
     84                em = 'Faculty with ID %(MatricNo)s %(fullname)s already exists' % student
     85                if not no_import:
     86                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
     87                    no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
     88                logger.info(em)
     89                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"' % student)
     90        return self.students.folder_contents()
     91    ###)
     92
     93InitializeClass(StudentsFolder)
     94
     95def addStudentsFolder(container, id, REQUEST=None, **kw):
     96    """Add a Student."""
     97    ob = StudentsFolder(id, **kw)
     98    return CPSBase_adder(container, ob, REQUEST=REQUEST)
     99###)
    31100
    32101class Student(CPSDocument): ###(
  • WAeUP_SRP/trunk/__init__.py

    r279 r361  
    2626from Products.WAeUP_SRP.Academics import CourseTicket, addCourseTicket
    2727from Products.WAeUP_SRP.Academics import CertificateCourse, addCertificateCourse
     28from Products.WAeUP_SRP.Students import StudentsFolder, addStudentsFolder
    2829from Products.WAeUP_SRP.Students import Student, addStudent
    2930from Products.WAeUP_SRP.Students import StudentPersonal, addStudentPersonal
     
    4950    AccoFolder,
    5051    Accommodation,
     52    StudentsFolder,
    5153    Student,
    5254    StudentPersonal,
     
    7072    addAccoFolder,
    7173    addAccommodation,
     74    addStudentsFolder,
    7275    addStudent,
    7376    addStudentPersonal,
     
    9194    {}, # AccoFolder
    9295    {}, # Accommodation
     96    {}, # StudentsFolder,
    9397    {}, # Student,
    9498    {}, # StudentPersonal,
  • WAeUP_SRP/trunk/profiles/default/schemas.xml

    r296 r361  
    1717 <object name="student_admission" meta_type="CPS Schema"/>
    1818 <object name="student_clearance" meta_type="CPS Schema"/>
    19  <object name="student_clearence" meta_type="CPS Schema"/>
    2019 <object name="student_documents" meta_type="CPS Schema"/>
    2120 <object name="student_eligibility" meta_type="CPS Schema"/>
  • WAeUP_SRP/trunk/profiles/default/schemas/student_personal.xml

    r199 r361  
    11<?xml version="1.0"?>
    22<object name="student_personal" meta_type="CPS Schema">
    3  <field name="age" meta_type="CPS DateTime Field"/>
    43 <field name="birthday" meta_type="CPS DateTime Field"/>
     4 <field name="campus_address" meta_type="CPS String Field"/>
     5 <field name="city" meta_type="CPS String Field"/>
    56 <field name="email" meta_type="CPS String Field">
    67  <property name="is_searchabletext">True</property>
    78 </field>
     9 <field name="entry_reg_no" meta_type="CPS String Field"/>
    810 <field name="firstname" meta_type="CPS String Field">
    911  <property name="is_searchabletext">True</property>
    1012 </field>
     13 <field name="former_surname" meta_type="CPS String Field">
     14  <property name="is_searchabletext">True</property>
     15 </field>
     16 <field name="fullname" meta_type="CPS String Field"/>
    1117 <field name="lastname" meta_type="CPS String Field">
    1218  <property name="is_searchabletext">True</property>
    1319 </field>
     20 <field name="lga" meta_type="CPS String Field"/>
     21 <field name="matricel_nr" meta_type="CPS String Field"/>
    1422 <field name="middlename" meta_type="CPS String Field">
    1523  <property name="is_searchabletext">True</property>
    1624 </field>
     25 <field name="nationality" meta_type="CPS String Field"/>
     26 <field name="phone" meta_type="CPS Boolean Field"/>
    1727 <field name="sex" meta_type="CPS Boolean Field"/>
    18  <field name="username" meta_type="CPS String Field">
     28 <field name="state" meta_type="CPS String Field"/>
     29 <field name="street" meta_type="CPS String Field">
    1930  <property name="is_searchabletext">True</property>
    2031 </field>
  • WAeUP_SRP/trunk/profiles/default/types/StudentsFolder.xml

    r332 r361  
    4141 <action title="Add JAMB Data" action_id="add_jamb" category="object"
    4242    condition_expr="" url_expr="string:${object/absolute_url}/create_jamb"
    43     visible="True">
    44   <permission value="University Manage"/>
    45  </action>
     43    visible="True"/>
    4644 <action title="Check Admission Status" action_id="check_admission"
    4745    category="object"
     
    6866 <action title="action_folder_contents" action_id="contents" category="object"
    6967    condition_expr="" url_expr="string:${object/absolute_url}/folder_contents"
    70     visible="False">
    71   <permission value="University Manage"/>
    72  </action>
     68    visible="False"/>
     69 <action title="import fulltime students" action_id="import_fulltime"
     70    category="import" condition_expr=""
     71    url_expr="string:${object_url}/loadFullTimeStudentsFromCSV"
     72    visible="True"/>
    7373</object>
  • WAeUP_SRP/trunk/skins/waeup_custom/getCPSCandidateLocalRoles.py

    r350 r361  
    1818mtool = getToolByName(context, 'portal_membership')
    1919#return mtool.getCPSCandidateLocalRoles(context)
    20 return ['SectionReader','SectionManager']
     20return ['Manager','SectionReader','SectionManager']
  • WAeUP_SRP/trunk/skins/waeup_custom/getContentInfo.py

    r306 r361  
    200200    info['type_l10n'] = cpsmcat(proxy.getTypeInfo().Title())
    201201else:
    202     LOG("getContentInfo() pb getting Type Information",
    203         DEBUG,
    204         'Proxy :',
    205         proxy)
     202##    LOG("getContentInfo() pb getting Type Information",
     203##        DEBUG,
     204##        'Proxy :',
     205##        proxy)
    206206    info['type_l10n'] = ''
    207207info['review_state'] = wtool.getInfoFor(proxy, 'review_state', '')
Note: See TracChangeset for help on using the changeset viewer.