Changeset 1151


Ignore:
Timestamp:
29 Dec 2006, 22:05:53 (18 years ago)
Author:
joachim
Message:

ask for email and password

Location:
WAeUP_SRP/trunk
Files:
6 added
14 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r1146 r1151  
    809809    ###)
    810810
    811     security.declareProtected(ModifyPortalContent,"importRegisteredStudents")###(
    812     def importRegisteredStudents(self):
    813         """load Registered Studentdata from CSV values"""
     811    security.declareProtected(ModifyPortalContent,"importReturningStudents")###(
     812    def importReturningStudents(self):
     813        """load Returning Studentdata from CSV values"""
    814814        import transaction
    815815        import random
     
    821821        total = 0
    822822        #name = 'pume_results'
    823         name = 'Registered'
    824         table = self.registered_import
     823        name = 'Returning'
     824        table = self.returning_import
    825825        no_import = []
    826826        imported = []
    827827        logger = logging.getLogger('Import.%s' % name)
    828828        try:
    829             registered = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     829            returning = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
    830830        except:
    831831            logger.error('Error reading %s.csv' % name)
     
    841841        if len(res) > 0:
    842842            regs = [s.matric_no for s in res]
    843         for student in registered:
     843        for student in returning:
    844844            if start:
    845845                start = False
     
    877877                if len(no_import) > 0:
    878878                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
    879                              '\n'.join(no_import))
     879                             '\n'.join(no_import) + '\n')
    880880                    no_import = []
    881                     imported = []
    882881                open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(
    883                                             '\n'.join(no_import))
     882                                            '\n'.join(no_import) + "\n")
     883                imported = []
    884884                em = '%d transactions commited total %s\n' % (tr_count,total)
    885885                transaction.commit()
     
    896896    security.declareProtected(ModifyPortalContent,"importResults")###(
    897897    def importResults(self):
    898         """load Registered Studentdata from CSV values"""
     898        """load Returning Students Results from CSV"""
    899899        import transaction
    900900        import random
     
    967967                if len(no_import) > 0:
    968968                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
    969                              '\n'.join(no_import))
     969                             '\n'.join(no_import)+'\n')
    970970                    no_import = []
    971971                open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(
    972                                             '\n'.join(imported))
     972                                            '\n'.join(imported) + '\n')
    973973                imported = []
    974974                if no_course_list:
    975975                    open("%s/import/%sno_courses%s.csv" % (i_home,name,current),"a").write(
    976                                             '\n'.join(no_course_list))
     976                                            '\n'.join(no_course_list) + '\n')
    977977                    no_course_list = []
    978978                em = '%d transactions commited total %s\n courses not found %s' % (tr_count,total,course_count)
     
    17201720###)
    17211721
    1722 
    17231722class StudentPume(CPSDocument): ###(
    17241723    """
  • WAeUP_SRP/trunk/WAeUPTables.py

    r1146 r1151  
    232232
    233233InitializeClass(CoursesCatalog)
    234 
    235 class RegisteredImport(WAeUPTable): ###(
    236 
    237     meta_type = 'Registered Import Table'
    238     name = "registered_import"
     234###)
     235
     236class ReturningImport(WAeUPTable): ###(
     237
     238    meta_type = 'Returning Import Table'
     239    name = "returning_import"
    239240    key = "matric_no"
    240241    def __init__(self):
    241         WAeUPTable.__init__(self, 'registered_import')
    242 
    243 
    244 InitializeClass(RegisteredImport)
     242        WAeUPTable.__init__(self, 'returning_import')
     243
     244
     245InitializeClass(ReturningImport)
     246###)
    245247
    246248class ResultsImport(WAeUPTable): ###(
  • WAeUP_SRP/trunk/WAeUPTool.py

    r828 r1151  
    3535from Products.CMFCore.permissions import ModifyPortalContent
    3636from Products.CMFCore.utils import UniqueObject
     37from Students import makeCertificateCode
     38import logging
     39
    3740
    3841class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
     
    5053                     )
    5154
    52 ##    security.declarePublic('getHallTitle')
    53 ##    def getHallTitle(self,hall):
    54 ##        """get the Hall Title"""
    55 ##        res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall)
    56 ##        if res and len(res) == 1:
    57 ##            return res[0].Title
    58 ##        return hall
    59 
    60     security.declarePublic('getAccommodationInfo')
     55    def generateStudentId(self,letter): ###(
     56        import random
     57        r = random
     58        if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
     59            letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
     60        students = self.portal_url.getPortalObject().campus.students
     61        sid = "%c%d" % (letter,r.randint(99999,1000000))
     62        while hasattr(students, sid):
     63            sid = "%c%d" % (letter,r.randint(99999,1000000))
     64        return sid
     65    ###)
     66
     67    security.declarePublic('getCertificateBrain') ###(
     68    def getCertificateBrain(self,cert_id):
     69        "do it"
     70        res = ZCatalog.searchResults(self.portal_catalog,
     71                                {'portal_type':"Certificate",
     72                                      'id': cert_id})
     73        if res:
     74            return res[0]
     75        return None
     76    ###)
     77   
     78    security.declarePublic('findStudentByMatricelNo') ###(
     79    def findStudentByMatricelNo(self,matric_no):
     80        "do it"
     81        res = ZCatalog.searchResults(self.portal_catalog,
     82                                {'portal_type':"StudentClearance",
     83                                 'SearchableText': matric_no})
     84        if res:
     85            return res[0]
     86        return None
     87    ###)
     88
     89    security.declarePublic('makeStudentMember') ###(
     90    def makeStudentMember(self,sid,password='uNsEt'):
     91        """make the student a member"""
     92        membership = self.portal_membership
     93        membership.addMember(sid,
     94                             password ,
     95                             roles=('Member',
     96                                     'Student',
     97                                     ),
     98                             domains='',
     99                             properties = {'memberareaCreationFlag': False,
     100                                           'homeless': True},)
     101        member = membership.getMemberById(sid)
     102        self.portal_registration.afterAdd(member, sid, password, None)
     103        self.manage_setLocalRoles(sid, ['Owner',])
     104    ###)
     105       
     106    security.declarePublic('makeStudentData') ###(
     107    def makeStudentData(self,student_id,email=None):
     108        "create Datastructure for a returning Student"
     109        #import pdb;pdb.set_trace()
     110        logger = logging.getLogger('Student.CreateData')
     111        students_folder = self.portal_url.getPortalObject().campus.students
     112        res = self.students_catalog(id=student_id)
     113        if res:
     114            st = res[0]
     115        res = self.returning_import(matric_no = st.matric_no)
     116        if res:
     117            student = res[0]
     118        logger.info('"%s", "creating Datastructure"')
     119        certcode_org = student.Coursemajorcode
     120        certcode = makeCertificateCode(certcode_org)
     121        certificate_brain = self.getCertificateBrain(certcode)
     122        if not certificate_brain:
     123            em = 'Certificate %s org-code %s not found\n' % (certcode, certcode_org)
     124            logger.info(em)
     125        level = student.Level
     126        try:
     127            int(level)
     128        except:
     129            em = '"%(matric_no)s","invalid Level","%(Level)s"' % student
     130            logger.info(em)
     131        matric_no = student.matric_no
     132        sid = student_id
     133        student_obj = getattr(students_folder,sid)
     134        student_obj.invokeFactory('StudentApplication','application')
     135        application = student_obj.application
     136        self.portal_workflow.doActionFor(application,'open',dest_container=application)
     137        da = {'Title': 'Application Data'}
     138        student_obj.invokeFactory('StudentPersonal','personal')
     139        da['jamb_reg_no'] = student.Entryregno
     140        da['entry_mode'] = student.Mode_of_Entry
     141        personal = student_obj.personal
     142        self.portal_workflow.doActionFor(personal,'open',dest_container=personal)
     143        dp = {'Title': 'Personal Data'}
     144        student_obj.invokeFactory('StudentClearance','clearance')
     145        clearance = student_obj.clearance
     146        self.portal_workflow.doActionFor(clearance,'open',dest_container=clearance)
     147        dc = {'Title': 'Clearance/Eligibility Record'}
     148        dc['matric_no'] = matric_no
     149        state = student.State
     150        lga = student.LGA
     151        if state and lga:
     152            lga =  state + ' / ' + lga
     153        else:
     154            lga = "None"
     155        dc['lga'] = lga
     156        dc['email'] = email
     157        dp['firstname'] = student.Firstname
     158        dp['middlename'] = student.Middlename
     159        dp['lastname'] = student.Lastname
     160        dp['sex'] = student.Sex == 'F'
     161        dp['perm_address'] = student.Permanent_Address
     162        application.getContent().edit(mapping=da)
     163        personal.getContent().edit(mapping=dp)
     164        clearance.getContent().edit(mapping=dc)
     165        #
     166        # Study Course
     167        #
     168        student_obj.invokeFactory('StudentStudyCourse','study_course')
     169        studycourse = student_obj.study_course
     170        self.portal_workflow.doActionFor(studycourse,'open',dest_container=studycourse)
     171        dsc = {}
     172        dsc['study_course'] = certcode
     173        studycourse.getContent().edit(mapping=dsc)
     174        #
     175        # Level
     176        #
     177##        l = getattr(studycourse,level,None)
     178##        if l is None:
     179##            studycourse.invokeFactory('StudentStudyLevel', level)
     180##            l = getattr(studycourse, level)
     181##            self.portal_workflow.doActionFor(l,'open',dest_container=l)
     182##            l.getContent().edit(mapping={'Title': "Level %s" % level})
     183       
     184    security.declarePublic('getAccommodationInfo') ###(
    61185    def getAccommodationInfo(self,bed):
    62186        """return Accommodation Info"""
     
    82206            info['maintenance_fee'] = batch_doc.cost
    83207        return info
     208    ###)
     209
     210    security.declareProtected(ModifyPortalContent,'deleteAllCourses') ###(
     211    def deleteAllCourses(self,department="All"):
     212        ''' delete the courses'''
     213        pm = self.portal_membership
     214        member = pm.getAuthenticatedMember()
     215       
     216        if str(member) not in ("henrik","joachim"):
     217            return "not possible"
     218        if department == "All":
     219            res = self.portal_catalog({'meta_type': 'Department'})
     220        if len(res) < 1:
     221            return "No Departments found"
     222       
     223        deleted = []
     224        for dep in res:
     225            cf = dep.getObject().courses
     226            if cf:
     227                cf.manage_delObjects(ids=cf.objectIds())
     228                deleted.append("deleted Courses in %s" % dep.getId)
     229        return "\r".join(deleted)
     230    ###)   
     231   
    84232
    85233InitializeClass(WAeUPTool)
  • WAeUP_SRP/trunk/Widgets.py

    r1146 r1151  
    326326        valid = CPSStringWidget.validate(self, datastructure, **kw)
    327327        #import pdb;pdb.set_trace()
    328         pumeresults = self.portal_pumeresults
     328        pumeresults = self.pumeresults
    329329        if not valid:
    330330            return 0
     
    361361        valid = CPSStringWidget.validate(self, datastructure, **kw)
    362362        #import pdb;pdb.set_trace()
    363         registered = self.registered_import
     363        returning = self.returning_import
    364364        results = self.results_import
    365365        err = 0
     
    371371            #s = getStudentByRegNo(self,value)
    372372            while not err:
    373                 res = registered(matric_no = value)
     373                res = returning(matric_no = value)
    374374                if len(res) < 1:
    375375                    err = 'No Student with MatricNo %s.' % (value)
  • WAeUP_SRP/trunk/exportimport.py

    r1146 r1151  
    102102    importWAeUPTable(site.portal_pins, '', context,'pins')
    103103    importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults')
    104     importWAeUPTable(site.registered_import, '', context,'registered_import')
     104    importWAeUPTable(site.returning_import, '', context,'returning_import')
    105105    importWAeUPTable(site.results_import, '', context,'results_import')
    106106    importWAeUPTable(site.students_catalog, '', context,'students_catalog')
  • WAeUP_SRP/trunk/profiles/default/layouts/student_session_results_search.xml

    r1150 r1151  
    11<?xml version="1.0"?>
    2 <object name="student_session_result_search" meta_type="CPS Layout">
     2<object name="student_session_results_search" meta_type="CPS Layout">
    33 <property name="layout_create_method"></property>
    44 <property name="layout_edit_method"></property>
     
    77 <property name="flexible_widgets"/>
    88 <property name="validate_values_expr"></property>
     9 <property name="label"></property>
     10 <property name="label_edit"></property>
     11 <property name="is_i18n">False</property>
     12 <widget name="email" meta_type="Email Widget">
     13  <property name="title">Email</property>
     14  <property name="fields">
     15   <element value="email"/>
     16  </property>
     17  <property name="label">Email</property>
     18  <property name="label_edit">Email</property>
     19  <property name="readonly_layout_modes"/>
     20  <property name="hidden_layout_modes">
     21   <element value="create"/>
     22  </property>
     23  <property name="hidden_readonly_layout_modes"/>
     24 </widget>
     25 <widget name="jamb_reg_no" meta_type="String Widget">
     26  <property name="title">JAMP Registration Nr</property>
     27  <property name="fields">
     28   <element value="jamb_reg_no"/>
     29  </property>
     30  <property name="label">JAMP Registration Nr</property>
     31  <property name="label_edit">JAMP Registration Nr</property>
     32  <property name="readonly_layout_modes"/>
     33  <property name="hidden_layout_modes">
     34   <element value="create"/>
     35   <element value="edit"/>
     36  </property>
     37  <property name="hidden_readonly_layout_modes"/>
     38  <property name="display_width">10</property>
     39  <property name="size_max">10</property>
     40 </widget>
    941 <widget name="matric_no" meta_type="MatricNo Widget">
    1042  <property name="title">Matriculation Number</property>
     
    2254  <property name="size_max">10</property>
    2355 </widget>
     56 <widget name="password" meta_type="Password Widget">
     57  <property name="title">Password</property>
     58  <property name="fields">
     59   <element value="password"/>
     60  </property>
     61  <property name="is_required">True</property>
     62  <property name="label">Choose a Password</property>
     63  <property name="label_edit">Choose a Password</property>
     64  <property name="check_digit">True</property>
     65  <property name="password_widget"></property>
     66  <property name="readonly_layout_modes"/>
     67  <property name="hidden_layout_modes">
     68   <element value="create"/>
     69  </property>
     70  <property name="hidden_readonly_layout_modes"/>
     71 </widget>
     72 <widget name="repeat_password" meta_type="Password Widget">
     73  <property name="title">Password</property>
     74  <property name="fields">
     75   <element value="repeat_password"/>
     76  </property>
     77  <property name="is_required">False</property>
     78  <property name="label">Choose a Password</property>
     79  <property name="label_edit">Repeat Password</property>
     80  <property name="readonly_layout_modes"/>
     81  <property name="password_widget">password</property>
     82  <property name="hidden_layout_modes">
     83   <element value="create"/>
     84  </property>
     85  <property name="hidden_readonly_layout_modes"/>
     86  <property name="size_min">0</property>
     87 </widget>
    2488 <table>
    2589  <row>
    26    <cell name="matric_no" ncols="3"/>
     90   <cell name="matric_no" />
     91  </row>
     92  <row>
     93   <cell name="email" />
     94  </row>
     95  <row>
     96   <cell name="password" />
     97  </row>
     98  <row>
     99   <cell name="repeat_password" />
    27100  </row>
    28101 </table>
  • WAeUP_SRP/trunk/profiles/default/schemas.xml

    r1146 r1151  
    2020 <object name="student_personal" meta_type="CPS Schema"/>
    2121 <object name="student_pume" meta_type="CPS Schema"/>
     22 <object name="student_returning" meta_type="CPS Schema"/>
    2223 <object name="student_search" meta_type="CPS Schema"/>
    2324 <object name="student_study_course" meta_type="CPS Schema"/>
  • WAeUP_SRP/trunk/profiles/default/students_catalog.xml

    r1146 r1151  
    22<object name="portal_catalog" meta_type="WAeUP Table">
    33 <column value="id"/>
     4 <column value="matric_no"/>
    45 <column value="jamb_reg_no"/>
    56 <column value="name"/>
     
    1718  <indexed_attr value="jamb_reg_no"/>
    1819 </index>
     20 <index name="matric_no" meta_type="FieldIndex">
     21  <indexed_attr value="matric_no"/>
     22 </index>
    1923 <index name="faculty" meta_type="KeywordIndex">
    2024  <indexed_attr value="faculty"/>
  • WAeUP_SRP/trunk/profiles/default/toolset.xml

    r1146 r1151  
    1111 <required tool_id="portal_pumeresults"
    1212           class="Products.WAeUP_SRP.WAeUPTables.PumeResultsTable"/>
    13  <required tool_id="registered_import"
    14            class="Products.WAeUP_SRP.WAeUPTables.RegisteredImport"/>
     13 <required tool_id="returning_import"
     14           class="Products.WAeUP_SRP.WAeUPTables.ReturningImport"/>
    1515 <required tool_id="results_import"
    1616           class="Products.WAeUP_SRP.WAeUPTables.ResultsImport"/>
  • WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py

    r1096 r1151  
    3737        students = context.portal_url.getPortalObject().campus.students
    3838        student = getattr(students,str(member))
    39         student_app = getattr(student,'application')
     39        if request.has_key('email'):
     40            context.waeup_tool.makeStudentData(str(member),email=request.get("email"))
     41        student_app = getattr(student,'application',None)
     42        if student_app is None:
     43            context.waeup_tool.makeStudentData(str(member))
     44        student_app = getattr(student,'application',None)
    4045        student_pume = getattr(student,'pume',None)
    4146        s_review_state = wftool.getInfoFor(student,'review_state',None)
  • WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py

    r1060 r1151  
    7171                                              sex = ds.get('sex'),
    7272                                             )
     73    elif context.portal_type == "Course":
     74        context.courses_catalog.modifyRecord(**ds)
    7375    if cpsdocument_edit_and_view_button is not None:
    7476        action = ''
  • WAeUP_SRP/trunk/skins/waeup_student/display_session_results.py

    r1146 r1151  
    1515
    1616res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search',
    17                       schema_id= 'student_clearance',
     17                      schema_id= 'student_returning',
    1818                      context=context,
    1919                      mapping=validate and REQUEST,
     
    4040                                 )
    4141elif psm == 'valid':
     42##    context.waeup_tool.makeStudent(ds.get('student'),
     43##                                   results=ds.get('results'))
    4244    return context.session_results_anon_view(student=ds.get('student'),
    4345                                           results=ds.get('results'))
  • WAeUP_SRP/trunk/skins/waeup_student/display_session_results_form.pt

    r1146 r1151  
    11<tal:block define="rendered_main options/rendered;
    2                    portal_status_message options/psm;
    3                    data_storage options/ds;
    4                    edition python:1;"
     2           portal_status_message options/psm;
     3           data_storage options/ds;
     4           edition python:1;"
     5           >
     6  <metal:block define-macro="edit_form">
     7    <metal:block use-macro="here/content_lib_master/macros/master">
     8      <metal:block fill-slot="header"
     9                   tal:define="creation creation|nothing;
     10                   edition edition|nothing;
     11                   metadata metadata|nothing"
    512                   >
    6 <metal:block define-macro="edit_form">
    7   <metal:block use-macro="here/content_lib_master/macros/master">
    8   <metal:block fill-slot="header"
    9     tal:define="creation creation|nothing;
    10                 edition edition|nothing;
    11                 metadata metadata|nothing"
    12                 >
    13     </metal:block>
     13      </metal:block>
    1414      <metal:block fill-slot="main">
    1515        <h3>Display Your 2005/2006 Session Results! </h3>
  • WAeUP_SRP/trunk/skins/waeup_student/session_results_anon_view.pt

    r1149 r1151  
    5252        </span>
    5353      </table>
     54      <a href="" tal:attributes="href string:${context/absolute_url}/set_access_data?matric_no=${student/matric_no}">Continue to Email-entry</a>
    5455    </metal:main>
    5556  </metal:body>
Note: See TracChangeset for help on using the changeset viewer.