Changeset 1025 for WAeUP_SRP


Ignore:
Timestamp:
10 Dec 2006, 18:39:15 (18 years ago)
Author:
joachim
Message:

Removed all fields except study_course from student_study_course
adde StudyCourse? Widget
M profiles/default/layouts/student_study_course.xml
M skins/waeup_default/waeup_edit.py
M Widgets.py
catch unauthorised errors
M skins/waeup_student/application_edit_form.pt
M skins/waeup_student/getStudentInfo.py
M skins/waeup_student/study_course_view.pt
AM skins/waeup_student/getStudentId.py

Location:
WAeUP_SRP/trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Widgets.py

    r1020 r1025  
    246246
    247247
     248###)
     249
     250class StudyCourseWidget(CPSStringWidget): ###(
     251    """ StudyCourse Widget"""
     252    meta_type = "StudyCourse Widget"
     253
     254    def validate(self, datastructure, **kw):
     255        """Validate datastructure and update datamodel."""
     256        #from Products.zdb import set_trace
     257        #set_trace()
     258        valid = CPSStringWidget.validate(self, datastructure, **kw)
     259        id_pat_str = r"\S"
     260        inv_id_pat = compile(r"^%s$" % id_pat_str)
     261        if not valid:
     262            return 0
     263        else:
     264            widget_id = self.getWidgetId()
     265            value = datastructure[widget_id].upper()
     266            err = 0
     267            if len(value.split()) > 1:
     268                err = 'Invalid Id, Id contains space(s).'
     269            elif not self.portal_catalog(portal_type='Certificate',id=value):
     270                err = 'No such certificate'
     271            if err:
     272                datastructure.setError(widget_id, err)
     273            else:
     274                datamodel = datastructure.getDataModel()
     275                datamodel[self.fields[0]] = value
     276            return not err
     277
     278InitializeClass(StudyCourseWidget)
     279
     280widgetRegistry.register(StudyCourseWidget)
    248281###)
    249282
     
    471504        pin = "%(prefix)s%(b)s%(n)s" % vars()
    472505        do = 1
    473         s_id = ''
     506        s_id = str(self.portal_membership.getAuthenticatedMember())
    474507        if self.reference == "":
    475             ref = str(self.portal_membership.getAuthenticatedMember())
     508            ref = s_id
    476509        else:
    477510            ref = datastructure[self.reference]
  • WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml

    r853 r1025  
    1919  <property name="hidden_readonly_layout_modes"/>
    2020 </widget>
    21  <widget name="study_course" meta_type="String Widget">
     21 <widget name="study_course" meta_type="StudyCourse Widget">
    2222  <property name="title">Certificate Code</property>
    2323  <property name="fields">
     
    3131  <property name="hidden_readonly_layout_modes"/>
    3232 </widget>
    33  <widget name="end_level" meta_type="Select Widget">
    34   <property name="title">End Level</property>
    35   <property name="fields">
    36    <element value="end_level"/>
    37   </property>
    38   <property name="label">End Level</property>
    39   <property name="label_edit">End Level</property>
    40   <property name="readonly_layout_modes"/>
    41   <property name="hidden_layout_modes"/>
    42   <property name="hidden_readonly_layout_modes"/>
    43   <property name="vocabulary">courselevel</property>
    44  </widget>
    45  <widget name="max_elect" meta_type="String Widget">
    46   <property name="title">Max Elect</property>
    47   <property name="fields">
    48    <element value="max_elect"/>
    49   </property>
    50   <property name="label">Max Elect</property>
    51   <property name="label_edit">Max Elect</property>
    52   <property name="readonly_layout_modes"/>
    53   <property name="hidden_layout_modes"/>
    54   <property name="hidden_readonly_layout_modes"/>
    55  </widget>
    56  <widget name="max_load" meta_type="Int Widget">
    57   <property name="title">Maximum Load</property>
    58   <property name="fields">
    59    <element value="max_load"/>
    60   </property>
    61   <property name="is_required">False</property>
    62   <property name="label">Maximum Load</property>
    63   <property name="label_edit">Maximum Load</property>
    64   <property name="readonly_layout_modes"/>
    65   <property name="hidden_layout_modes"/>
    66   <property name="hidden_readonly_layout_modes"/>
    67  </widget>
    68  <widget name="max_pass" meta_type="Int Widget">
    69   <property name="title">Maximum Pass</property>
    70   <property name="fields">
    71    <element value="max_pass"/>
    72   </property>
    73   <property name="is_required">False</property>
    74   <property name="label">Maximum Pass</property>
    75   <property name="label_edit">Maximum Pass</property>
    76   <property name="readonly_layout_modes"/>
    77   <property name="hidden_layout_modes"/>
    78   <property name="hidden_readonly_layout_modes"/>
    79  </widget>
    80  <widget name="n_core" meta_type="Int Widget">
    81   <property name="title">NCore</property>
    82   <property name="fields">
    83    <element value="n_core"/>
    84   </property>
    85   <property name="label">NCore</property>
    86   <property name="label_edit">NCore</property>
    87   <property name="readonly_layout_modes"/>
    88   <property name="hidden_layout_modes"/>
    89   <property name="hidden_readonly_layout_modes"/>
    90  </widget>
    91  <widget name="nr_years" meta_type="Int Widget">
    92   <property name="title">Nr of Years</property>
    93   <property name="fields">
    94    <element value="nr_years"/>
    95   </property>
    96   <property name="label">Nr of Years</property>
    97   <property name="label_edit">Nr of Years</property>
    98   <property name="readonly_layout_modes"/>
    99   <property name="hidden_layout_modes"/>
    100   <property name="hidden_readonly_layout_modes"/>
    101  </widget>
    102  <widget name="probation_credits" meta_type="Int Widget">
    103   <property name="title">Probation  Credits</property>
    104   <property name="fields">
    105    <element value="probation_credits"/>
    106   </property>
    107   <property name="label">Probation  Credits</property>
    108   <property name="label_edit">Probation  Credits</property>
    109   <property name="readonly_layout_modes"/>
    110   <property name="hidden_layout_modes"/>
    111   <property name="hidden_readonly_layout_modes"/>
    112  </widget>
    113  <widget name="promotion_credits" meta_type="Int Widget">
    114   <property name="title">Promotion  Credits</property>
    115   <property name="fields">
    116    <element value="promotion_credits"/>
    117   </property>
    118   <property name="label">Promotion  Credits</property>
    119   <property name="label_edit">Promotion  Credits</property>
    120   <property name="readonly_layout_modes"/>
    121   <property name="hidden_layout_modes"/>
    122   <property name="hidden_readonly_layout_modes"/>
    123  </widget>
    124  <widget name="start_level" meta_type="Select Widget">
    125   <property name="title">Start Level</property>
    126   <property name="fields">
    127    <element value="start_level"/>
    128   </property>
    129   <property name="label">Start Level</property>
    130   <property name="label_edit">Start Level</property>
    131   <property name="readonly_layout_modes"/>
    132   <property name="hidden_layout_modes"/>
    133   <property name="hidden_readonly_layout_modes"/>
    134   <property name="vocabulary">courselevel</property>
    135  </widget>
    136  <widget name="end_level" meta_type="Select Widget">
    137   <property name="title">End Level</property>
    138   <property name="fields">
    139    <element value="end_level"/>
    140   </property>
    141   <property name="label">End Level</property>
    142   <property name="label_edit">End Level</property>
    143   <property name="readonly_layout_modes"/>
    144   <property name="hidden_layout_modes"/>
    145   <property name="hidden_readonly_layout_modes"/>
    146   <property name="vocabulary">courselevel</property>
    147  </widget>
    148  <widget name="department" meta_type="String Widget">
    149   <property name="title">Department Code</property>
    150   <property name="fields">
    151    <element value="department"/>
    152   </property>
    153   <property name="is_required">False</property>
    154   <property name="label">Department Code</property>
    155   <property name="label_edit">Department Code</property>
    156   <property name="readonly_layout_modes"/>
    157   <property name="hidden_layout_modes"/>
    158   <property name="hidden_readonly_layout_modes"/>
    159  </widget>
    160  <widget name="faculty" meta_type="String Widget">
    161   <property name="title">Faculty Code</property>
    162   <property name="fields">
    163    <element value="faculty"/>
    164   </property>
    165   <property name="is_required">False</property>
    166   <property name="label">Faculty Code</property>
    167   <property name="label_edit">Faculty Code</property>
    168   <property name="readonly_layout_modes"/>
    169   <property name="hidden_layout_modes"/>
    170   <property name="hidden_readonly_layout_modes"/>
    171  </widget>
    17233 <table>
    173   <row>
    174    <cell name="title"/>
    175   </row>
    17634  <row>
    17735   <cell name="study_course"/>
    17836  </row>
    179   <row>
    180    <cell name="faculty"/>
    181   </row>
    182   <row>
    183    <cell name="department"/>
    184   </row>
    185   <row>
    186    <cell name="start_level"/>
    187   </row>
    188   <row>
    189    <cell name="end_level"/>
    190   </row>
    191   <row>
    192    <cell name="max_pass"/>
    193   </row>
    194   <row>
    195    <cell name="max_load"/>
    196   </row>
    197   <row>
    198    <cell name="promotion_credits"/>
    199   </row>
    200   <row>
    201    <cell name="probation_credits"/>
    202   </row>
    203   <row>
    204    <cell name="nr_years"/>
    205   </row>
    206   <row>
    207    <cell name="n_core"/>
    208   </row>
    209   <row>
    210    <cell name="max_elect"/>
    211   </row>
    21237 </table>
    21338</object>
  • WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py

    r859 r1025  
    2323# (We don't call getEditableContent here, validate does it when needed.)
    2424doc = context.getContent()
     25if context.portal_type == "StudentStudyCourse":
     26    if len(context.objectIds()) > 0:
     27        psm = 'Edit of StudyCourse is only possible if there are no levels'
     28        args = getFormUidUrlArg(REQUEST)
     29        args['portal_status_message'] = psm
     30        url = context.absolute_url() + '?' + urlencode(args)
     31        REQUEST.RESPONSE.redirect(url)
     32       
    2533is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
    2634                            use_session=True)
     
    3644    comments = REQUEST.get('comments')
    3745    context.cpsdocument_notify_modification(comments=comments)
     46    if context.portal_type == "StudentStudyCourse":
     47        course = ds.get('study_course')
     48        student_id = context.getStudentId()
     49        res = context.portal_catalog(portal_type='Certificate',id = course)
     50        if res:
     51            c_brain = res[0]
     52            c_path = c_brain.getPath().split('/')
     53            student_id = context.getStudentId()
     54            context.students_catalog.modifyRecord(id = student_id,
     55                                                  course = course,
     56                                                  faculty = c_path[-4],
     57                                                  department = c_path[-3],
     58                                                  )
    3859    if cpsdocument_edit_and_view_button is not None:
    3960        action = ''
  • WAeUP_SRP/trunk/skins/waeup_student/application_edit_form.pt

    r877 r1025  
    1 <metal:html tal:define="info context/getStudentInfo;
    2             rendered_main python:info['app_doc'].render(
     1<metal:html tal:define="info context/getStudentInfo">
     2  <span tal:condition="not: info">
     3    <metal:block use-macro="here/error_not_found/macros/not_found" />
     4  </span>
     5<metal:block tal:condition="info">
     6<metal:block tal:define="rendered_main python:info['app_doc'].render(
    37                      layout_mode='edit',
    48                      schema_id = 'student_application',
     
    5054    </metal:main>
    5155  </metal:body>
     56</metal:block>
     57</metal:block>
    5258</metal:html>
  • WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py

    r1017 r1025  
    4343            logger.info("student %s tried to access %s" % (member_id,requested_id))
    4444            student_id = member_id
    45             #mtool.assertViewable(context)
     45            mtool.assertViewable(context)
    4646            break
    4747        student_id = member_id
     
    7878        info['sex'] = 'female'
    7979course = getattr(student,'study_course',None)
    80 info['course'] = course
    8180if course:
    82     info['course_doc'] = student.study_course.getContent()
     81    cert_id = course.getContent().study_course
     82    res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
     83    ci = {}
     84    if len(res) > 0:
     85        info['course'] = course
     86        brain = res[0]
     87        ci['study_course'] = brain.getId
     88        ci['title'] = brain.Title
     89        pl = brain.getPath().split('/')
     90        ci['faculty'] = pl[-4]
     91        ci['department'] = pl[-3]
     92        info['course_doc'] = ci
     93    else:
     94        info['course'] = None
    8395#
    8496acco = getattr(student,'accommodation_2006',None)
  • WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt

    r913 r1025  
    1919    </metal:block>
    2020    <metal:main fill-slot="main">
    21       <span tal:omit-tag=""  
     21      <span tal:omit-tag="" tal:condition="nothing"
    2222            tal:content="structure python: info['doc'].render(layout_mode='view')" />
     23      <table tal:define="sc python: s_info['course_doc']">
     24        <tr>
     25          <td width="180px">Certificate:</td>
     26          <td><span tal:content="sc/title" /></td>
     27        </tr>
     28        <tr>
     29          <td>Certificate ID:</td>
     30          <td tal:content="sc/study_course" />
     31        </tr>
     32          <span tal:define="f_id sc/faculty;
     33          d_id sc/department;
     34          f_title context/academics/?f_id/Title|string:Faculty not yet in Prospectus;
     35          d_title context/academics/?f_id/?d_id/Title|string:Department not yet in Prospectus"
     36          >
     37            <tr>
     38              <td>Faculty:</td>
     39              <td tal:content="f_title" />
     40            </tr>
     41            <tr>
     42              <td>Department:</td>
     43              <td><span tal:content="d_title" /></td>
     44            </tr>
     45          </span>
     46        </table>       
    2347     
    2448      <form action="" method="post" class="group"
Note: See TracChangeset for help on using the changeset viewer.