Changeset 7275 for main/waeup.sirp/trunk


Ignore:
Timestamp:
5 Dec 2011, 07:20:41 (13 years ago)
Author:
Henrik Bettermann
Message:

Redirect to contact form after rejecting clearance and pre-fill subject line.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

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

    r7259 r7275  
    2020import sys
    2121import grok
     22from urllib import urlencode
    2223from time import time
    2324from datetime import datetime
     
    363364    grok.context(IStudent)
    364365    grok.name('contactstudent')
    365     grok.require('waeup.manageStudent')
     366    grok.require('waeup.viewStudent')
    366367    pnav = 4
    367368    title = 'Contact'
    368369    form_fields = grok.AutoFields(IContactForm).select('subject', 'body')
     370
     371    def update(self, subject=u''):
     372        self.form_fields.get('subject').field.default = subject
     373        self.subject = subject
     374        return
    369375
    370376    def label(self):
     
    567573        if self.context.state == CLEARED:
    568574            IWorkflowInfo(self.context).fireTransition('reset4')
    569             self.flash('Clearance has been annulled.')
     575            message = 'Clearance has been annulled'
     576            self.flash(message)
    570577        elif self.context.state == REQUESTED:
    571578            IWorkflowInfo(self.context).fireTransition('reset3')
    572             self.flash('Clearance request has been rejected.')
     579            message = 'Clearance request has been rejected'
     580            self.flash(message)
    573581        else:
    574582            self.flash('Student is in the wrong state.')
    575         self.redirect(self.url(self.context,'view_clearance'))
     583            return
     584        args = {'subject':message}
     585        self.redirect(self.url(self.context) +
     586            '/contactstudent?%s' % urlencode(args))
    576587        return
    577588
    578589    def render(self):
    579         self.redirect(self.url(self.context, 'view_clearance'))
    580590        return
    581591
     
    17521762    def requestClearance(self, **data):
    17531763        self.applyData(self.context, **data)
    1754         self.context._p_changed = True
     1764        #self.context._p_changed = True
    17551765        if self.dataNotComplete():
    17561766            self.flash(self.dataNotComplete())
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7251 r7275  
    736736        self.browser.getLink("Reject clearance").click()
    737737        self.assertTrue('Clearance has been annulled' in self.browser.contents)
     738        urlmessage = 'Clearance+has+been+annulled'
     739        self.assertEqual(self.browser.url, self.student_path +
     740            '/contactstudent?subject=%s' % urlmessage)
    738741        self.assertTrue('State: <span>clearance started</span>'
    739742            in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.