Changeset 1482 for WAeUP_SRP/trunk/skins


Ignore:
Timestamp:
23 Feb 2007, 16:56:46 (18 years ago)
Author:
joachim
Message:

add course registration.
The Link to the study_level is disabled in study_course_view.pt,
but can be invoked manually. On first invocation the courses are created.

Location:
WAeUP_SRP/trunk/skins/waeup_student
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_student/add_course_result.py

    r805 r1482  
    1010# $Id$
    1111"""
    12 FIXME: add docstring.
     12add a course_result object.
    1313"""
     14from urllib import urlencode
     15request = context.REQUEST
     16course_cat = context.courses_catalog
     17from Products.AdvancedQuery import Eq, Between, Le,In
     18aq_portal = context.portal_catalog.evalAdvancedQuery
     19course_id = request.get('course_id')
     20d = context.getCourseInfo(course_id)
     21args = {}
     22err = ''
     23while True:
     24    if d['title'] == 'unknown':
     25        err = "no such course"
     26        break
     27    if context.hasObject(course_id):
     28        err = "course already exists"
     29        break
     30    if context.hasObject("%s_co" % course_id):
     31        err = "course already exists as carryover"
     32        break
     33    break
    1434
    15 return context.REQUEST.RESPONSE.redirect("%s/content_create?type_name=StudentCourseResult"
    16                                           % (context.absolute_url()))
     35if err:
     36    args['course_id'] = course_id
     37    args['error'] = err
     38    url = "%s?%s" % (context.absolute_url(),urlencode(args))
     39    return request.RESPONSE.redirect(url)
     40##cert_id = context.aq_parent.getContent().study_course   
     41##res = context.portal_catalog(portal_type="Certificate", id = cert_id)
     42##l = []
     43##if res:
     44##    cert = res[0]
     45##    path = cert.getPath()
     46##    query = Eq("path",path) &\
     47##            Eq('portal_type','CertificateCourse') &\
     48##            Eq('SearchableText', "%s" % student.level) &\
     49##            Eq('id',course_id)
     50##course = aq_portal(query)[0]
     51cr_id = context.invokeFactory('StudentCourseResult',course_id)
     52##d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     53##getattr(context,cr_id).getContent().edit(mapping=d)
     54args['course_id'] = course_id
     55from urllib import urlencode
     56url = "%s?%s" % (context.absolute_url(),urlencode(args))
     57return request.RESPONSE.redirect(url)
     58
  • WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py

    r1471 r1482  
    4545current_level = sbrain.level
    4646levels = context.objectIds()
    47 #context.portal_workflow.doActionFor(context,'close_for_edit')
     47review_state = wftool.getInfoFor(context,'review_state',None)
     48if review_state != 'content_addable':
     49    context.portal_workflow.doActionFor(context,'close_for_edit')
    4850
    49 #levels.sort()
    50 #if int(current_level) > int(levels[-1]):
    51 #if not levels:
    52 #    context.invokeFactory('StudentStudyLevel',"%s" % current_level)
    53 #    level = getattr(context,"%s" % current_level)
    54 #    level.getContent().edit(mapping={'session': "2006/2007"})
    55 #    context.portal_workflow.doActionFor(level,'open')
    56 #    context.portal_workflow.doActionFor(level,'close_for_edit')
    57 #    levels.append(current_level)
    58 #for l in levels:
    59 #    row = {}
    60 #    row['id'] = l
    61 #    row['title'] = "Level %s" % l
    62 #    row['url'] = "%s/%s" % (context.absolute_url(),l)
    63 #    items.append(row)
     51levels.sort()
     52if not levels:
     53    context.invokeFactory('StudentStudyLevel',"%s" % current_level) 
     54    level = getattr(context,"%s" % current_level)
     55    session = context.getSessionString()
     56    level.getContent().edit(mapping={'session': session})
     57    context.portal_workflow.doActionFor(level,'open')
     58    context.portal_workflow.doActionFor(level,'close_for_edit')
     59    levels.append(current_level)
     60for l in levels:
     61    row = {}
     62    row['id'] = l
     63    row['title'] = "Level %s" % l
     64    row['url'] = "%s/%s" % (context.absolute_url(),l)
     65    items.append(row)
    6466
    6567info['items'] = items
  • WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py

    r1380 r1482  
    5757normal = []
    5858carry_overs = []
     59credits_total = 0
    5960for id,obj in context.objectItems():
     61    try:
     62        credit = int(obj.getContent().credits)
     63    except ValueError:
     64        credit = 3
     65    credits_total += credit
    6066    if id.endswith('_co'):
    6167        d = context.getCourseInfo(id[:-3])
     
    6975            d['coe'] = 'Elective'
    7076        normal.append(d)
    71 
     77info['credits_total'] = credits_total
    7278carry_overs.sort(cmp_semester)
    7379info['carry_overs'] = carry_overs
  • WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt

    r1409 r1482  
    6464                     />
    6565            </td>
    66             <td><a href="view" tal:attributes="href string:${row/url}">
    67               <strong tal:content="row/title" /></a> </td>
     66            <td><a href="view" tal:condition="python: 0"
     67                   tal:attributes="href string:${row/url}">
     68              <strong tal:content="row/title" /></a>
     69              <strong tal:condition="python: 1" tal:content="row/title" />
     70            </td>
    6871          </tr>
    6972        </table>
  • WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt

    r1417 r1482  
    1919    </metal:block>
    2020    <metal:main fill-slot="main" tal:condition="python:1">
     21      <form action="add_course_result" method="post" class="group">
     22        <h3>Add a course</h3>
     23        <table>
     24          <tr>
     25            <th>Course Id</th>
     26            <td><input type="text" name="course_id"
     27                       tal:attributes="value request/course_id|nothing"/></td>
     28            <td tal:condition="request/error|nothing"
     29                tal:content="request/error" />
     30          </tr>
     31          <tr>
     32            <th></th>
     33            <td colspan="2">
     34              <input type="submit" name="add"
     35                     class="context" value="Add Course"
     36                     />
     37            </td>
     38          </tr>
     39        </table>
     40      </form>   
    2141      <form action="." method="post" class="group">
    2242        <h3>Carryover Courses</h3>
     
    3656            <td width="2%" tal:content="row/semester"></td>
    3757            <td width="2%" tal:content="row/credits"></td>
    38             <td width="8%" tal:content="row/grade|nothing"></td>
     58            <td width="8%" tal:content="row/grade|string:"></td>
    3959          </tr>
    4060        </table>
     
    5777            <td width="8%" tal:content="row/coe|nothing"></td>
    5878          </tr>
     79          <tr>
     80            <td colspan="1"></td>
     81            <th colspan="3">Total credits</th>
     82            <td width="8%" tal:content="info/credits_total"></td>
     83          </tr>
    5984        </table>
    6085        <table width="100%" cellspacing="0" cellpadding="2"
     
    7095                       % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
    7196                       />
    72                 <input tal:condition="python:1" type="submit" name="register_checked:method"
     97                <input tal:condition="python:0" type="submit" name="register_checked:method"
    7398                       class="context" value="Register" />
    7499                <input tal:condition="python:0" type="submit" name="retract_checked:method"
    75100                       class="context" value="Retract" />
    76                 <input type="submit" name="folder_delete:method" value="button_delete"
     101                <input type="submit" name="course_result_delete:method" value="button_delete"
    77102                       class="destructive" i18n:attributes="value"
    78103                       tal:attributes="onclick python:'return window.confirm(\'%s\')' %
     
    89114      </form>
    90115    </metal:main>
    91    
    92     <metal:sub fill-slot="sub"/>
    93116  </metal:body>
    94117</metal:html>
     118 
Note: See TracChangeset for help on using the changeset viewer.