Changeset 6637


Ignore:
Timestamp:
27 Aug 2011, 13:19:07 (13 years ago)
Author:
Henrik Bettermann
Message:

Add logger, student workflow and student workflow history.

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

Legend:

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

    r6635 r6637  
    307307    target = 'accommodation'
    308308
     309class HistoryViewActionButton(PlainActionButton):
     310    grok.order(7)
     311    grok.context(IStudent)
     312    grok.view(StudentBaseDisplayFormPage)
     313    grok.require('waeup.viewStudents')
     314    text = 'History'
     315    target = 'history'
     316
    309317class StudentBaseManageFormPage(WAeUPEditFormPage):
    310318    """ View to edit student base data
     
    445453    def label(self):
    446454        return '%s: Accommodation Data' % self.context.__parent__.name
     455
     456class StudentHistoryPage(WAeUPPage):
     457    """ Page to display student clearance data
     458    """
     459    grok.context(IStudent)
     460    grok.name('history')
     461    grok.require('waeup.viewStudents')
     462    grok.template('studenthistory')
     463
     464    @property
     465    def title(self):
     466        return 'Student: %s' % self.context.name
     467
     468    @property
     469    def label(self):
     470        return '%s: History' % self.context.name
  • main/waeup.sirp/trunk/src/waeup/sirp/students/container.py

    r6635 r6637  
    2626from waeup.sirp.students.payments import StudentPayments
    2727from waeup.sirp.students.accommodation import StudentAccommodation
     28from waeup.sirp.utils.helpers import get_current_principal
     29from waeup.sirp.utils.logger import Logger
    2830
    29 class StudentsContainer(grok.Container):
     31class StudentsContainer(grok.Container, Logger):
    3032    """
    3133    The node containing the student models
     
    5355        self[student.student_id]['accommodation'] = accommodation
    5456        return
     57
     58    logger_name = 'waeup.sirp.${sitename}.students'
     59    logger_filename = 'students.log'
     60
     61    def logger_info(self, target, ob_class, comment=None):
     62        """Get the logger's info method.
     63        """
     64        user = get_current_principal()
     65        if user is None:
     66            user = 'system'
     67        else:
     68            user = user.id
     69        self.logger.info('%s - %s - %s - %s' % (
     70                user, target, ob_class, comment))
     71        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6635 r6637  
    11##
    22## interfaces.py
    3 from zope.interface import Interface
     3from zope.interface import Interface, Attribute
    44from zope import schema
    55from waeup.sirp.interfaces import IWAeUPObject
     
    88    """Representation of student base data.
    99    """
     10    history = Attribute('Object history, a list of messages.')
     11    state = Attribute('Returns the registration state of a student')
     12
     13    def loggerInfo(ob_class, comment):
     14        """Adds an INFO message to the log file
     15        """
     16
    1017    student_id = schema.TextLine(
    1118        title = u'Student Id',
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r6632 r6637  
    2121from zope.component.interfaces import IFactory
    2222from zope.interface import implementedBy
     23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     24from waeup.sirp.interfaces import IObjectHistory
    2325from waeup.sirp.students.interfaces import IStudent
    2426from waeup.sirp.utils.helpers import attrs_to_fields
     
    3335    def __init__(self):
    3436        super(Student, self).__init__()
    35         #IWorkflowInfo(self).fireTransition('init')
     37        IWorkflowInfo(self).fireTransition('create')
    3638        return
     39
     40    def loggerInfo(self, ob_class, comment=None):
     41        target = self.__name__
     42        return grok.getSite()['students'].logger_info(ob_class,target,comment)
     43
     44    @property
     45    def state(self):
     46        state = IWorkflowState(self).getState()
     47        return state
     48
     49    @property
     50    def history(self):
     51        history = IObjectHistory(self)
     52        return history
    3753
    3854# Set all attributes of Student required in IStudent as field
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6635 r6637  
    9191        self.payments_student_path = self.student_path + '/payments'
    9292        self.accommodation_student_path = self.student_path + '/accommodation'
     93        self.history_student_path = self.student_path + '/history'
    9394
    9495        # Populate university
     
    231232        self.assertEqual(self.browser.url, self.accommodation_student_path)
    232233
     234        self.browser.open(self.student_path)
     235        self.browser.getLink("History").click()
     236        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     237        self.assertEqual(self.browser.url, self.history_student_path)
     238        self.assertMatches('...Student object created by system...', self.browser.contents)
     239
    233240        return
Note: See TracChangeset for help on using the changeset viewer.