Changeset 1653 for WAeUP_SRP/branches


Ignore:
Timestamp:
28 Mar 2007, 02:35:25 (18 years ago)
Author:
uli
Message:

Incorporated changeset 1593:1652 of trunk into uli-branch.

Location:
WAeUP_SRP/branches/uli
Files:
44 edited
6 copied

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/branches/uli/PatchCPSUserFolderUserFolder.py

    r1593 r1653  
    8686                                                   "StudentStudyLevel"):
    8787            break
    88         # don't test if it is not a proxy
    89         if real_object.portal_type == real_object.meta_type:
    90             break
     88
     89        # don't test if it is not a proxy
     90        #if real_object.portal_type == real_object.meta_type:
     91        #    break
     92       
    9193        # can be later simplified by replacing by students_catalog values - Henrik
    9294        # getattr works always because of acquisition ?! Henrik
     
    9496        if sc is None:
    9597            break
    96         #from pdb import set_trace;set_trace()
    9798        sc_obj = sc.getContent()
    9899        cert_id = sc_obj.study_course
     
    121122                                                )
    122123        if real_object.portal_type == "StudentStudyLevel":
    123             context_obj = getattr(certificate_obj,real_object.getId(),None)
     124            if real_object.meta_type != "StudentStudyLevel":
     125                context_obj = getattr(certificate_obj,real_object.getId(),None)
     126            else:
     127                context_obj = getattr(certificate_obj,real_object.aq_parent.getId(),None)
    124128            if context_obj is None:
     129                #from pdb import set_trace;set_trace()
    125130                break
    126131            allowed = set(('CourseAdviser', 'SectionManager'))
    127132        elif real_object.portal_type == "Student" and "CourseAdvisers" in groups:
    128             #we need some special processing since CourseAdvisers are only 
     133            #we need some special processing since CourseAdvisers are only
    129134            #specified per StudyLevel
    130135            allowed = set(('CourseAdviser', 'SectionManager'))
  • WAeUP_SRP/branches/uli/PatchCatalogToolXMLAdapter.py

    r1062 r1653  
    2121        inds[ind.attributes.items()[1][1]] = ind.attributes.items()[0][1]
    2222        #print ind.attributes.items()
    23     #print "indexes: ", inds
     23    #from pdb import set_trace; set_trace()
    2424    na = node.attributes.items()
    2525    not_found = True
    2626    new_indexes = []
    2727    new_columns = []
    28     if na[0][1] in ("WAeUP Table"):
    29         not_found = False
    30     elif na[0][1] == "CMF Catalog":
     28    if na[0][1] in ("CMF Catalog","WAeUP Table"):
    3129        #print na[1][1]
    3230        not_found = False
     
    4947            not_found = True
    5048    if not_found:
    51         self._initProperties(node)
    52         self._initObjects(node)
    53         self._initIndexes(node)
     49        self._logger.info("%s modified." % na[1][1])
     50        #self._initProperties(node)
     51        #self._initObjects(node)
     52        if new_indexes and len(self.context()) == 0: #disable creation of new indexes if records in the table
     53            self._initIndexes(node)
    5454        self._initColumns(node)
    55         self._refreshCatalog()
     55        #self._refreshCatalog()
    5656
    57     self._logger.info("Catalog tool imported.")
     57    self._logger.info("Catalog tool %s imported."  % na[1][1])
    5858   
    5959from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
  • WAeUP_SRP/branches/uli/Students.py

    r1593 r1653  
    1616from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
    1717from Products.WAeUP_SRP.Academics import makeCertificateCode
     18from Products.AdvancedQuery import Eq, Between, Le,In
    1819import logging
    1920import csv,re,os
     
    2223i_home = Globals.INSTANCE_HOME
    2324MAX_TRANS = 1000
     25from urllib import urlencode
     26
    2427import DateTime
    2528# import PIL.Image
     
    3639
    3740###)
     41
     42def response_write(response,s):
     43    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
     44    while s.find('<') > -1:
     45        s = s.replace('<','&lt;')
     46    while s.find('>') > -1:
     47        #from pdb import set_trace;set_trace()
     48        s = s.replace('>','&gt;')
     49    response.write("%s<br>\n" % s)
    3850
    3951def getInt(s): ###(
     
    8193    portal_type = meta_type
    8294    security = ClassSecurityInfo()
    83 
    84 
    8595
    8696    security.declareProtected(ModifyPortalContent,"createDEStudents")###(
     
    537547        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
    538548        students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()
     549        #students_folder = self.portal_url().getPortalObject().campus.students
    539550        tr_count = 1
    540551        total = 0
     
    701712        logger.info(em)
    702713        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     714    ###)
     715
     716    security.declareProtected(ModifyPortalContent,"fixAllNames")###(
     717    def fixAllNames(self):
     718        "fix all students names"
     719        import transaction
     720        response = self.REQUEST.RESPONSE
     721        logger = logging.getLogger('fixAllNames')
     722        logger.info('Start')
     723        students = self.portal_catalog(portal_type='Student')
     724        count = 0
     725        total = 0
     726        for student in students:
     727            scat_res = self.students_catalog(id = student.getId)
     728            if not scat_res:
     729                self.students_catalog.addRecord(id = student.getId)
     730                scat_res = self.students_catalog(id = student.getId)
     731            student_entry = scat_res[0]
     732            old_new = self.fixName(student,student_entry)
     733            count += 1
     734            response_write(response,'"%d","%s",%s' % (count + total,student_entry.id,old_new))
     735            if count > 2000:
     736                transaction.commit()
     737                logger.info("%d transactions commited" % count)
     738                total += count
     739                count = 0
     740    ###)
     741
     742    security.declareProtected(ModifyPortalContent,"fixName")###(
     743    def fixName(self,student_brain, student_entry):
     744        "fix the name of a student"
     745        fix = "first"
     746        if student_entry.get('name_fixed',None) == fix:
     747            return "Name already fixed"
     748        student_id = student_entry.id
     749        new_student = student_entry.jamb_reg_no.startswith('6')
     750        student_obj = student_brain.getObject()
     751        personal = getattr(student_obj,'personal',None)
     752        invalid = ''
     753        if personal is None:
     754            return '"%s","Returning","%s","%s"' % (invalid,student_entry.name,"not logged in")
     755        per_doc = personal.getContent()
     756        old_first = per_doc.firstname
     757        old_middle = per_doc.middlename
     758        old_last = per_doc.lastname
     759        new_first = ''
     760        new_middle = ''
     761        new_last = ''
     762        if new_student:
     763            if not old_first and not old_middle and old_last:
     764                new_names = [n.capitalize() for n in old_last.split()]
     765                if len(new_names) > 1:
     766                    old_first = new_names[0]
     767                    old_last = new_names[-1]
     768                    old_middle = ' '.join(new_names[1:-1])
     769                else:
     770                    old_last = new_names[0]
     771                    old_first = ''
     772                    old_middle = ''
     773            if old_first:
     774                new_first = old_first
     775            if old_middle:
     776                new_middle = old_middle
     777            if old_last:
     778                new_last = old_last
     779            if old_first.find('<') != -1 or\
     780               old_first.find('>') != -1 or\
     781               old_middle.find('<') != -1 or\
     782               old_middle.find('>') != -1 or\
     783               old_last.find('<') != -1 or\
     784               old_last.find('>') != -1:
     785                   invalid = "invalid characters"
     786        else:
     787            new_first = old_first
     788            if new_first.strip() == '-':
     789                new_first = ''
     790            new_middle = old_middle
     791            if new_middle.strip() == '-':
     792                new_middle = ''
     793            new_last = old_last
     794            if new_last.strip() == '-':
     795                new_last = ''
     796        name = "%(new_first)s %(new_middle)s %(new_last)s" % vars()
     797        if new_student:
     798            text = "New"
     799        else:
     800            text = "Returning"
     801        old_new = '"%s","%s","%s","%s"' % (invalid,text,
     802                                           student_entry.name,
     803                                           name)
     804        if not invalid:
     805            self.students_catalog.modifyRecord(id = student_id,
     806                                      name_fixed = fix,
     807                                      name = name)
     808            per_doc.edit(mapping = {'firstname' : new_first,
     809                                'middlename' : new_middle,
     810                                'lastname' : new_last,
     811                                })
     812        return old_new
    703813    ###)
    704814
     
    11141224    ###)
    11151225
    1116 
    1117 
    1118     security.declareProtected(View,"fixOwnership")
     1226    security.declareProtected(View,"fixOwnership") ###(
    11191227    def fixOwnership(self):
    11201228        """fix Ownership"""
     
    11251233            student.application.manage_setLocalRoles(sid, ['Owner',])
    11261234            student.personal.manage_setLocalRoles(sid, ['Owner',])
    1127 
    1128     security.declareProtected(View,"Title")
     1235    ###)
     1236
     1237    security.declareProtected(View,"Title") ###(
    11291238    def Title(self):
    11301239        """compose title"""
    11311240        return "Student Section"
     1241    ###)
    11321242
    11331243    def generateStudentId(self,letter): ###(
     
    11461256InitializeClass(StudentsFolder)
    11471257
    1148 def addStudentsFolder(container, id, REQUEST=None, **kw):
     1258def addStudentsFolder(container, id, REQUEST=None, **kw): ###(
    11491259    """Add a Student."""
    11501260    ob = StudentsFolder(id, **kw)
    11511261    return CPSBase_adder(container, ob, REQUEST=REQUEST)
     1262    ###)
     1263
    11521264###)
     1265
    11531266
    11541267class Student(CPSDocument): ###(
     
    13161429        return "Level %s" % self.aq_parent.getId()
    13171430
    1318 ##    security.declarePublic("gpa")
    1319 ##    def gpa(self):
    1320 ##        """calculate the gpa"""
    1321 ##        sum = 0
    1322 ##        course_count = 0
    1323 ##        for sc in self.objectValues():
    1324 ##            result = sc.getContent()
    1325 ##            if not result.grade:
    1326 ##                continue
    1327 ##            res = self.portal_catalog({'meta_type': 'Course',
    1328 ##                                          'id': sc.aq_parent.id})
    1329 ##            if len(res) != 1:
    1330 ##                continue
    1331 ##            course = res[0].getObject().getContent()
    1332 ##            sum += course.credits * ['F','E','D','C','B','A'].index(result.grade)
    1333 ##            course_count += 1
    1334 ##        if course_count:
    1335 ##            return sum/course_count
    1336 ##        return 0.0
     1431    def create_course_results(self,cert_id,current_level):
     1432        "create all courses in a level"
     1433        aq_portal = self.portal_catalog.evalAdvancedQuery
     1434        res = self.portal_catalog(portal_type="Certificate", id = cert_id)
     1435        l = []
     1436        import transaction
     1437        if res:
     1438            cert = res[0]
     1439            path = cert.getPath()
     1440            query = Eq("path","%s/%s" % (path,current_level)) &\
     1441                    Eq('portal_type','CertificateCourse')
     1442            courses = aq_portal(query)
     1443            #from pdb import set_trace;set_trace()
     1444            self_proxy = self.aq_parent
     1445            for c in courses:
     1446                d = self.getCourseInfo(c.getId)
     1447                cr_id = self_proxy.invokeFactory('StudentCourseResult',c.getId)
     1448                course_result = getattr(self_proxy,cr_id)
     1449                self.portal_workflow.doActionFor(course_result,'open')
     1450                d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     1451                course_result.getContent().edit(mapping=d)
     1452                transaction.commit()
    13371453
    13381454InitializeClass(StudentStudyLevel)
  • WAeUP_SRP/branches/uli/WAeUPTables.py

    r1593 r1653  
    2222from Globals import InitializeClass
    2323from Products.ZCatalog.ZCatalog import ZCatalog
     24from Products.ZCatalog.ProgressHandler import ZLogHandler
    2425from AccessControl import ClassSecurityInfo
    2526from Products.CMFCore.permissions import ModifyPortalContent
    2627
    27 import DateTime
     28import DateTime,time
    2829import csv,re
    2930import logging
     
    4849    implements(IWAeUPTable)
    4950    security = ClassSecurityInfo()
     51
     52    def refreshCatalog(self, clear=0, pghandler=None):
     53        """ don't refresh for a normal table """
     54
     55        if self.REQUEST and self.REQUEST.RESPONSE:
     56            self.REQUEST.RESPONSE.redirect(
     57              URL1 +
     58              '/manage_catalogAdvanced?manage_tabs_message=Catalog%20refresh%20not%20implemented')
     59
     60    def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
     61        """ clears the whole enchilada """
     62        #self._catalog.clear()
     63
     64        if REQUEST and RESPONSE:
     65            RESPONSE.redirect(
     66              URL1 +
     67              '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Clearing%20disabled')
    5068
    5169    def addRecord(self, **data):
     
    7593            raise KeyError("No record for uid %s" % uid)
    7694        record = records[0]
    77         record_data = {}
    78         for field in self.schema() + self.indexes():
    79             record_data[field] = getattr(record, field)
    8095        record_data = {}
    8196        for field in self.schema() + self.indexes():
     
    210225
    211226class StudentsCatalog(WAeUPTable): ###(
     227    security = ClassSecurityInfo()
    212228
    213229    meta_type = 'WAeUP Students Catalog'
    214230    name = "students_catalog"
    215231    key = "id"
     232    interesting_types = ('Student',
     233                         'StudentApplication',
     234                         'StudentCLearance',
     235                         'StudentPersonal',
     236                         'StudentStudyCourse',
     237                         )
     238
    216239    def __init__(self):
    217240        WAeUPTable.__init__(self, 'students_catalog')
     241        return
     242
     243    def get_review_state(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): ###(
     244        "return the students review_state from portal_catalog"
     245        cat_res = self.portal_catalog(id = sid)
     246        if len(cat_res) != 1:
     247            return None
     248        return cat_res[0].review_state
     249
     250    def get_course(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     251        "return the students study_course"
     252        if study_course_doc is None:
     253            return None
     254        return getattr(study_course_doc,'study_course',None)
     255
     256    def get_department(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     257        "return the students department"
     258        if study_course_doc is None:
     259            return None
     260        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
     261        if len(certificate_res) != 1:
     262            return None
     263        return certificate_res[0].getPath().split('/')[-3]
     264
     265    def get_email(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     266        "return the students email from the personal"
     267        if personal_doc is None:
     268            return None
     269        return getattr(personal_doc,'email',None)
     270
     271    def get_entry_mode(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     272        "return the students entry_mode from the application"
     273        if application_doc is None:
     274            return None
     275        return getattr(application_doc,'entry_mode',None)
     276
     277    def get_jamb_reg_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     278        "return the students jamb_reg_no from the application"
     279        if application_doc is None:
     280            return None
     281        return getattr(application_doc,'jamb_reg_no',None)
     282
     283    def get_faculty(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     284        "return the students faculty"
     285        if study_course_doc is None:
     286            return None
     287        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
     288        if len(certificate_res) != 1:
     289            return None
     290        return certificate_res[0].getPath().split('/')[-4]
     291
     292    def get_level(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     293        "return the students study_course"
     294        if study_course_doc is None:
     295            return None
     296        #from pdb import set_trace;set_trace()
     297        return getattr(study_course_doc,'current_level',None)
     298
     299    def get_matric_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     300        "return the students matric_no from the clearance "
     301        if clearance_doc is None:
     302            return None
     303        return getattr(clearance_doc,'matric_no',None)
     304
     305    def get_name(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     306        "return the students name from the personal"
     307        if personal_doc is None:
     308            return None
     309        doc = personal_doc
     310        return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname)
     311
     312    def get_phone(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     313        "return the students phone from the personal"
     314        if personal_doc is None:
     315            return None
     316        return getattr(personal_doc,'phone',None)
     317
     318    def get_sex(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     319        "return the students sex from the personal"
     320        if personal_doc is None:
     321            return None
     322        return getattr(personal_doc,'sex',None)
     323
     324    def get_verdict(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
     325        "return the students study_course"
     326        if study_course_doc is None:
     327            return None
     328        return getattr(study_course_doc,'current_verdict',None)
     329    ###)
     330
     331    def refreshCatalog(self, clear=0, pghandler=None): ###(
     332        """ re-index everything we can find """
     333        students_folder = self.portal_url.getPortalObject().campus.students
     334
     335        cat = self._catalog
     336        paths = self._catalog.uids.items()
     337        if clear:
     338            paths = tuple(paths)
     339            cat.clear()
     340
     341        num_objects = len(paths)
     342        if pghandler:
     343            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
     344        for i in xrange(num_objects):
     345            if pghandler: pghandler.report(i)
     346            p = paths[i]
     347            sid = p[0]
     348            pcat_res = self.portal_catalog(id=sid)
     349            if len(pcat_res) != 1:
     350                continue
     351            student_brain = pcat_res[0]
     352            student_obj = student_brain.getObject()
     353            if student_obj.hasObject('application'):
     354                application_doc = getattr(student_obj,'application').getContent()
     355            else:
     356                application_doc = None
     357            if student_obj.hasObject('clearance'):
     358                clearance_doc = getattr(student_obj,'clearance').getContent()
     359            else:
     360                clearance_doc = None
     361            if student_obj.hasObject('personal'):
     362                personal_doc = getattr(student_obj,'personal').getContent()
     363            else:
     364                personal_doc = None
     365            if student_obj.hasObject('study_course'):
     366                study_course_doc = getattr(student_obj,'study_course').getContent()
     367            else:
     368                study_course_doc = None
     369            data = {}
     370            data['id'] = sid
     371            for field in self.schema():
     372                function = getattr(self,"get_%s" % field, None)
     373                if function is None:
     374                    continue
     375                value = function(sid,application_doc,clearance_doc,personal_doc,study_course_doc)
     376                if value is not None:
     377                    data[field] = value
     378            self.modifyRecord(**data)
     379        if pghandler: pghandler.finish()
     380    ###)
     381
     382    def manage_catalogReindex(self, REQUEST, RESPONSE, URL1):
     383        """ clear the catalog, then re-index everything """
     384
     385        elapse = time.time()
     386        c_elapse = time.clock()
     387
     388        pgthreshold = self._getProgressThreshold()
     389        handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None
     390        self.refreshCatalog(clear=0, pghandler=handler)
     391
     392        elapse = time.time() - elapse
     393        c_elapse = time.clock() - c_elapse
     394
     395        RESPONSE.redirect(
     396            URL1 +
     397            '/manage_catalogAdvanced?manage_tabs_message=' +
     398            urllib.quote('Catalog Updated \n'
     399                         'Total time: %s\n'
     400                         'Total CPU time: %s' % (`elapse`, `c_elapse`)))
     401
     402
     403    security.declarePrivate('notify_event_listener')
     404    def notify_event_listener(self,event_type,object,infos):
     405        "listen for events"
     406        pt = object.portal_type
     407        mt = object.meta_type
     408        students_catalog = self.students_catalog
     409        #if pt not in self.interesting_types:
     410        #    return
     411        #print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
     412        if not infos.has_key('rpath'):
     413            return
     414        if pt == 'Student' and event_type == "workflow":
     415            pass
     416        elif mt == 'StudentApplication':
     417            if event_type not in ('sys_modify_object'):
     418                return
     419            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
     420            from pdb import set_trace;set_trace()
     421            jamb_reg_no = getattr(object,'jamb_reg_no',None)
     422            if jamb_reg_no is None:
     423                return
     424            student_id = infos['rpath'].split('/')[2]
     425            self.fixName(student_id)
     426            student_entry = students_catalog(id = student_id)[0]
     427            if student_entry.jamb_reg_no == jamb_reg_no:
     428                return
     429            students_catalog.modifyRecord(id = student_id,
     430                                          jamb_reg_no = jamb_reg_no)
     431        elif mt == 'StudentPersonal':
     432            if event_type not in ('sys_modify_object'):
     433                return
     434            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
     435            student_id = infos['rpath'].split('/')[2]
     436            self.fixName(student_id)
    218437
    219438
     
    234453###)
    235454
     455class OnlinePaymentsImport(WAeUPTable): ###(
     456
     457    meta_type = 'WAeUP Online Payment Transactions'
     458    name = "online_payments_import"
     459    key = "order_id"
     460    def __init__(self):
     461        WAeUPTable.__init__(self, self.name)
     462
     463
     464InitializeClass(CoursesCatalog)
     465###)
     466
    236467class ReturningImport(WAeUPTable): ###(
    237468
  • WAeUP_SRP/branches/uli/WAeUPTool.py

    r1593 r1653  
    3838p_home = package_home(globals())
    3939i_home = INSTANCE_HOME
    40 import logging,os
     40import DateTime
     41import logging
    4142import transaction
    42 
    43 
    44 
     43import csv,re,os
    4544
    4645class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
     
    113112    ###)
    114113
    115     security.declareProtected(ModifyPortalContent,'doCommit') ###(
     114    security.declareProtected(View,'doCommit') ###(
    116115    def doCommit(self,logger=None):
    117116        "commit some transactions"
     
    532531    ###)
    533532
     533    security.declareProtected(ModifyPortalContent,"importOnlinePaymentTransactions")###(
     534    def importOnlinePaymentTransactions(self):
     535        """load Online Payment Transactions from CSV values"""
     536        import transaction
     537        import random
     538        #from pdb import set_trace
     539        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     540        opt = self.online_payments_import
     541        students_folder = self.portal_url.getPortalObject().campus.students
     542        start = True
     543        tr_count = 1
     544        total = 0
     545        #name = 'pume_results'
     546        name = 'OnlineTransactions'
     547        no_import = []
     548        imported = []
     549        logger = logging.getLogger('WAeUPTool.importOnlinePaymentTransactions')
     550        try:
     551            transactions = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     552        except:
     553            logger.error('Error reading %s.csv' % name)
     554            return
     555        for pay_transaction in transactions:
     556            if start:
     557                start = False
     558                logger.info('Start loading from %s.csv' % name)
     559                s = ','.join(['"%s"' % fn for fn in pay_transaction.keys()])
     560                no_import.append('%s,"Error"' % s)
     561                format = ','.join(['"%%(%s)s"' % fn for fn in pay_transaction.keys()])
     562                format_error = format + ',"%(Error)s"'
     563            data = {}
     564
     565            # format of the first file sent from Tayo
     566            #data['datetime'] = date = DateTime.DateTime(pay_transaction['Date'])
     567            #data['student_id'] = student_id = pay_transaction['Payer ID']
     568            #data['order_id'] = order_id = pay_transaction['Order ID (Tranx Ref)']
     569            #data['response_code'] = response_code = pay_transaction['Resp Code']
     570            #data['amount'] = amount = pay_transaction['Amount']
     571
     572            # format of the second file sent from Tayo
     573            data['datetime'] = date = 0
     574            data['student_id'] = student_id = pay_transaction['Payer ID']
     575            data['order_id'] = order_id = pay_transaction['Order ID (Tranx Ref)']
     576            data['response_code'] = response_code = '00'
     577            data['amount'] = amount = pay_transaction['Amount']
     578
     579            dup = False
     580            if response_code == "12":
     581                continue
     582            try:
     583                opt.addRecord(**data)
     584            except ValueError:
     585                dup = True
     586            #from pdb import set_trace;set_trace()
     587            if dup:
     588                if response_code == "00":
     589                    opt.modifyRecord(**data)
     590                else:
     591                    pay_transaction['Error'] = "Duplicate order Id"
     592                    no_import.append( format_error % pay_transaction)
     593                    logger.info("dupplicate order_id %(order_id)s for %(student_id)s %(response_code)s" % data)
     594                    continue
     595            tr_count += 1
     596            if tr_count > 1000:
     597                if len(no_import) > 0:
     598                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
     599                             '\n'.join(no_import) + '\n')
     600                    no_import = []
     601                em = '%d transactions committed\n' % (tr_count)
     602                transaction.commit()
     603                regs = []
     604                logger.info(em)
     605                total += tr_count
     606                tr_count = 0
     607        open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
     608                                                '\n'.join(no_import))
     609        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     610    ###)
     611
    534612InitializeClass(WAeUPTool)
  • WAeUP_SRP/branches/uli/doc/srp_documentation.mm

    r1530 r1653  
    88</node>
    99<node CREATED="1172489529057" ID="Freemind_Link_43083883" MODIFIED="1172489545651" POSITION="right" TEXT="SRP Data Structure">
    10 <node CREATED="1170079621592" FOLDED="true" ID="Freemind_Link_1297017754" MODIFIED="1170079640872" TEXT="Campus">
     10<node CREATED="1170079621592" ID="Freemind_Link_1297017754" MODIFIED="1170079640872" TEXT="Campus">
    1111<node CREATED="1171710559043" ID="Freemind_Link_1592396213" MODIFIED="1171710565212" TEXT="Id: campus"/>
    1212<node CREATED="1170079643589" FOLDED="true" ID="Freemind_Link_1231068129" MODIFIED="1171710686426" TEXT="Academic Section">
     
    4848</node>
    4949</node>
    50 <node CREATED="1170082138244" FOLDED="true" ID="Freemind_Link_1354366927" MODIFIED="1171710679266" TEXT="Student Section">
     50<node CREATED="1170082138244" ID="Freemind_Link_1354366927" MODIFIED="1171710679266" TEXT="Student Section">
    5151<node CREATED="1171709784119" ID="_" MODIFIED="1171709937449" TEXT="Type: StudentsFolder" VSHIFT="104"/>
    5252<node CREATED="1171710545564" ID="Freemind_Link_221165828" MODIFIED="1171710551332" TEXT="Id: students"/>
    53 <node CREATED="1170082147831" FOLDED="true" ID="Freemind_Link_115332414" MODIFIED="1171709774415" TEXT="{Student}">
     53<node CREATED="1170082147831" ID="Freemind_Link_115332414" MODIFIED="1171709774415" TEXT="{Student}">
    5454<node CREATED="1171114205479" ID="Freemind_Link_1051911128" LINK="../profiles/default/types/Student.xml" MODIFIED="1171353141707" TEXT="Type: Student"/>
    5555<node CREATED="1171124926993" ID="Freemind_Link_1838352082" LINK="../profiles/default/schemas/student.xml" MODIFIED="1171353152905" TEXT="Schema: student"/>
     
    171171</node>
    172172</node>
    173 <node CREATED="1170082392807" FOLDED="true" ID="Freemind_Link_1979443941" MODIFIED="1171711179966" TEXT="Study Course">
     173<node CREATED="1170082392807" ID="Freemind_Link_1979443941" MODIFIED="1171711179966" TEXT="Study Course">
    174174<node CREATED="1170930140692" ID="Freemind_Link_607082969" MODIFIED="1171009488850" TEXT="Id: study_course"/>
    175175<node CREATED="1170930264337" ID="Freemind_Link_1384807180" LINK="../profiles/default/types/StudentStudyCourse.xml" MODIFIED="1172159914623" TEXT="Type: StudentStudyCourse"/>
  • WAeUP_SRP/branches/uli/exportimport.py

    r1515 r1653  
    9090                                              roles=('SectionReader',))
    9191            students.manage_setLocalGroupRoles(groupid = 'CourseAdvisers',
    92                                               roles=('SectionReader',))                                             
     92                                              roles=('SectionReader',))
    9393            students.manage_setLocalGroupRoles(groupid='MemberAdmins',
    9494                                         roles=('SectionOfficer',))
     
    120120    importWAeUPTable(site.courses_catalog, '', context,'courses_catalog')
    121121    importWAeUPTable(site.payments_catalog, '', context,'payments_catalog')
     122    importWAeUPTable(site.online_payments_import, '', context,'online_payments_import')
    122123    importWAeUPTable(site.portal_pins, '', context,'pins')
    123124    importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults')
  • WAeUP_SRP/branches/uli/profiles/default/actions.xml

    r1474 r1653  
    177177  <action title="Change Password" action_id="change_password"
    178178     category="student" condition_expr="member"
    179      url_expr="string:${portal_url}/change_password" visible="True">
     179     url_expr="string:${portal_url}/change_password" visible="False">
    180180   <permission>View</permission>
    181181  </action>
  • WAeUP_SRP/branches/uli/profiles/default/courses_catalog.xml

    r1410 r1653  
    11<?xml version="1.0"?>
    22<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
    3 <object name="courses_catalog" meta_type="WAeUP Table">
     3<object name="courses_catalog" meta_type="CMF Catalog">
    44 <column value="code"/>
    55 <column value="faculty"/>
  • WAeUP_SRP/branches/uli/profiles/default/layouts/student_change_password.xml

    r1474 r1653  
    3535    <property name="hidden_readonly_layout_modes"/>
    3636    <property name="password_widget"></property>
    37     <property name="check_digit">False</property>
     37    <property name="check_digit">True</property>
    3838    <property name="size_min">6</property>
    3939    <property name="size_max">10</property>
  • WAeUP_SRP/branches/uli/profiles/default/schemas/payment.xml

    r1399 r1653  
    66  <field name="type_description" meta_type="CPS String Field" >
    77    <property name="is_searchabletext">True</property>
    8   </field> <field name="order_id" meta_type="CPS String Field"/>
     8  </field>
    99  <field name="amount" meta_type="CPS String Field"/>
    1010  <field name="resp_pay_reference" meta_type="CPS String Field"/>
  • WAeUP_SRP/branches/uli/profiles/default/schemas/student_study_level.xml

    r1399 r1653  
    44 <field name="code" meta_type="CPS String Field"/>
    55 <field name="session" meta_type="CPS String Field"/>
    6  <field name="gpa" meta_type="CPS Float Field"/>
    7  <field name="status" meta_type="CPS String Field"/>
    86 <field name="verdict" meta_type="CPS String Field"/>
    9   <field name="imported_gpa" meta_type="CPS Float Field"/>
     7 <field name="validated_by" meta_type="CPS String Field"/>
     8 <field name="validation_date" meta_type="CPS DateTime Field"/>
    109</object>
  • WAeUP_SRP/branches/uli/profiles/default/students_catalog.xml

    r1403 r1653  
    1919 </index>
    2020 <index name="jamb_reg_no" meta_type="FieldIndex">
    21   <indexed_attr value="student_application:jamb_reg_no"/>
     21  <indexed_attr value="jamb_reg_no"/>
    2222 </index>
    2323 <index name="matric_no" meta_type="FieldIndex">
    24   <indexed_attr value="student_clearance:matric_no"/>
     24  <indexed_attr value="matric_no"/>
    2525 </index>
    2626 <index name="faculty" meta_type="KeywordIndex">
     
    2828 </index>
    2929 <index name="entry_mode" meta_type="KeywordIndex">
    30   <indexed_attr value="student_application:entry_mode"/>
     30  <indexed_attr value="entry_mode"/>
    3131 </index>
    3232 <index name="department" meta_type="KeywordIndex">
     
    3434 </index>
    3535 <index name="level" meta_type="KeywordIndex">
    36   <indexed_attr value="student_study_course:current_level"/>
     36  <indexed_attr value="current_level"/>
    3737 </index>
    3838 <index name="verdict" meta_type="KeywordIndex">
    39   <indexed_attr value="student_study_course:current_verdict"/>
     39  <indexed_attr value="current_verdict"/>
    4040 </index>
    4141 <index name="course" meta_type="KeywordIndex">
    42   <indexed_attr value="student_study_course:study_course"/>
     42  <indexed_attr value="study_course"/>
    4343 </index>
    4444</object>
  • WAeUP_SRP/branches/uli/profiles/default/toolset.xml

    r1151 r1653  
    77 <required tool_id="payments_catalog"
    88           class="Products.WAeUP_SRP.WAeUPTables.PaymentsCatalog"/>
     9 <required tool_id="online_payments_import"
     10           class="Products.WAeUP_SRP.WAeUPTables.OnlinePaymentsImport"/>
    911 <required tool_id="portal_pins"
    1012           class="Products.WAeUP_SRP.WAeUPTables.PinTable"/>
  • WAeUP_SRP/branches/uli/profiles/default/workflows/waeup_student_subobject_wf/definition.xml

    r1515 r1653  
    99 <permission>Modify portal content</permission>
    1010 <permission>View</permission>
     11 <permission>View</permission>
    1112 <state state_id="closed" title="">
     13  <exit-transition transition_id="create_content"/>
    1214  <exit-transition transition_id="open"/>
    1315  <permission-map name="Add portal content" acquired="True">
     
    103105             new_state="closed" trigger="USER"
    104106             before_script="" after_script="">
    105  
     107
    106108  <guard>
    107109   <guard-role>SectionOfficer</guard-role>
     
    115117             new_state="content_addable" trigger="USER"
    116118             before_script="" after_script="">
    117  
     119
    118120  <guard>
    119121   <guard-role>SectionOfficer</guard-role>
     
    127129             new_state="created" trigger="USER"
    128130             before_script="" after_script="">
    129  
     131
    130132  <guard>
    131133  </guard>
     
    136138             new_state="" trigger="USER" before_script=""
    137139             after_script="">
    138  
     140
    139141  <guard>
    140142  </guard>
     
    144146             new_state="opened" trigger="USER"
    145147             before_script="" after_script="">
    146  
     148
    147149  <guard>
    148150   <guard-role>SectionOfficer</guard-role>
  • WAeUP_SRP/branches/uli/skins/waeup_academics/getCertificateInfo.py

    r913 r1653  
    1818
    1919info = {}
    20 info['action'] = "%s" % context.campus.absolute_url()
     20info['action'] = "%s" % context.absolute_url()
    2121info['choosen_ids'] = request.get('ids',[])
    2222info['doc'] = context.getContent()
  • WAeUP_SRP/branches/uli/skins/waeup_academics/getLevelInfo.py

    r1514 r1653  
    1616wf = context.portal_workflow
    1717mtool = context.portal_membership
     18academics_path = "%s/campus/academics" % context.portal_url()
    1819path_info = request.get('PATH_INFO').split('/')
    1920try:
     
    4445    ro = r.getObject()
    4546    rd = ro.getContent()
    46     row['id'] = r.getId
     47    course_id = row['id'] = r.getId
    4748    row['title'] = rd.Title()
    4849    row['core'] = rd.core_or_elective
     
    5051    row['url'] = ro.absolute_url()
    5152    row['review_state'] = wf.getInfoFor(ro,'review_state','None')
    52     row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
     53    editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
     54    if editable:
     55        course_res = context.courses_catalog(code=course_id)
     56        if course_res:
     57            rc = course_res[0]
     58            row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,rc.faculty,rc.department,course_id)
    5359    if rd.semester == 'first':
    5460        first.append(row)
  • WAeUP_SRP/branches/uli/skins/waeup_academics/level_view.pt

    r1511 r1653  
    4848                    [edit]
    4949                    </a>
     50                <a tal:condition="row/real_course_path|nothing"
     51                   href="edit" tal:attributes="href string:${row/real_course_path}">
     52                    [goto course]
     53                    </a>
    5054                </td>
    5155              </tr>
  • WAeUP_SRP/branches/uli/skins/waeup_default/mail2admin.py

    r976 r1653  
    3737     email,
    3838     'kehindesamuel@waeup.org',
    39      'henrik@waeup.org',
     39     'waeup@saoas.org',
    4040#    'js@aixtraware.de',
    4141     email,
  • WAeUP_SRP/branches/uli/skins/waeup_epayment/epayment_cb.py

    r1593 r1653  
    1414import logging
    1515logger = logging.getLogger('Skins.epayment_cb')
     16from AccessControl import Unauthorized
    1617import DateTime
    1718if context.portal_membership.isAnonymousUser():
     
    2122students = context.portal_url.getPortalObject().campus.students
    2223wftool = context.portal_workflow
     24mtool = context.portal_membership
     25member = mtool.getAuthenticatedMember()
     26member_id = str(member)
    2327student_id = context.getStudentId()
    24 if student_id is None:
     28if student_id is None or student_id != member_id:
     29    logger.info('%s tried to access payment object of %s' % (member_id,student_id))
     30    referer = request.get('HTTP_REFERER','none')
     31    logger.info('%s:%s illegal access, referer = %s' % (member_id,student_id,referer))
     32    real_ip = request.get('HTTP_X_REAL_IP',"none")
     33    logger.info('%s:%s illegal access, real_x_ip = %s' % (member_id,student_id,real_ip))
    2534    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
    2635
     
    3746for rc,pdk in resp_codes:
    3847    pd[pdk] = request.get(rc)
    39 context.getContent().edit(mapping=pd)
     48try:
     49    context.getContent().edit(mapping=pd)
     50except UnAuthorized,E:
     51    logger.info('%s ' % student_id)
     52
    4053#resp = pd['resp_desc']
    4154#if  resp.startswith('Appro') and resp.endswith('essful'):
     
    4457    wftool.doActionFor(student,'pay_school_fee')
    4558    logger.info('%s received valid callback' % student_id)
     59    referer = request.get('HTTP_REFERER','none')
     60    logger.info('%s valid callback referer = %s' % (student_id,referer))
     61    real_ip = request.get('HTTP_X_REAL_IP',"none")
     62    logger.info('%s valid callback real_ip = %s' % (student_id,real_ip))
    4663
    4764elif len(resp) < 3:
  • WAeUP_SRP/branches/uli/skins/waeup_epayment/getPaymentsFolderInfo.py

    r1593 r1653  
    5353    else:
    5454        row['is_approvable'] = is_so and (review_state == "opened")
    55     if (review_state == "closed") and so_object.resp_code in ('SC','00','AP',):
     55    if so_object.type_description.startswith('School Fee'):
     56        row['is_requeryable'] = (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
     57    else:
     58        row['is_requeryable'] = is_so and (review_state == "opened")
     59    if (review_state == "closed") and so_object.resp_code in ('SC','00','AP','IP',):
    5660        row['confirmed'] = 'active'
    5761    else:
  • WAeUP_SRP/branches/uli/skins/waeup_epayment/pay_online.py

    r1593 r1653  
    9191info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id)
    9292
    93 logger.info('%(student_id)s initiated online school fee payment' % info)
     93logger.info('%(student_id)s initiated online school fee payment with order_id %(order_id)s and callback url %(callback_url)s' % info)
    9494payment_fields = (('x_SiteID','site_id'),
    9595                  ('x_Redirect_url','callback_url'),
  • WAeUP_SRP/branches/uli/skins/waeup_epayment/payment_receipt.pt

    r1427 r1653  
    88      <span tal:condition="info">
    99     
    10         <metal:block tal:condition="python:info_doc['doc'].resp_code in ('00','AP',)">           
     10        <metal:block tal:condition="python:info_doc['doc'].resp_code in ('00','AP','IP')">           
    1111        <h3>Online Payment Receipt</h3>
    1212        <br />
     
    106106        </metal:block>
    107107       
    108         <metal:block tal:condition="python:info_doc['doc'].resp_code not in ('SC','00','AP','')">           
     108        <metal:block tal:condition="python:info_doc['doc'].resp_code not in ('SC','00','AP','IP','')">           
    109109        <h3>Response from Bank: "<span tal:content="python:info_doc['doc'].resp_desc" />"</h3>
    110110        <br />       
  • WAeUP_SRP/branches/uli/skins/waeup_epayment/payments_view.pt

    r1431 r1653  
    3434            </td>
    3535            <td>
    36             <a tal:condition="python:row['is_approvable']"
     36            <a tal:condition="row/is_approvable"
    3737               tal:attributes="href string:${context/absolute_url}/${row/id}/approve_epayment;
    3838                               onclick python:'return window.confirm(\'%s\')' %(cpsmcat('Are you sure? You will not be able to undo the approval.'), );
    3939                               ">
    4040                [approve payment]
     41            </a>             
     42            </td>
     43            <td tal:condition="nothing">
     44            <a tal:condition="row/is_requeryable"
     45               tal:attributes="href string:${context/absolute_url}/${row/id}/requery_payment;
     46                               onclick python:'return window.confirm(\'%s\')' %(cpsmcat('Are you sure? You will not be able to undo the approval.'), );
     47                               ">
     48                [requery payment]
    4149            </a>             
    4250            </td>
     
    5361                value="Initiate School Fee Online Payment"
    5462                />
     63               
     64
     65
     66               
    5567        </form> 
    5668
  • WAeUP_SRP/branches/uli/skins/waeup_student/add_course_result.py

    r1593 r1653  
    3838    if d['title'] == 'unknown':
    3939        err = "No such course!"
    40         logger.info('%s tried to add StudentCourseResult object %s for non-existing course' % (member,course_id))
     40        #logger.info('%s tried to add StudentCourseResult object %s for non-existing course' % (member,course_id))
    4141        break
    4242    if context.hasObject(course_id):
    4343        err = "Course already exists!"
    44         logger.info('%s tried to add StudentCourseResult object %s which is already in course list' % (member,course_id))
     44        #logger.info('%s tried to add StudentCourseResult object %s which is already in course list' % (member,course_id))
    4545        break
    4646    if context.hasObject("%s_co" % course_id):
    4747        err = "Course already exists as carryover course!"
    48         logger.info('%s tried to add StudentCourseResult object %s which already exists as carryover course' % (member,course_id))
     48        #logger.info('%s tried to add StudentCourseResult object %s which already exists as carryover course' % (member,course_id))
    4949        break
    5050    break
     
    5454    #args['error'] = err
    5555    args['portal_status_message'] = err
    56     url = "%s?%s" % (context.absolute_url(),urlencode(args))
     56    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
    5757    return request.RESPONSE.redirect(url)
    5858
     
    6666args['course_id'] = course_id
    6767
    68 logger.info('%s added StudentCourseResult object %s' % (member,course_id))
     68logger.info('%s added StudentCourseResult object %s for %s' % (member,course_id,context.getStudentId()))
    6969
    70 args = {}
    7170psm = "You successfully added course %s!" % course_id
    7271args['portal_status_message'] = psm
    73 url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     72if action_after_validate:
     73    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     74else:
     75    url = context.absolute_url() + '?' + urlencode(args)
    7476return REQUEST.RESPONSE.redirect(url)
    7577
  • WAeUP_SRP/branches/uli/skins/waeup_student/change_password.py

    r1593 r1653  
    44
    55"""
     6
     7return
     8
     9
     10
     11
     12
     13
     14
     15
    616request = context.REQUEST
    717import DateTime,logging
  • WAeUP_SRP/branches/uli/skins/waeup_student/clearance_edit.py

    r1593 r1653  
    120120        wftool.doActionFor(info['clear'],'open')
    121121        wftool.doActionFor(info['student'],'reject_clearance')
    122         action = "/contact_student_form"
     122        action = "/external_contact_student_form"
    123123        psm = "Student's clearance request has been rejected! Please fill and submit the form below!"
    124124        subject = "Clearance request rejected"
  • WAeUP_SRP/branches/uli/skins/waeup_student/contact_student_form.pt

    r1593 r1653  
    2828      <input type="hidden" name="probtype" type="text" id="probtype"
    2929             tal:attributes="value subject"/>     
     30      <input type="hidden" name="action" type="text" id="action"
     31             tal:attributes="value continue"/> 
    3032             
    3133      <table width="100%" border="0" cellspacing="5" cellpadding="0">
  • WAeUP_SRP/branches/uli/skins/waeup_student/course_registration_slip.pt

    r1593 r1653  
    1919     
    2020      <div tal:condition="validated">
    21         - validated by Course Adviser -
     21        - validated by Course Adviser -
     22      <span tal:condition="info/doc/validated_by|nothing" tal:omit-tag="">
     23        <span tal:replace="info/doc/validated_by" /> on <span tal:replace="info/doc/validation_date" />
     24      </span>
    2225      </div>
    2326      <div tal:condition="not: validated">
  • WAeUP_SRP/branches/uli/skins/waeup_student/create_level.py

    r1593 r1653  
    3131current_level = student.level
    3232in_progress =  request.get('in_progress','not started')
     33level_created =  request.get('level_created','xxx')
     34create_level =  request.get('create_level',None)
    3335
    34 if context.hasObject(current_level):
    35     response.redirect("%s/%s" % (context.absolute_url(),current_level))
     36if context.hasObject(current_level) and create_level :
     37    logger.info('%s", level %s already exists' % (student.id,current_level))
    3638    return
    3739
    38 if in_progress in ('not started','started'):
    39     session.set('in_progress','started')
    40     view = context.in_progress_view(refresh=3,page='create_level?in_progress=started')
    41     response.setHeader('Content-type','text/html; charset=ISO-8859-15')
    42     response.setHeader('Content-length','%d' % (len(view)))
    43     response.setStatus('OK')
    44     response.write(view)
    45     response.write('')
    46     if in_progress == 'started':
    47         return
     40##if in_progress in ('not started','started'):
     41##    session.set('in_progress','started')
     42##    view = context.in_progress_view(refresh=20,page='create_level?in_progress=started')
     43##    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
     44##    response.setHeader('Content-length','%d' % (len(view)))
     45##    response.setStatus('OK')
     46##    response.write(view)
     47##    response.write('')
     48##    if in_progress == 'started':
     49##        return
    4850   
    49 
    50 context.invokeFactory('StudentStudyLevel',"%s" % current_level)
    51 level = getattr(context,"%s" % current_level)
    52 context.portal_workflow.doActionFor(level,'open')
    53 study_session = context.getSessionString()
    54 level.getContent().edit(mapping={'session': study_session})
    55 context.portal_workflow.doActionFor(level,'close_for_edit')
     51if level_created == current_level:
     52    level = getattr(context,"%s" % current_level)
     53else:
     54    context.invokeFactory('StudentStudyLevel',"%s" % current_level)
     55    level = getattr(context,"%s" % current_level)
     56    context.portal_workflow.doActionFor(level,'open')
     57    study_session = context.getSessionString()
     58    level.getContent().edit(mapping={'session': study_session})
     59    context.portal_workflow.doActionFor(level,'close_for_edit')
     60    response.redirect("%s?level_created=%s" % (context.absolute_url(),current_level))
    5661results = context.results_import(matric_no = student.matric_no)
    5762if results:
     
    9095        context.portal_workflow.doActionFor(course_result,'open')
    9196        course_result.getContent().edit(mapping=d)
    92 res = context.portal_catalog(portal_type="Certificate", id = cert_id)
    93 l = []
    94 if res:
    95     cert = res[0]
    96     path = cert.getPath()
    97     query = Eq("path",path) &\
    98             Eq('portal_type','CertificateCourse') &\
    99             Eq('SearchableText', "%s" % student.level)
    100     courses = aq_portal(query)
    101     for c in courses:
    102         d = context.getCourseInfo(c.getId)
    103         cr_id = level.invokeFactory('StudentCourseResult',c.getId)
    104         course_result = getattr(level,cr_id)
    105         context.portal_workflow.doActionFor(course_result,'open')
    106         d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
    107         course_result.getContent().edit(mapping=d)
    108 return
     97level['create_course_results'](cert_id,current_level)
     98##res = context.portal_catalog(portal_type="Certificate", id = cert_id)
     99##l = []
     100##if res:
     101##    cert = res[0]
     102##    path = cert.getPath()
     103##    #set_trace()
     104##    query = Eq("path","%s/%s" % (path,current_level)) &\
     105##            Eq('portal_type','CertificateCourse')
     106##    courses = aq_portal(query)
     107##    for c in courses:
     108##        d = context.getCourseInfo(c.getId)
     109##        cr_id = level.invokeFactory('StudentCourseResult',c.getId)
     110##        course_result = getattr(level,cr_id)
     111##        context.portal_workflow.doActionFor(course_result,'open')
     112##        d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     113##        course_result.getContent().edit(mapping=d)
     114       
     115return response.redirect("%s/%s" % (context.absolute_url(),current_level))
     116
  • WAeUP_SRP/branches/uli/skins/waeup_student/delete_course_result.py

    r1593 r1653  
    1414
    1515from Products.CMFCore.utils import getToolByName
     16from AccessControl import Unauthorized
     17
    1618here = context
    1719from urllib import urlencode
     
    3032            real_ids.append(id)
    3133    if real_ids:
    32         context.manage_delObjects(real_ids)
    33         logger.info('%s deleted StudentCourseResult object %s' % (member,id))
    34         message = 'psm_item(s)_deleted'
     34        try:
     35            context.manage_delObjects(real_ids)
     36            logger.info('%s deleted StudentCourseResult object %s for %s' % (member,id,context.getStudentId()))
     37            message = 'psm_item(s)_deleted'
     38        except Unauthorized:
     39            logger.info('%s has no permission to delete StudentCourseResult objects for %s' % (member,context.getStudentId()))
     40            message = 'no item(s) deleted'
    3541else:
    3642    message = 'psm_select_at_least_one_document'
    37    
     43
    3844args = {}
    3945args['portal_status_message'] = message
    40 url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     46
     47if action_after_validate:
     48    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     49else:
     50    url = context.absolute_url() + '?' + urlencode(args)
    4151if REQUEST is not None:
    42     return REQUEST.RESPONSE.redirect(url)   
     52    return REQUEST.RESPONSE.redirect(url)
  • WAeUP_SRP/branches/uli/skins/waeup_student/getSessionResults.py

    r1593 r1653  
    101101#set_trace()
    102102verdict_voc = context.portal_vocabularies.verdicts
    103 verdict_code = student_from_cat.get('verdict',None)
     103verdict_code = student_from_cat.verdict
    104104if verdict_code:
    105105    info['verdict'] = verdict = verdict_voc.get(verdict_code,'N/A').upper()
  • WAeUP_SRP/branches/uli/skins/waeup_student/getStudyCourseInfo.py

    r1593 r1653  
    2525info = {}
    2626info['is_so'] = context.isSectionOfficer()
    27 info['action'] = "%s" % context.campus.absolute_url()
     27info['action'] = "%s" % context.absolute_url()
    2828info['choosen_ids'] = request.get('ids',[])
    2929course  = info['doc'] = context.getContent()
     
    5757may_register = (student_review_state in ('school_fee_paid',)) and\
    5858               current_level not in levels and\
    59                (sbrain.verdict in ('A','B') or sbrain.jamb_reg_no.startswith('6'))
     59               (sbrain.verdict in ('A','B','C') or sbrain.jamb_reg_no.startswith('6'))
    6060
    6161levels.sort()
  • WAeUP_SRP/branches/uli/skins/waeup_student/getStudyLevelInfo.py

    r1593 r1653  
    4040    return 0.0
    4141
    42 def cmp_semester(a,b):
    43     if a['semester'] == b['semester']:
     42def cmp_semester_id(a,b):
     43    s1 = "%(semester)s%(id)s" % a
     44    s2 = "%(semester)s%(id)s" % b
     45    if s1 == s2:
    4446        return 0
    45     if a['semester'] > b['semester']:
     47    if s1 > s2:
    4648        return 1
    4749    return -1
     
    104106        normal.append(d)
    105107info['credits_total'] = credits_total
    106 carry_overs.sort(cmp_semester)
     108carry_overs.sort(cmp_semester_id)
    107109info['carry_overs'] = carry_overs
    108 normal.sort(cmp_semester)
     110normal.sort(cmp_semester_id)
    109111info['normal'] = normal
    110112
  • WAeUP_SRP/branches/uli/skins/waeup_student/layout_personal_view.pt

    r1201 r1653  
    99      <td><span class="dlabel">Student ID</span>:
    1010      </td>
    11       <td tal:condition="nothing">
     11      <td>
    1212         <span tal:replace="context/getStudentId" />
    1313      </td>     
  • WAeUP_SRP/branches/uli/skins/waeup_student/mail2student.py

    r1593 r1653  
    55##bind script=script
    66##bind subpath=traverse_subpath
    7 ##parameters=co_name=None,co_email=None,student_email=None,probtype=None,commt=None
     7##parameters=co_name=None,co_email=None,student_email=None,probtype=None,commt=None, action=None
    88##title=
    99##
    1010# $Id: mail2admin.py 869 2006-11-15 13:46:49Z henrik $
     11
     12from urllib import urlencode
    1113
    1214mhost = context.MailHost
     
    2729#prop.email_from_address should be used for To:
    2830REQUEST = context.REQUEST
    29 url_tuple = REQUEST.HTTP_REFERER.split('?')
    30 if len(url_tuple) == 2:
    31     url_tuple[1] ='portal_status_message=Your message has been sent!'
    32 else:
    33     url_tuple.append('portal_status_message=Your message has been sent!')
    34 redirect_url = "?".join(url_tuple)
    35 REQUEST.set('rurl', redirect_url) # to see the result in the error log
     31
     32#url_tuple = REQUEST.HTTP_REFERER.split('?')
     33#if len(url_tuple) == 2:
     34#    url_tuple[1] ='portal_status_message=Your message has been sent!'
     35#else:
     36#    url_tuple.append('portal_status_message=Your message has been sent!')
     37#redirect_url = "?".join(url_tuple)
     38#REQUEST.set('rurl', redirect_url) # to see the result in the error log
     39
    3640msg = message % (
    3741     co_name,
     
    3943     student_email,
    4044     co_email,
    41      'henrik@waeup.org',
     45     'waeup@saoas.org',
    4246#    'js@aixtraware.de',
    4347     co_email,
     
    4751mhost.send(msg)
    4852
    49 REQUEST = context.REQUEST
    50 RESPONSE = REQUEST.RESPONSE
    5153
    52 RESPONSE.redirect(redirect_url)
     54#REQUEST = context.REQUEST
     55#RESPONSE = REQUEST.RESPONSE
     56#RESPONSE.redirect(redirect_url)
     57
     58args = {}
     59psm = "Your message has been sent!"
     60args['portal_status_message'] = psm
     61if action:
     62    url = context.absolute_url() + '/' + action + '?' + urlencode(args)
     63else:
     64    url = context.absolute_url() +'?' + urlencode(args)
     65return REQUEST.RESPONSE.redirect(url)
     66
     67
     68
  • WAeUP_SRP/branches/uli/skins/waeup_student/refresh_level.py

    r1593 r1653  
    112112psm = "Course list updated!"
    113113args['portal_status_message'] = psm
    114 url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     114if action_after_validate:
     115    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     116else:
     117    url = context.absolute_url() + '?' + urlencode(args)
    115118return REQUEST.RESPONSE.redirect(url)
  • WAeUP_SRP/branches/uli/skins/waeup_student/register_courses.py

    r1593 r1653  
    1919        pass
    2020
    21 from urllib import urlencode       
     21from urllib import urlencode
    2222
    2323request = context.REQUEST
     
    4747psm = "You successfully submitted your course list!"
    4848args['portal_status_message'] = psm
    49 url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     49if action_after_validate:
     50    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
     51else:
     52    url = context.absolute_url() + '?' + urlencode(args)
    5053return REQUEST.RESPONSE.redirect(url)
  • WAeUP_SRP/branches/uli/skins/waeup_student/reject_courses.py

    r1593 r1653  
    4646args['continue'] = action_after_validate
    4747args['portal_status_message'] = psm
    48 url = context.absolute_url() + '/' + action_after_reject + '?' + urlencode(args)
     48if action_after_reject:
     49    url = context.absolute_url() + '/' + action_after_reject + '?' + urlencode(args)
     50else:
     51    url = context.absolute_url() + '?' + urlencode(args)
    4952return REQUEST.RESPONSE.redirect(url)
  • WAeUP_SRP/branches/uli/skins/waeup_student/statistics_new_view.pt

    r1532 r1653  
    3333            <th align="right">CR</th>
    3434            <th align="right">VC</th>
    35             <th align="right">SFP</th>
     35            <th align="right">SFP+</th>
    3636          </tr>
    3737          <tr tal:repeat="d departments"
     
    7474        <tr><td>CR: </td> <td>Clearance requested</td></tr>
    7575        <tr><td>VC: </td> <td>Validated and cleared</td></tr>
    76         <tr><td>SFP: </td> <td>School fee paid</td></tr>
     76        <tr><td>SFP+: </td> <td>School fee paid and further</td></tr>
    7777        </table>
    7878      </span>
  • WAeUP_SRP/branches/uli/skins/waeup_student/statistics_ret_view.pt

    r1593 r1653  
    3434            <th >Faculty</th>
    3535            <th align="right">RET</th>
    36             <th align="right">SFP</th>
     36            <th align="right">SFP+</th>
    3737          </tr>
    3838          <tr tal:define="d python:departments[0]"
     
    6060        <table>
    6161        <tr><td>RET:</td> <td>Returning students who have logged in</td></tr>
    62         <tr><td>SFP:</td> <td>Returning students who already paid their school fee</td></tr>
     62        <tr><td>SFP:</td> <td>Returning students who paid their school fee</td></tr>
    6363        </table>       
    6464      </span>
  • WAeUP_SRP/branches/uli/skins/waeup_student/study_course_view.pt

    r1518 r1653  
    6666            tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
    6767            <td align="left" valign="middle" style="width: 5px;"
    68                 tal:condition="python: 0 and is_so">
     68                tal:condition="python:is_so">
    6969              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
    7070                     tal:condition="is_so"
     
    8484               summary="contents of the folder"
    8585               class="folderButtons">
    86           <tr>
     86          <tr tal:condition="python: is_so and info['items']">
    8787            <td align="left" valign="top" rowspan="3"></td>
    8888            <td align="left" valign="top">
    89               <span tal:condition="python:0 and is_so">
    90                 <input type="button" value="button_select_all" class="context"
     89              <input type="button" value="button_select_all" class="context"
    9190                       onclick="someJavaScriptFunctionThatWillBeReplaced"
    9291                       i18n:attributes="value"
     
    9493                       % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
    9594                       />
    96                 <input type="submit" name="folder_delete:method" value="button_delete"
    97                        class="destructive" i18n:attributes="value"
    98                        tal:attributes="onclick python:'return window.confirm(\'%s\')' %
    99                        (cpsmcat('description_confirm_delete'), )"
    100                        />
    101               </span>
     95              <input type="submit" name="folder_delete:method" value="button_delete"
     96                     class="destructive" i18n:attributes="value"
     97                     tal:attributes="onclick python:'return window.confirm(\'%s\')' %
     98                     (cpsmcat('description_confirm_delete'), )"
     99                     />
    102100            </td>
    103101          </tr>
  • WAeUP_SRP/branches/uli/skins/waeup_student/study_level_view.pt

    r1593 r1653  
    6464        <br />
    6565      <div class="" tal:condition="not: info/normal">
    66         Your faculty has not yet provided the list of courses for your certificate. Please contact your faculty!
     66        <font color="red">Your faculty has not yet provided the list of courses for your certificate. Please contact your faculty!</font>
     67        <br /><br />
    6768      </div>
    6869        <table class="contentListing" width="100%" id="folder_content"
     
    109110                       class="context" value="Update"
    110111                       />
     112                     
     113                       
    111114                <br /><br />
    112115                <input tal:condition="info/normal"
    113116                       type="submit" name="register_courses:method"
    114117                       class="context" value="Submit" />
     118                       
     119                <input type="hidden" name="action_after_validate" type="text" id="action_after_validate"
     120                       tal:attributes="value string:study_level_view"/> 
     121                       
     122                <br /><br />
     123               
     124                <strong>Note:</strong> 'Update' checks for all courses in your certificate and will add them to your course list irrespective of
     125                prior deletion, i.e. already deleted courses will show up again.
     126               
     127                Please use this function only if you are sure that your faculty has added courses which are not yet on your course list.                               
     128                       
    115129            </td>
    116130          </tr>
     
    142156                <input tal:condition="python: review_state in ('courses_registered', 'courses_validated',)" type="submit" name="reject_courses:method"
    143157                       class="context" value="Reject" />
     158                       
     159                <input type="hidden" name="action_after_validate" type="text" id="action_after_validate"
     160                       tal:attributes="value string:study_level_view"/>                         
     161                <input type="hidden" name="action_after_reject" type="text" id="action_after_reject"
     162                       tal:attributes="value string:contact_student_form"/>                         
    144163
    145164            </td>
     
    176195                       
    177196                <input type="hidden" name="action_after_validate" type="text" id="action_after_validate"
    178                        tal:attributes="value string:/study_level_view"/>                         
     197                       tal:attributes="value string:study_level_view"/>                         
    179198                <input type="hidden" name="action_after_reject" type="text" id="action_after_reject"
    180                        tal:attributes="value string:/contact_student_form"/>   
     199                       tal:attributes="value string:contact_student_form"/>   
    181200                                             
    182201
     
    199218                     />
    200219              <input type="hidden" name="action_after_validate" type="text" id="action_after_validate"
    201                        tal:attributes="value string:/study_level_view"/>                       
     220                       tal:attributes="value string:study_level_view"/>                       
    202221            </td>               
    203222        </table>
  • WAeUP_SRP/branches/uli/skins/waeup_student/validate_courses.py

    r1593 r1653  
    1313"""
    1414from Products.CMFCore.WorkflowCore import WorkflowException
     15import DateTime
     16current = DateTime.DateTime()
    1517try:
    1618    from Products.zdb import set_trace
     
    3032student_id = context.getStudentId()
    3133student = getattr(students_folder,student_id)
     34level_doc = context.getContent()
     35if level_doc.portal_type == 'StudentStudyLevel':
     36    level_doc.edit(mapping={'validated_by': member_id,
     37                            'validation_date': current,})
    3238try:
    3339    wftool.doActionFor(student,'validate_courses')
Note: See TracChangeset for help on using the changeset viewer.