Changeset 15174


Ignore:
Timestamp:
25 Sep 2018, 11:45:47 (6 years ago)
Author:
Henrik Bettermann
Message:

Implement 2-step validation process.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited
1 moved

Legend:

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

    r15173 r15174  
    11461146        return
    11471147
    1148 class StudentTranscriptValidateView(UtilityView, grok.View):
    1149     """ View to validate transcript
    1150     """
    1151     grok.context(IStudentStudyCourse)
    1152     grok.name('validate_transcript')
    1153     grok.require('waeup.processTranscript')
    1154 
    1155     def update(self, SUBMIT=None):
    1156         if self.context.student.state != TRANSREQ:
    1157             self.flash(_('Student is in wrong state.'), type="warning")
    1158             self.redirect(self.url(self.context))
    1159             return
    1160         # Fire transition
    1161         IWorkflowInfo(self.context.student).fireTransition(
    1162             'validate_transcript')
    1163         self.flash(_('Transcript validated.'))
    1164         self.redirect(self.url(self.context) + '/transcript')
    1165         return
    1166 
    1167     def render(self):
    1168         return
    1169 
    11701148class StudentTranscriptSignView(UtilityView, grok.View):
    11711149    """ View to sign transcript
     
    12081186        return
    12091187
     1188class StudentTranscriptValidateFormPage(KofaEditFormPage):
     1189    """ Page to validate transcript
     1190    """
     1191    grok.context(IStudentStudyCourse)
     1192    grok.name('validate_transcript')
     1193    grok.require('waeup.processTranscript')
     1194    grok.template('transcriptprocess')
     1195    label = _('Validate transcript')
     1196    buttonname = _('Save comment and validate transcript')
     1197    pnav = 4
     1198
     1199    def update(self, SUBMIT=None):
     1200        super(StudentTranscriptValidateFormPage, self).update()
     1201        if self.context.student.state != TRANSREQ:
     1202            self.flash(_('Student is in wrong state.'), type="warning")
     1203            self.redirect(self.url(self.context))
     1204            return
     1205        if getattr(self.context, 'transcript_comment', None) is not None:
     1206            self.correspondence = self.context.transcript_comment.replace(
     1207                '\n', '<br>')
     1208        else:
     1209            self.correspondence = ''
     1210        if getattr(self.context, 'transcript_signees', None) is not None:
     1211            self.signees = self.context.transcript_signees.replace(
     1212                '\n', '<br><br>')
     1213        else:
     1214            self.signees = ''
     1215        if SUBMIT is None:
     1216            return
     1217        # Fire transition
     1218        IWorkflowInfo(self.context.student).fireTransition('validate_transcript')
     1219        self.flash(_('Transcript validated.'))
     1220        comment = self.request.form.get('comment', '').replace('\r', '')
     1221        tz = getattr(queryUtility(IKofaUtils), 'tzinfo', pytz.utc)
     1222        today = now(tz).strftime('%d/%m/%Y %H:%M:%S %Z')
     1223        old_transcript_comment = getattr(
     1224            self.context, 'transcript_comment', None)
     1225        if old_transcript_comment == None:
     1226            old_transcript_comment = ''
     1227        self.context.transcript_comment = '''On %s %s wrote:
     1228
     1229%s
     1230
     1231%s''' % (today, self.request.principal.id, comment,
     1232         old_transcript_comment)
     1233        self.context.writeLogMessage(
     1234            self, 'comment: %s' % comment.replace('\n', '<br>'))
     1235        self.redirect(self.url(self.context) + '/transcript')
     1236        return
     1237
    12101238class StudentTranscriptReleaseFormPage(KofaEditFormPage):
    12111239    """ Page to release transcript
     
    12141242    grok.name('release_transcript')
    12151243    grok.require('waeup.processTranscript')
    1216     grok.template('transcriptrelease')
     1244    grok.template('transcriptprocess')
    12171245    label = _('Release transcript')
    12181246    buttonname = _('Save comment and release transcript')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r15163 r15174  
    21792179        self.browser.open(self.studycourse_path + '/transcript')
    21802180        self.browser.getLink("Validate transcript").click()
     2181        self.browser.getControl("Save comment and validate transcript").click()
    21812182        # After validation all manage forms are locked.
    21822183        self.browser.open(self.studycourse_path + '/manage')
     
    22982299        # Officer is on transcript page and can validate the transcript
    22992300        self.browser.getLink("Validate transcript").click()
     2301        self.browser.getControl("Save comment and validate transcript").click()
    23002302        self.assertTrue(
    23012303            '<div class="alert alert-success">Transcript validated.</div>'
Note: See TracChangeset for help on using the changeset viewer.