Changeset 11597


Ignore:
Timestamp:
23 Apr 2014, 10:29:32 (11 years ago)
Author:
Henrik Bettermann
Message:

View and viewlet added which enable students to generate a matric number.

Location:
main/waeup.aaue/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/CHANGES.txt

    r11591 r11597  
    441.2dev (unreleased)
    55===================
     6
     7* constructMatricNumber customized. AAUE matric number construction scheme
     8  applied. View and viewlet added which enable students to generate
     9  a matric number.
    610
    711* STUDY_MODES_DICT customized.
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r11555 r11597  
    1919from zope.i18n import translate
    2020from zope.component import getUtility
     21from waeup.kofa.browser.layout import UtilityView
    2122from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2223from waeup.kofa.interfaces import IKofaUtils
    23 from waeup.kofa.students.interfaces import IStudentsUtils
     24from waeup.kofa.students.interfaces import IStudentsUtils, IStudent
    2425from waeup.kofa.students.browser import (
    2526    StudentBasePDFFormPage,
     
    188189            'waeup.kofa', target_language=portal_language) \
    189190            + ' %s' % self.context.display_fullname
     191
     192class StudentGetMatricNumberPage(UtilityView, grok.View):
     193    """ Construct and set the matriculation number.
     194    """
     195    grok.context(IStudent)
     196    grok.name('get_matric_number')
     197    grok.require('waeup.viewStudent')
     198
     199    def update(self):
     200        students_utils = getUtility(IStudentsUtils)
     201        msg, mnumber = students_utils.setMatricNumber(self.context)
     202        if msg:
     203            self.flash(msg, type="danger")
     204        else:
     205            self.flash(_('Matriculation number %s assigned.' % mnumber))
     206        self.redirect(self.url(self.context))
     207        return
     208
     209    def render(self):
     210        return
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r11596 r11597  
    1818import shutil
    1919import tempfile
     20import grok
     21from mechanize import LinkNotFoundError
    2022from hurry.workflow.interfaces import IWorkflowState
    2123from zope.component.hooks import setSite, clearSite
     
    332334        return
    333335
    334 
     336    def test_set_matric_number(self):
     337        # Login as student
     338        self.browser.open(self.login_path)
     339        #IWorkflowState(self.student).setState('school fee paid')
     340        self.browser.open(self.login_path)
     341        self.browser.getControl(name="form.login").value = self.student_id
     342        self.browser.getControl(name="form.password").value = 'spwd'
     343        self.browser.getControl("Login").click()
     344        self.assertRaises(
     345            LinkNotFoundError,
     346            self.browser.getLink, 'Get Matriculation Number')
     347        self.student.matric_number = None
     348        site = grok.getSite()
     349        site['configuration'].next_matric_integer = 1
     350        self.student['studycourse'].certificate.study_mode = 'ug_pt'
     351        self.browser.open(self.student_path)
     352        self.browser.getLink("Get Matriculation Number").click()
     353        self.assertTrue('Matriculation number PTP/fac1/dep1/04/00001 assigned.'
     354            in self.browser.contents)
     355        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00001')
     356        self.assertRaises(
     357            LinkNotFoundError,
     358            self.browser.getLink, 'Get Matriculation Number')
     359        return
     360
  • main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py

    r9870 r11597  
    1717##
    1818
     19import grok
     20from zope.component import getUtility
     21from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
    1922from waeup.kofa.students.viewlets import (
    20     AddPreviousPaymentActionButton, AddBalancePaymentActionButton)
     23    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
     24    ManageActionButton, StudentBaseDisplayFormPage)
     25
     26from waeup.aaue.interfaces import MessageFactory as _
    2127
    2228class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
     
    3137    def target_url(self):
    3238        return ''
     39
     40class GetMatricNumberActionButton(ManageActionButton):
     41    grok.order(10)
     42    grok.context(IStudent)
     43    grok.view(StudentBaseDisplayFormPage)
     44    grok.require('waeup.viewStudent')
     45    icon = 'actionicon_count.png'
     46    text = _('Get Matriculation Number')
     47
     48    @property
     49    def target_url(self):
     50        students_utils = getUtility(IStudentsUtils)
     51        if self.context.matric_number:
     52            return ''
     53        matric_number = students_utils.constructMatricNumber(self.context)
     54        if not matric_number:
     55            return ''
     56        return self.view.url(self.view.context, 'get_matric_number')
Note: See TracChangeset for help on using the changeset viewer.