Changeset 10458


Ignore:
Timestamp:
6 Aug 2013, 20:32:53 (11 years ago)
Author:
Henrik Bettermann
Message:

Add pages and buttons for transcript request processing. Work in progress, tests will follow!

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
6 edited

Legend:

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

    r9703 r10458  
    224224            self.widgets['next_kin_address'].cssClass = 'span8'
    225225            self.widgets['next_kin_address'].height = 6
     226        if self.widgets.get('transcript_comment'):
     227            self.widgets['transcript_comment'].cssClass = 'span8'
     228            self.widgets['transcript_comment'].height = 6
    226229        if self.widgets.get('notice'):
    227230            self.widgets['notice'].cssClass = 'span8'
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r10453 r10458  
    338338            'nationality,officer_comment,perm_address,personal_updated,'
    339339            'phone,reg_number,sex,student_id,suspended,suspended_comment,'
    340             'transcript_address,'
     340            'transcript_comment,'
    341341            'password,state,history,certcode,is_postgrad,current_level,'
    342342            'current_session\r\n')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10440 r10458  
    2020import sys
    2121import grok
     22import pytz
    2223from urllib import urlencode
    2324from datetime import datetime
     
    6465from waeup.kofa.university.vocabularies import course_levels
    6566from waeup.kofa.utils.batching import VirtualExportJobContainer
    66 from waeup.kofa.utils.helpers import get_current_principal, to_timezone
     67from waeup.kofa.utils.helpers import get_current_principal, to_timezone, now
    6768from waeup.kofa.widgets.restwidget import ReSTDisplayWidget
    6869from waeup.kofa.students.interfaces import (
     
    7475    ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer,
    7576    IStudentOnlinePayment, IStudentPreviousPayment, IStudentBalancePayment,
    76     IBedTicket, IStudentsUtils, IStudentRequestPW
     77    IBedTicket, IStudentsUtils, IStudentRequestPW, IStudentTranscript
    7778    )
    7879from waeup.kofa.students.catalog import search, StudentQueryResultItem
     
    8283from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID,
    8384    CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED,
    84     FORBIDDEN_POSTGRAD_TRANS)
     85    GRADUATED, TRANSCRIPT, FORBIDDEN_POSTGRAD_TRANS)
    8586
    8687
     
    10611062                self,'removed: %s' % ', '.join(deleted))
    10621063        self.redirect(self.url(self.context, u'@@manage')+'?tab2')
     1064        return
     1065
     1066class StudentRequestTranscriptPage(KofaPage):
     1067    """ Page to transcript by student
     1068    """
     1069    grok.context(IStudent)
     1070    grok.name('request_transcript')
     1071    grok.require('waeup.handleStudent')
     1072    grok.template('requesttranscript')
     1073    label = _('Request transcript')
     1074    ac_prefix = 'TSC'
     1075    notice = ''
     1076    pnav = 4
     1077    buttonname = _('Request transcript now')
     1078    with_ac = True
     1079
     1080    def update(self, SUBMIT=None):
     1081        if not self.context.state == GRADUATED:
     1082            self.flash(_("Wrong state"))
     1083            self.redirect(self.url(self.context))
     1084            return
     1085        if self.with_ac:
     1086            self.ac_series = self.request.form.get('ac_series', None)
     1087            self.ac_number = self.request.form.get('ac_number', None)
     1088        if self.context.transcript_comment is not None:
     1089            self.correspondence = self.context.transcript_comment.replace(
     1090                '\n', '<br>')
     1091        else:
     1092            self.correspondence = ''
     1093        if SUBMIT is None:
     1094            return
     1095        if self.with_ac:
     1096            pin = '%s-%s-%s' % (self.ac_prefix, self.ac_series, self.ac_number)
     1097            code = get_access_code(pin)
     1098            if not code:
     1099                self.flash(_('Activation code is invalid.'))
     1100                return
     1101            if code.state == USED:
     1102                self.flash(_('Activation code has already been used.'))
     1103                return
     1104            # Mark pin as used (this also fires a pin related transition)
     1105            # and fire transition start_clearance
     1106            comment = _(u"invalidated")
     1107            # Here we know that the ac is in state initialized so we do not
     1108            # expect an exception, but the owner might be different
     1109            if not invalidate_accesscode(pin, comment, self.context.student_id):
     1110                self.flash(_('You are not the owner of this access code.'))
     1111                return
     1112            self.context.clr_code = pin
     1113        IWorkflowInfo(self.context).fireTransition('request_transcript')
     1114        comment = self.request.form.get('comment', '').replace('\r', '')
     1115        address = self.request.form.get('address', '').replace('\r', '')
     1116        tz = getattr(queryUtility(IKofaUtils), 'tzinfo', pytz.utc)
     1117        today = now(tz).strftime('%d/%m/%Y %H:%M:%S %Z')
     1118        old_transcript_comment = self.context.transcript_comment
     1119        if old_transcript_comment == None:
     1120            old_transcript_comment = ''
     1121        self.context.transcript_comment = '''On %s %s wrote:
     1122
     1123%s
     1124
     1125Dispatch Address:
     1126%s
     1127
     1128%s''' % (today, self.request.principal.id, comment, address,
     1129         old_transcript_comment)
     1130        self.context.writeLogMessage(
     1131            self, 'comment: %s' % comment.replace('\n', '<br>'))
     1132        self.flash(_('Transcript processing has been started.'))
     1133        self.redirect(self.url(self.context))
     1134        return
     1135
     1136class StudentRequestTranscriptManageFormPage(KofaEditFormPage):
     1137    """ Page to edit personal data by student
     1138    """
     1139    grok.context(IStudent)
     1140    grok.name('manage_transcript_request')
     1141    grok.require('waeup.manageStudent')
     1142    form_fields = grok.AutoFields(IStudentTranscript)
     1143    label = _('Manage transcript request')
     1144    pnav = 4
     1145
     1146    def update(self):
     1147        super(StudentRequestTranscriptManageFormPage, self).update()
     1148        if self.context.state != TRANSCRIPT:
     1149            self.flash(_("Wrong state"))
     1150            self.redirect(self.url(self.context))
     1151        return
     1152
     1153    #@action(_('Save'), style='primary')
     1154    #def save(self, **data):
     1155    #    msave(self, **data)
     1156    #    return
     1157
     1158    @action(_('Save comment and mark as processed'), style='primary')
     1159    def process(self, **data):
     1160        if self.context.state == TRANSCRIPT:
     1161            IWorkflowInfo(self.context).fireTransition('process_transcript')
     1162            message = _('Transcript request processed.')
     1163            self.flash(message)
     1164        else:
     1165            self.flash(_('Student is in wrong state.'))
     1166            self.redirect(self.url(self.context))
     1167            return
     1168        self.applyData(self.context, **data)
     1169        comment = data['transcript_comment']
     1170        if comment:
     1171            self.context.writeLogMessage(
     1172                self, 'comment: %s' %
     1173                comment.replace('\r\n', '<br>'))
     1174            args = {'subject':message, 'body':comment}
     1175        else:
     1176            args = {'subject':message,}
     1177        self.redirect(self.url(self.context) +
     1178            '/contactstudent?%s' % urlencode(args))
    10631179        return
    10641180
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r10452 r10458  
    336336    """
    337337
    338     transcript_address = schema.Text(
    339         title = _(u'Address'),
    340         required = False,
    341         description = _(
    342             u'Enter address the transcript has been shipped to.'),
     338    transcript_comment = schema.Text(
     339        title = _(u'Comment'),
     340        required = False,
    343341        )
    344342
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r10455 r10458  
    141141            'nationality,officer_comment,perm_address,personal_updated,'
    142142            'phone,reg_number,sex,student_id,suspended,suspended_comment,'
    143             'transcript_address,password,state,history,certcode,is_postgrad,'
     143            'transcript_comment,password,state,history,certcode,is_postgrad,'
    144144            'current_level,current_session\r\n'
    145145            'my adm code,0,my clr code,'
     
    163163            'nationality,officer_comment,perm_address,personal_updated,'
    164164            'phone,reg_number,sex,student_id,suspended,suspended_comment,'
    165             'transcript_address,password,state,history,certcode,'
     165            'transcript_comment,password,state,history,certcode,'
    166166            'is_postgrad,current_level,current_session\r\n'
    167167            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
     
    183183            'nationality,officer_comment,perm_address,personal_updated,'
    184184            'phone,reg_number,sex,student_id,suspended,suspended_comment,'
    185             'transcript_address,password,state,history,certcode,'
     185            'transcript_comment,password,state,history,certcode,'
    186186            'is_postgrad,current_level,current_session\r\n'
    187187            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r10278 r10458  
    3333from waeup.kofa.students.workflow import (
    3434    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
    35     VALIDATED)
     35    VALIDATED, GRADUATED, TRANSCRIPT)
    3636from waeup.kofa.students.browser import (
    3737    clearance_disabled_message,
     
    675675    @property
    676676    def target_url(self):
     677        return self.view.url(self.view.context, self.target)
     678
     679class RequestTranscriptActionButton(ManageActionButton):
     680    grok.order(8)
     681    grok.context(IStudent)
     682    grok.view(StudentBaseDisplayFormPage)
     683    grok.require('waeup.handleStudent')
     684    text = _('Request transcript')
     685    target = 'request_transcript'
     686    icon = 'actionicon_transcript.png'
     687
     688    @property
     689    def target_url(self):
     690        if self.context.state != GRADUATED:
     691            return ''
     692        return self.view.url(self.view.context, self.target)
     693
     694class ManageTranscriptRequestActionButton(ManageActionButton):
     695    grok.order(9)
     696    grok.context(IStudent)
     697    grok.view(StudentBaseDisplayFormPage)
     698    grok.require('waeup.manageStudent')
     699    text = _('Manage transcript request')
     700    target = 'manage_transcript_request'
     701    icon = 'actionicon_transcript.png'
     702
     703    @property
     704    def target_url(self):
     705        if self.context.state != TRANSCRIPT:
     706            return ''
    677707        return self.view.url(self.view.context, self.target)
    678708
Note: See TracChangeset for help on using the changeset viewer.