Changeset 15140 for main


Ignore:
Timestamp:
18 Sep 2018, 05:53:44 (6 years ago)
Author:
Henrik Bettermann
Message:

Implement transcript validation workflow. More tests will follow.

Location:
main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/batching.py

    r15066 r15140  
    528528        problems.
    529529        """
     530        if obj.student.studycourse_locked:
     531            return 'Studycourse is locked.'
    530532        certificate = getattr(obj, 'certificate', None)
    531533        entry_session = getattr(obj, 'entry_session', None)
     
    619621        return
    620622
     623    def checkUpdateRequirements(self, obj, row, site):
     624        """
     625        """
     626        if obj.student.studycourse_locked:
     627            return 'Studylevel is locked.'
     628        return None
     629
    621630class CourseTicketProcessor(StudentProcessorBase):
    622631    """The Course Ticket Processor imports course tickets, the subobjects
     
    714723            del parent[ticket.code]
    715724        return
     725
     726    def checkUpdateRequirements(self, obj, row, site):
     727        """
     728        """
     729        if obj.student.studycourse_locked:
     730            return 'Studycourse is locked.'
     731        return None
    716732
    717733    def checkConversion(self, row, mode='ignore'):
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/browser.py

    r15134 r15140  
    996996
    997997    def update(self):
    998         if not self.context.is_current:
     998        if not self.context.is_current \
     999            or self.context.student.studycourse_locked:
    9991000            emit_lock_message(self)
    10001001            return
     
    10761077    """ Page to request transcript by student
    10771078    """
    1078     grok.context(IStudent)
     1079    grok.context(IStudentTranscript)
    10791080    grok.name('request_transcript')
    10801081    grok.require('waeup.handleStudent')
     
    11461147        return
    11471148
    1148 class StudentTranscriptReleasesFormPage(KofaEditFormPage):
     1149class StudentTranscriptValidateView(UtilityView, grok.View):
     1150    """ View to validate transcript
     1151    """
     1152    grok.context(IStudentTranscript)
     1153    grok.name('validate_transcript')
     1154    grok.require('waeup.processTranscript')
     1155    form_fields = grok.AutoFields(IStudentTranscript)
     1156
     1157    def update(self, SUBMIT=None):
     1158        if self.context.student.state != TRANSREQ:
     1159            self.flash(_('Student is in wrong state.'), type="warning")
     1160            self.redirect(self.url(self.context))
     1161            return
     1162        # Fire transition
     1163        IWorkflowInfo(self.context).fireTransition('validate_transcript')
     1164        self.flash(_('Transcript validated.'))
     1165        self.redirect(self.url(self.context))
     1166        return
     1167
     1168    def render(self):
     1169        return
     1170
     1171class StudentTranscriptReleaseFormPage(KofaEditFormPage):
    11491172    """ Page to release transcript
    11501173    """
    1151     grok.context(IStudent)
     1174    grok.context(IStudentTranscript)
    11521175    grok.name('release_transcript')
    11531176    grok.require('waeup.processTranscript')
     
    11551178    form_fields = grok.AutoFields(IStudentTranscript)
    11561179    label = _('Release transcript')
    1157     buttonname = _('Save comment and mark as released')
     1180    buttonname = _('Save comment and release transcript')
    11581181    pnav = 4
    11591182
    11601183    def update(self, SUBMIT=None):
    1161         super(StudentTranscriptReleasesFormPage, self).update()
     1184        super(StudentTranscriptReleaseFormPage, self).update()
    11621185        if self.context.state != TRANSVAL:
    11631186            self.flash(_('Student is in wrong state.'), type="warning")
     
    11731196        # Fire transition
    11741197        IWorkflowInfo(self.context).fireTransition('release_transcript')
    1175         self.flash(_('Transcript released.'))
     1198        self.flash(_('Transcript released and final transcript file saved.'))
    11761199        comment = self.request.form.get('comment', '').replace('\r', '')
    11771200        tz = getattr(queryUtility(IKofaUtils), 'tzinfo', pytz.utc)
     
    11901213        # Show and produce transcript file
    11911214        self.redirect(self.url(self.context) + '/studycourse/transcript.pdf')
    1192 
    1193         #subject = _('Transcript released')
    1194         #args = {'subject':subject, 'body':comment}
    1195         #self.redirect(self.url(self.context) +
    1196         #    '/contactstudent?%s' % urlencode(args))
    1197 
    11981215        return
    11991216
     
    12021219    for this page. It's an emergency page.
    12031220    """
    1204     grok.context(IStudent)
     1221    grok.context(IStudentTranscript)
    12051222    grok.name('manage_transcript_request')
    12061223    grok.require('waeup.processTranscript')
     
    13081325                         ]
    13091326
    1310         return students_utils.renderPDFTranscript(
     1327        pdfstream = students_utils.renderPDFTranscript(
    13111328            self, 'transcript.pdf',
    13121329            self.context.student, studentview,
     
    13171334            save_file=self._save_file(),
    13181335            )
     1336        if not pdfstream:
     1337            self.redirect(self.url(self.context.student))
     1338            return
     1339        return pdfstream
    13191340
    13201341class StudentTransferFormPage(KofaAddFormPage):
     
    14941515
    14951516    def update(self, ADD=None, course=None):
    1496         if not self.context.__parent__.is_current:
     1517        if not self.context.__parent__.is_current \
     1518            or self.context.student.studycourse_locked:
    14971519            emit_lock_message(self)
    14981520            return
     
    15661588            emit_lock_message(self)
    15671589            return
    1568         if str(self.context.__parent__.current_level) != self.context.__name__:
     1590        if str(self.context.student.current_level) != self.context.__name__:
    15691591            self.flash(_('This is not the student\'s current level.'),
    15701592                       type="danger")
     
    16621684
    16631685    def update(self):
    1664         if not self.context.__parent__.is_current:
     1686        if not self.context.__parent__.is_current \
     1687            or self.context.student.studycourse_locked:
    16651688            emit_lock_message(self)
    16661689            return
     
    17141737    pnav = 4
    17151738    grok.template('courseticketmanagepage')
     1739
     1740    def update(self):
     1741        if not self.context.__parent__.__parent__.is_current \
     1742            or self.context.student.studycourse_locked:
     1743            emit_lock_message(self)
     1744            return
     1745        super(CourseTicketManageFormPage, self).update()
     1746        return
    17161747
    17171748    @property
     
    26422673
    26432674    def update(self):
    2644         if not self.context.is_current:
     2675        if not self.context.is_current \
     2676            or self.context.student.studycourse_locked:
    26452677            emit_lock_message(self)
    26462678            return
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/fileviewlets.py

    r14880 r15140  
    153153
    154154
     155class FinalTranscriptImage(StudentImage):
     156    """Renders final transcript.
     157    """
     158    grok.name('final_transcript')
     159    download_name = u'final_transcript'
     160
     161
    155162class BirthCertificateImage(StudentImage):
    156163    """Renders birth certificate scan.
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/student.py

    r14169 r15140  
    3838    IKofaUtils, registration_states_vocab, IExtFileStore,
    3939    CREATED, ADMITTED, CLEARANCE, PAID, REGISTERED, VALIDATED, RETURNING,
    40     GRADUATED)
     40    GRADUATED, TRANSVAL, TRANSREL)
    4141from waeup.kofa.students.accommodation import StudentAccommodation
    4242from waeup.kofa.students.interfaces import (
     
    239239    def transcript_enabled(self):
    240240        return True
     241
     242    @property
     243    def studycourse_locked(self):
     244        return self.state in (GRADUATED, TRANSREL, TRANSVAL)
    241245
    242246    @property
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/tests/test_browser.py

    r15128 r15140  
    21512151        self.browser.getLink("K1000000").click()
    21522152        self.assertFalse('Release transcript request' in self.browser.contents)
    2153         # ToDo: Somebody has to validate the transcript
    2154 
    2155 
    2156 
    2157         IWorkflowState(self.student).setState('transcript validated')
    2158 
    2159 
    2160 
    2161         self.browser.open(self.student_path)
     2153        # Officer has to validate the transcript
     2154        self.browser.getLink("Validate transcript").click()
     2155
     2156
     2157
     2158
    21622159        self.assertTrue('Release transcript' in self.browser.contents)
    21632160        # Now the transcript can be released.
     
    21682165        self.browser.getControl(name="comment").value = (
    21692166            'Hello,\nYour transcript has been sent to the address provided.')
    2170         self.browser.getControl("Save comment and mark as released").click()
     2167        self.browser.getControl("Save comment and release transcript").click()
    21712168        self.assertTrue(
    21722169            'UTC mrtranscript wrote:\n\nHello,\nYour transcript has '
     
    21782175        logcontent = open(logfile).read()
    21792176        self.assertTrue(
    2180             'mrtranscript - students.browser.StudentTranscriptReleasesFormPage - '
     2177            'mrtranscript - students.browser.StudentTranscriptReleaseFormPage - '
    21812178            'K1000000 - comment: Hello,<br>'
    21822179            'Your transcript has been sent to the address provided'
     
    21862183        storage = getUtility(IExtFileStore)
    21872184        file_id = IFileStoreNameChooser(
    2188             self.student).chooseName(attr='transcript.pdf')
     2185            self.student).chooseName(attr='final_transcript.pdf')
    21892186        pdf = storage.getFile(file_id).read()
    21902187        self.assertTrue(len(pdf) > 0)
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/utils.py

    r15128 r15140  
    860860        file_store = getUtility(IExtFileStore)
    861861        file_id = IFileStoreNameChooser(student).chooseName(
    862             attr="transcript.pdf")
     862            attr="final_transcript.pdf")
    863863        file_store.createFile(file_id, StringIO(transcript))
    864864        return
     
    979979        if save_file:
    980980            self._saveTranscriptPDF(student, pdf_stream)
     981            return
    981982        return pdf_stream
    982983
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/viewlets.py

    r15134 r15140  
    3232    OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage,
    3333    StudentClearanceEditFormPage, StudentPersonalEditFormPage,
    34     PaymentsManageFormPage, StudyCourseTranscriptPage, EditScoresPage)
     34    PaymentsManageFormPage, StudyCourseTranscriptPage, EditScoresPage,)
    3535from waeup.kofa.students.interfaces import (
    3636    IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel,
    3737    ICourseTicket, IStudentOnlinePayment, IBedTicket,
    38     IStudentPaymentsContainer, IStudentsUtils
     38    IStudentPaymentsContainer, IStudentsUtils, IStudentTranscript
    3939    )
    4040from waeup.kofa.students.workflow import (
     
    145145class StudentManageTranscriptLink(StudentManageLink):
    146146    grok.order(9)
    147     link = 'transcript.pdf'
     147    link = 'final_transcript'
    148148    text = _(u'Final Transcript')
    149149
     
    155155            text = translate(
    156156                self.text, 'waeup.kofa', target_language=lang)
    157             url = self.view.url(self.context.student['studycourse'], self.link)
     157            url = self.view.url(self.context.student, self.link)
    158158            return u'<li><a href="%s">%s</a></li>' % (
    159159                url, text)
     
    762762class RequestTranscriptActionButton(ManageActionButton):
    763763    grok.order(8)
    764     grok.context(IStudent)
     764    grok.context(IStudentTranscript)
    765765    grok.view(StudentBaseDisplayFormPage)
    766766    grok.require('waeup.handleStudent')
     
    776776
    777777
     778class ValidateTranscriptActionButton(ManageActionButton):
     779    grok.order(9)
     780    grok.context(IStudentTranscript)
     781    grok.view(StudentBaseDisplayFormPage)
     782    grok.require('waeup.processTranscript')
     783    text = _('Validate transcript')
     784    target = 'validate_transcript'
     785    icon = 'actionicon_transcript.png'
     786
     787    @property
     788    def target_url(self):
     789        if self.context.state != TRANSREQ:
     790            return ''
     791        return self.view.url(self.view.context, self.target)
     792
     793    @property
     794    def onclick(self):
     795        return "return window.confirm(%s);" % _(
     796            "'Course results cannot be changed after transcript "
     797            "validation. \\n\\n"
     798            "You really want to validate the transcript?'")
     799
     800
    778801class ReleaseTranscriptActionButton(ManageActionButton):
    779802    grok.order(9)
    780     grok.context(IStudent)
     803    grok.context(IStudentTranscript)
    781804    grok.view(StudentBaseDisplayFormPage)
    782805    grok.require('waeup.processTranscript')
  • main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/workflow.py

    r15128 r15140  
    209209    Transition(
    210210        transition_id = 'validate_transcript',
    211         title = _('Transcript validated'),
     211        title = _('Validate transcript'),
    212212        msg = _("Transcript validated"),
    213213        source = TRANSREQ,
     
    216216    Transition(
    217217        transition_id = 'release_transcript',
    218         title = _('Transcript released'),
     218        title = _('Release transcript'),
    219219        msg = _("Transcript released"),
    220220        source = TRANSVAL,
    221221        destination = TRANSREL),
     222
     223    Transition(
     224        transition_id = 'reset11',
     225        title = _('Reset to graduated'),
     226        msg = _("Transcript process reset"),
     227        source = TRANSREL,
     228        destination = GRADUATED),
    222229    )
    223230
Note: See TracChangeset for help on using the changeset viewer.