Ignore:
Timestamp:
25 Oct 2011, 10:16:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement write_log_message function and log removal of payments as well as valid callbacks.

File:
1 edited

Legend:

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

    r6940 r6943  
    5050from waeup.sirp.authentication import get_principal_role_manager
    5151
     52def write_log_message(view, message):
     53    ob_class = view.__implemented__.__name__.replace('waeup.sirp.','')
     54    view.context.getStudent().loggerInfo(ob_class, message)
     55    return
     56
    5257# Save function used for save methods in manager pages
    5358def msave(view, **data):
    5459    form = view.request.form
    55     ob_class = view.__implemented__.__name__.replace('waeup.sirp.','')
    5660    changed_fields = view.applyData(view.context, **data)
    5761    # Turn list of lists into single list
     
    6266    view.flash('Form has been saved.')
    6367    if fields_string:
    64         view.context.getStudent().loggerInfo(ob_class, 'saved: % s' % fields_string)
     68        write_log_message(view, 'saved: % s' % fields_string)
    6569    return
    6670
     
    366370    def save(self, **data):
    367371        form = self.request.form
    368         ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    369372        password = form.get('password', None)
    370373        password_ctl = form.get('control_password', None)
     
    376379                #      are no (other) errors left in form.
    377380                IUserAccount(self.context).setPassword(password)
    378                 self.context.loggerInfo(ob_class, 'password changed')
     381                write_log_message(self, 'password changed')
    379382
    380383        #self.reg_number = form.get('form.reg_number', None)
     
    403406        self.flash('Form has been saved.')
    404407        if fields_string:
    405             self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
     408            write_log_message(self, 'saved: % s' % fields_string)
    406409        return
    407410
     
    772775
    773776# We don't need the display form page yet
    774 class PaymentsDisplayFormPage(WAeUPDisplayFormPage):
    775     """ Page to display the student payments
    776     """
    777     grok.context(IStudentPaymentsContainer)
    778     grok.name('view')
    779     grok.require('waeup.viewStudent')
    780     form_fields = grok.AutoFields(IStudentPaymentsContainer)
    781     grok.template('paymentspage')
    782     title = 'Payments'
    783     pnav = 4
    784 
    785     def formatDatetime(self,datetimeobj):
    786         if isinstance(datetimeobj, datetime):
    787             return datetimeobj.strftime("%Y-%m-%d %H:%M:%S")
    788         else:
    789             return None
    790 
    791     @property
    792     def label(self):
    793         return '%s: Payments' % self.context.__parent__.fullname
    794 
    795     def update(self):
    796         super(PaymentsDisplayFormPage, self).update()
    797         datatable.need()
    798         return
     777#class PaymentsDisplayFormPage(WAeUPDisplayFormPage):
     778#    """ Page to display the student payments
     779#    """
     780#    grok.context(IStudentPaymentsContainer)
     781#    grok.name('view')
     782#    grok.require('waeup.viewStudent')
     783#    form_fields = grok.AutoFields(IStudentPaymentsContainer)
     784#    grok.template('paymentspage')
     785#    title = 'Payments'
     786#    pnav = 4
     787
     788#    def formatDatetime(self,datetimeobj):
     789#        if isinstance(datetimeobj, datetime):
     790#            return datetimeobj.strftime("%Y-%m-%d %H:%M:%S")
     791#        else:
     792#            return None
     793
     794#    @property
     795#    def label(self):
     796#        return '%s: Payments' % self.context.__parent__.fullname
     797
     798#    def update(self):
     799#        super(PaymentsDisplayFormPage, self).update()
     800#        datatable.need()
     801#        return
    799802
    800803# This manage form page is for both students and students officers.
     
    853856        if len(deleted):
    854857            self.flash('Successfully removed: %s' % ', '.join(deleted))
     858            write_log_message(self,'removed: % s' % ', '.join(deleted))
    855859        self.redirect(self.url(self.context))
    856860        return
     
    936940    def update(self):
    937941        student = self.context.getStudent()
     942        write_log_message(self,'valid callback: %s' % self.context.p_id)
    938943        self.context.r_amount_approved = self.context.amount_auth
    939944        self.context.r_card_num = u'0000'
Note: See TracChangeset for help on using the changeset viewer.