Changeset 6695


Ignore:
Timestamp:
9 Sep 2011, 06:03:28 (13 years ago)
Author:
Henrik Bettermann
Message:

Add clearance_locked attribute and set True when a student is added.

Add clearance edit page for students.

Shorten page template names.

Rename Edit buttons for officers. Officers are managing and students are editing objects.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
5 edited
4 moved

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6694 r6695  
    6666    IStudentPersonal, IStudentBase, IStudentStudyCourse,
    6767    IStudentPayments, IStudentAccommodation, IStudentNavigation,
    68     IStudentBaseEdit,
     68    IStudentBaseEdit, IStudentClearanceEdit,
    6969    )
    7070from waeup.sirp.students.student import Student
     
    117117    grok.name('index')
    118118    grok.require('waeup.viewStudent')
    119     grok.template('studentscontainerpage')
     119    grok.template('containerpage')
    120120    label = 'Student Section'
    121121    title = 'Students'
     
    156156    grok.name('manage')
    157157    grok.require('waeup.manageStudents')
    158     grok.template('studentscontainermanagepage')
     158    grok.template('containermanagepage')
    159159    pnav = 4
    160160    title = 'Manage student section'
     
    233233    grok.name('index')
    234234    grok.require('waeup.viewStudent')
    235     grok.template('studentpage')
     235    grok.template('basepage')
    236236    form_fields = grok.AutoFields(IStudentBase).omit('password')
    237237    pnav = 4
     
    247247    grok.view(StudentBaseDisplayFormPage)
    248248    grok.require('waeup.manageStudents')
    249     text = 'Edit'
     249    text = 'Manage'
    250250    target = 'edit_base'
    251251
     
    257257    grok.require('waeup.manageStudents')
    258258    form_fields = grok.AutoFields(IStudentBase).omit('student_id')
    259     grok.template('studentbasemanagepage')
    260     label = 'Edit base data'
     259    grok.template('basemanagepage')
     260    label = 'Manage base data'
    261261    title = 'Base Data'
    262262    pnav = 4
     
    303303    grok.name('view_clearance')
    304304    grok.require('waeup.viewStudent')
    305     form_fields = grok.AutoFields(IStudentClearance)
     305    form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    306306    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    307307    title = 'Clearance Data'
     
    317317    grok.view(StudentClearanceDisplayFormPage)
    318318    grok.require('waeup.manageStudents')
    319     text = 'Edit'
     319    text = 'Manage'
    320320    target = 'edit_clearance'
    321321
     
    327327    grok.require('waeup.manageStudents')
    328328    form_fields = grok.AutoFields(IStudentClearance)
    329     label = 'Edit clearance data'
     329    label = 'Manage clearance data'
    330330    title = 'Clearance Data'
    331331    pnav = 4
     
    337337        return super(StudentClearanceManageFormPage, self).update()
    338338
     339    @grok.action('Save')
     340    def save(self, **data):
     341        changed_fields = self.applyData(self.context, **data)
     342        changed_fields = changed_fields.values()
     343        fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
     344        self.context._p_changed = True
     345        form = self.request.form
     346        self.flash('Form has been saved.')
     347        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     348        if fields_string:
     349            self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
     350        return
     351
    339352class StudentPersonalDisplayFormPage(WAeUPDisplayFormPage):
    340353    """ Page to display student personal data
     
    356369    grok.view(StudentPersonalDisplayFormPage)
    357370    grok.require('waeup.manageStudents')
    358     text = 'Edit'
     371    text = 'Manage'
    359372    target = 'edit_personal'
    360373
     
    366379    grok.require('waeup.viewStudent')
    367380    form_fields = grok.AutoFields(IStudentPersonal)
    368     label = 'Edit personal data'
     381    label = 'Manage personal data'
    369382    title = 'Personal Data'
    370383    pnav = 4
     
    390403    grok.view(StudyCourseDisplayFormPage)
    391404    grok.require('waeup.manageStudents')
    392     text = 'Edit'
     405    text = 'Manage'
    393406    target = 'edit'
    394407
     
    400413    grok.require('waeup.manageStudents')
    401414    form_fields = grok.AutoFields(IStudentStudyCourse)
    402     label = 'Edit clearance data'
    403415    title = 'Study Course'
    404     label = 'Edit study course'
     416    label = 'Manage study course'
    405417    pnav = 4
    406418
     
    466478    grok.require('waeup.handleStudent')
    467479    form_fields = grok.AutoFields(IStudentBaseEdit).omit('student_id')
    468     grok.template('studentbaseeditpage')
     480    grok.template('baseeditpage')
    469481    label = 'Change password'
    470482    title = 'Base Data'
     
    491503            IUserAccount(self.context).setPassword(form['form.password'])
    492504        return
     505
     506class StudentClearanceEditActionButton(ManageActionButton):
     507    grok.order(1)
     508    grok.context(IStudent)
     509    grok.view(StudentClearanceDisplayFormPage)
     510    grok.require('waeup.handleStudent')
     511    text = 'Edit and submit'
     512    target = 'cedit'
     513
     514class StudentClearanceEditFormPage(StudentClearanceManageFormPage):
     515    """ View to edit student clearance data by student
     516    """
     517    grok.context(IStudent)
     518    grok.name('cedit')
     519    grok.require('waeup.handleStudent')
     520    form_fields = grok.AutoFields(IStudentClearanceEdit).omit('clearance_locked')
     521    #grok.template('clearanceeditpage')
     522    label = 'Edit clerance data'
     523    title = 'Clearance Data'
     524    pnav = 4
     525    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/container.py

    r6684 r6695  
    4949            raise TypeError(
    5050                'StudentsContainers contain only IStudent instances')
     51        student.clearance_locked = True
    5152        self[student.student_id] = student
    5253        studycourse = StudentStudyCourse()
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6694 r6695  
    9191        )
    9292
     93    clearance_locked = schema.Bool(
     94        title = u'Clearance form locked',
     95        default = False,
     96        )
     97
    9398class IStudentPersonal(IWAeUPObject):
    9499    """Representation of student personal data.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r6694 r6695  
    2424from waeup.sirp.interfaces import IObjectHistory
    2525from waeup.sirp.students.interfaces import (
    26     IStudent, IStudentNavigation, IStudentBaseEdit,
    27     )
     26    IStudent, IStudentNavigation, IStudentBaseEdit, IStudentClearanceEdit,
     27    IStudentPersonalEdit)
    2828from waeup.sirp.utils.helpers import attrs_to_fields
    2929from waeup.sirp.students.utils import generate_student_id
     
    3434    """
    3535    grok.implements(IStudent, IStudentNavigation,
    36         IStudentBaseEdit)
     36        IStudentBaseEdit, IStudentClearanceEdit, IStudentPersonalEdit)
    3737    grok.provides(IStudent)
    3838
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6694 r6695  
    199199        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    200200        self.assertEqual(self.browser.url, self.student_path)
    201         self.browser.getLink("Edit").click()
     201        self.browser.getLink("Manage").click()
    202202        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    203203        self.assertEqual(self.browser.url, self.manage_student_path)
     
    213213        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    214214        self.assertEqual(self.browser.url, self.clearance_student_path)
    215         self.browser.getLink("Edit").click()
     215        self.browser.getLink("Manage").click()
    216216        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    217217        self.assertEqual(self.browser.url, self.edit_clearance_student_path)
     
    221221        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    222222        self.assertEqual(self.browser.url, self.personal_student_path)
    223         self.browser.getLink("Edit").click()
     223        self.browser.getLink("Manage").click()
    224224        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    225225        self.assertEqual(self.browser.url, self.edit_personal_student_path)
     
    229229        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    230230        self.assertEqual(self.browser.url, self.studycourse_student_path)
    231         self.browser.getLink("Edit").click()
    232         self.assertTrue('Edit study course' in self.browser.contents)
     231        self.browser.getLink("Manage").click()
     232        self.assertTrue('Manage study course' in self.browser.contents)
    233233
    234234        self.browser.open(self.student_path)
     
    274274        # We can login again with the new password
    275275        self.browser.getLink("Login").click()
    276         #self.browser.open(self.login_path)
     276        self.browser.open(self.login_path)
    277277        self.browser.getControl(name="form.login").value = self.test_student_id
    278278        self.browser.getControl(name="form.password").value = 'new_password'
     
    280280        self.assertEqual(self.browser.url, self.student_path)
    281281        self.assertTrue('You logged in' in self.browser.contents)
    282         return
     282
     283        return
Note: See TracChangeset for help on using the changeset viewer.