Changeset 2539 for WAeUP_SRP/base/skins


Ignore:
Timestamp:
5 Nov 2007, 18:07:42 (17 years ago)
Author:
joachim
Message:

disallow calling from the url, commented out code removed (in custom)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_student/create_level.py

    r2489 r2539  
    1818    aq_portal = context.portal_catalog_real.evalAdvancedQuery
    1919aq_courses = context.courses_catalog.evalAdvancedQuery
     20aq_results = context.course_results.evalAdvancedQuery
    2021
    2122current = DateTime.DateTime()
    2223request = context.REQUEST
    23 #session = request.SESSION
    2424response = request.RESPONSE
    2525redirect = response.redirect
     
    2828member = mtool.getAuthenticatedMember()
    2929member_id = str(member)
     30requested_id = context.getStudentId()
     31#set_trace()
     32create_level =  request.form.get('create_level',None)
     33if not create_level or not requested_id or\
     34   (not context.isStaff() and member_id != requested_id):
     35    logger.info('%s tried to access %s' % (member_id,requested_id))
     36    return redirect("%s/srp_anonymous_view" % context.portal_url())
     37student_id = context.getStudentId()
     38
    3039lt = context.portal_layouts
    3140wt = context.waeup_tool
    32 student = context.students_catalog(id=context.getStudentId())[0]
     41student = context.students_catalog(id=student_id)[0]
    3342cert_id = student.course
    3443current_level = student.level
    3544current_session = student.session
    3645in_progress =  request.get('in_progress','not started')
    37 #level_created =  request.get('level_created','xxx')
    38 create_level =  request.get('create_level',None)
     46if aq_results(Eq('student_id',student_id) & Eq('level_id',current_level)):
     47    logger.info('%s tried to create already existing level %s' % (student.id,current_level))
     48    return
    3949
    40 ##if context.hasObject(current_level) and create_level:
    41 ##    if getattr(context,current_level).objectIds():
    42 ##        logger.info('%s tried to add already existing level %s' % (student.id,current_level))
    43 ##    return
    4450logger.info('%s started to create level %s' % (student.id,current_level))
    45 
    46 ##if in_progress in ('not started','started'):
    47 ##    session.set('in_progress','started')
    48 ##    view = context.in_progress_view(refresh=20,page='create_level?in_progress=started')
    49 ##    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
    50 ##    response.setHeader('Content-length','%d' % (len(view)))
    51 ##    response.setStatus('OK')
    52 ##    response.write(view)
    53 ##    response.write('')
    54 ##    if in_progress == 'started':
    55 ##        return
    5651
    5752if context.hasObject(current_level):
     
    6156    level = getattr(context,"%s" % current_level)
    6257    context.portal_workflow.doActionFor(level,'open')
    63     #study_session = context.getSessionString()
    6458    level.getContent().edit(mapping={'session': current_session})
    6559    context.portal_workflow.doActionFor(level,'close_for_edit')
    66     #context.waeup_tool.doCommit()
    6760level_id = level.getId()
    68 student_id = context.getStudentId()
    6961session_id = context.getLevelSession(level.getContent(),student_id,level_id)
    7062results = []
     
    108100        d = context.getCourseInfo(co.CosCode)
    109101        d['course_id'] = course_id
    110         #d['grade'] = co.GRADE
    111102        d['carry_over'] = carry_over
    112         # course_id = level.invokeFactory('StudentCourseResult',"%s_co" % course_id)
    113         # course_result = getattr(level,course_id)
    114         # context.portal_workflow.doActionFor(course_result,'open')
    115         # course_result.getContent().edit(mapping=d)
    116         # context.waeup_tool.doCommit()
    117103        d['code'] = course_id
    118104        d['student_id'] = student_id
     
    121107        records.append(d)
    122108
    123 #level['create_course_results'](cert_id,current_level)
    124109res = context.portal_catalog(portal_type="Certificate", id = cert_id)
    125110if res:
     
    136121        l += course_id,
    137122        d = context.getCourseInfo(c.getId)
    138         # course_id = level.invokeFactory('StudentCourseResult',c.getId)
    139         # course_result = getattr(level,course_id)
    140         # context.portal_workflow.doActionFor(course_result,'open')
    141         # d['core_or_elective'] = True
    142         # course_result.getContent().edit(mapping=d)
    143         # context.waeup_tool.doCommit()
    144123        d['carry_over'] = False
    145124        d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     
    148127        d['level_id'] = level_id
    149128        d['session_id'] = session_id
    150         #context.course_results.addRecord(**d)
    151129        records.append(d)
    152130if records:
     
    154132logger.info('%s finished to create level %s' % (student.id,current_level))
    155133
    156 #if current_session == '05':
    157 #    next_session = '06'
    158 #    next_level = "%s" % (int(current_level) + 100)
    159 #    study_course = getattr(student,'study_course')
    160 #    context.portal_workflow.doActionFor(study_course,'open')
    161 #    study_course_doc = study_course.getContent()
    162 #    study_course_doc.edit(mapping= {'current_level': next_level,
    163 #                                    'current_session': next_session,})
    164 #    context.portal_workflow.doActionFor(study_course,'close_for_edit')
    165 
    166134return response.redirect("%s/%s" % (context.absolute_url(),current_level))
Note: See TracChangeset for help on using the changeset viewer.