Ignore:
Timestamp:
16 Apr 2021, 15:12:37 (4 years ago)
Author:
Henrik Bettermann
Message:

Enable managers to edit/remove all flash notices of students in a department.

File:
1 edited

Legend:

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

    r16459 r16465  
    4343from waeup.kofa.browser.interfaces import ICaptchaManager
    4444from waeup.kofa.browser.layout import (
    45     KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage,
     45    KofaPage, KofaFormPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage,
    4646    NullValidator, jsaction, action, UtilityView)
    4747from waeup.kofa.browser.pages import (
     
    5656from waeup.kofa.mandates.mandate import PasswordMandate, ParentsPasswordMandate
    5757from waeup.kofa.university.interfaces import (
    58     IDepartment, ICertificate, ICourse)
     58    IDepartment, ICertificate, ICourse, IFlashNotice)
    5959from waeup.kofa.university.certificate import (
    6060    VirtualCertificateExportJobContainer)
     
    37963796        return
    37973797
    3798 class RemoveFlashNoticeAllStudentsInDepartmentView(UtilityView, grok.View):
    3799     """ Remove flash notices of all students in a department.
     3798#class RemoveFlashNoticeAllStudentsInDepartmentView(UtilityView, grok.View):
     3799#    """ Remove flash notices of all students in a department.
     3800#    """
     3801#    grok.context(IDepartment)
     3802#    grok.name('removeflash')
     3803#    grok.require('waeup.manageStudent')
     3804
     3805#    def update(self):
     3806#        cat = queryUtility(ICatalog, name='students_catalog')
     3807#        students = cat.searchResults(
     3808#            depcode=(self.context.code, self.context.code),
     3809#            )
     3810#        num = 0
     3811#        for student in students:
     3812#            student.flash_notice = u''
     3813#            num += 1
     3814#        self.flash(_('%d flash notices have been removed.' % num))
     3815#        self.redirect(self.url(self.context))
     3816#        return
     3817
     3818#    def render(self):
     3819#        return
     3820
     3821class EditFlashNoticesFormPage(KofaFormPage):
     3822    """Edit all flash notices of students in a department.
    38003823    """
    38013824    grok.context(IDepartment)
    3802     grok.name('removeflash')
     3825    grok.name('edit_flash_notices')
     3826    grok.template('editflashnotices')
    38033827    grok.require('waeup.manageStudent')
    3804 
    3805     def update(self):
     3828    form_fields = grok.AutoFields(IFlashNotice)
     3829    pnav = 0
     3830
     3831    def label(self):
     3832        return _(u'Set flash notices for all students in ${a}',
     3833            mapping = {'a':self.context.longtitle})
     3834
     3835    @action('Save flash notices', style='primary')
     3836    def save(self, *args, **data):
    38063837        cat = queryUtility(ICatalog, name='students_catalog')
    38073838        students = cat.searchResults(
     
    38103841        num = 0
    38113842        for student in students:
    3812             student.flash_notice = u''
     3843            student.flash_notice = data['flash_notice']
    38133844            num += 1
    3814         self.flash(_('%d flash notices have been removed.' % num))
     3845        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
     3846        grok.getSite().logger.info(
     3847            '%s - %s - saved flash notice: %s'
     3848            % (ob_class, self.context.__name__, data['flash_notice']))
     3849        self.flash(_('%d flash notices have been edited.' % num))
    38153850        self.redirect(self.url(self.context))
    38163851        return
    38173852
    3818     def render(self):
    3819         return
     3853    @action(_('Cancel'), validator=NullValidator)
     3854    def cancel(self, **data):
     3855        self.redirect(self.url(self.context))
    38203856
    38213857class EditScoresPage(KofaPage):
Note: See TracChangeset for help on using the changeset viewer.