Changeset 1194


Ignore:
Timestamp:
4 Jan 2007, 08:37:30 (18 years ago)
Author:
joachim
Message:

neu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTool.py

    r1174 r1194  
    3333from Products.CMFCore.permissions import ModifyPortalContent
    3434from Products.CMFCore.utils import UniqueObject
     35from Products.CMFCore.URLTool import URLTool
    3536from Students import makeCertificateCode
    3637import logging
     
    5556
    5657
    57 
    5858    def generateStudentId(self,letter): ###(
    5959        import random
    6060        r = random
    61         if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
     61        ##if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
     62        if letter == '?':
    6263            letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
    63         students = self.portal_url.getPortalObject().campus.students
    6464        sid = "%c%d" % (letter,r.randint(99999,1000000))
    65         while hasattr(students, sid):
     65##        students = self.portal_url.getPortalObject().campus.students
     66##        while hasattr(students, sid):
     67##            sid = "%c%d" % (letter,r.randint(99999,1000000))
     68        while self.students_catalog(id = sid):
    6669            sid = "%c%d" % (letter,r.randint(99999,1000000))
    6770        return sid
     
    6972
    7073    security.declareProtected(ModifyPortalContent,'createOne') ###(
    71     def createOne(self,student_brain,commit=False):
    72         students_folder = self.portal_url.getPortalObject().campus.students
    73         sid = self.waeup_tool.generateStudentId('?')
     74    def createOne(self,students_folder,student_brain,letter,commit=False):
     75        sid = self.waeup_tool.generateStudentId(letter)
    7476        students_folder.invokeFactory('Student', sid)
    7577        student = getattr(students_folder,sid)
     
    224226        # Level
    225227        #
    226 ##        l = getattr(studycourse,level,None)
    227 ##        if l is None:
    228 ##            studycourse.invokeFactory('StudentStudyLevel', level)
    229 ##            l = getattr(studycourse, level)
    230 ##            self.portal_workflow.doActionFor(l,'open',dest_container=l)
    231 ##            l.getContent().edit(mapping={'Title': "Level %s" % level})
     228        l = getattr(studycourse,level,None)
     229        if l is None:
     230            studycourse.invokeFactory('StudentStudyLevel', level)
     231            l = getattr(studycourse, level)
     232            self.portal_workflow.doActionFor(l,'open',dest_container=l)
     233            l.getContent().edit(mapping={'Title': "Level %s" % level})
     234###)
     235
     236    security.declarePublic('makeStudentLevel') ###(
     237    def makeStudentLevel(self,student_id):
     238        "create the StudyLevel for a returning Student"
     239        #import pdb;pdb.set_trace()
     240        logger = logging.getLogger('Student.CreateLevel')
     241        students_folder = self.portal_url.getPortalObject().campus.students
     242        res = self.students_catalog(id=student_id)
     243        if res:
     244            st = res[0]
     245        course = st.course
     246        matric_no = st.matric_no
     247        level = st.level
     248        res = self.results_import(matric_no = matric_no)
     249        if res:
     250            results = res
     251        logger.info('"%s", "creating Level", "%s"' % (student_id,level))
     252        #
     253        # Level
     254        #
     255        student_obj = getattr(self.portal_url.getPortalObject().campus.students,student_id)
     256        studycourse = getattr(student_obj,"study_course",None)
     257        self.portal_workflow.doActionFor(studycourse,'close_for_edit',dest_container=studycourse)
     258        l = getattr(studycourse,level,None)
     259        if l is None:
     260            studycourse.invokeFactory('StudentStudyLevel', level)
     261            l = getattr(studycourse, level)
     262            self.portal_workflow.doActionFor(l,'open',dest_container=l)
     263            l.getContent().edit(mapping={'Title': "Level %s" % level})
     264        ###)
    232265
    233266    security.declarePublic('getAccommodationInfo') ###(
Note: See TracChangeset for help on using the changeset viewer.