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.

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

Legend:

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

    r16459 r16465  
    55=======================
    66
    7 * Enable managers to remove all flash notices of students in a department.
     7* Enable managers to edit/remove all flash notices of students in a department.
    88
    991.7 (2021-04-13)
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r16459 r16465  
    560560            "'All students, who requested clearance in this department, will be cleared. Are you sure?'")
    561561
    562 class RemoveFlashDepartmentStudentsActionButton(ManageActionButton):
    563     """ 'Remove all flash notices' button for departments.
     562#class RemoveFlashDepartmentStudentsActionButton(ManageActionButton):
     563#    """ 'Remove all flash notices' button for departments.
     564#    """
     565#    grok.context(IDepartment)
     566#    grok.view(DepartmentPage)
     567#    grok.name('removeflashdepartmentstudents')
     568#    grok.require('waeup.manageStudent')
     569#    icon = 'actionicon_wipe.png'
     570#    text = _('Remove all flash notices')
     571#    target = 'removeflash'
     572#    grok.order(5)
     573
     574#    @property
     575#    def onclick(self):
     576#        return "return window.confirm(%s);" % _(
     577#            "'Flash notices of all students in this department will be removed. Are you sure?'")
     578
     579class EditFlashDepartmentStudentsActionButton(ManageActionButton):
     580    """ 'Edit all flash notices' button for departments.
    564581    """
    565582    grok.context(IDepartment)
     
    567584    grok.name('removeflashdepartmentstudents')
    568585    grok.require('waeup.manageStudent')
    569     icon = 'actionicon_wipe.png'
    570     text = _('Remove all flash notices')
    571     target = 'removeflash'
     586    icon = 'actionicon_flash.png'
     587    text = _('Edit all flash notices')
     588    target = 'edit_flash_notices'
    572589    grok.order(5)
    573 
    574     @property
    575     def onclick(self):
    576         return "return window.confirm(%s);" % _(
    577             "'Flash notices of all students in this department will be removed. Are you sure?'")
    578590
    579591class ManageCourseActionButton(ManageActionButton):
  • 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):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r16459 r16465  
    18821882        return
    18831883
    1884     def test_remove_all_flash_notices(self):
     1884    #def test_remove_all_flash_notices(self):
     1885    #    self.student.flash_notice = u'test'
     1886    #    self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1887    #    self.browser.open('http://localhost/app/faculties/fac1/dep1')
     1888    #    self.browser.getLink("Remove all flash notices").click()
     1889    #    self.assertTrue('1 flash notices have been removed' in self.browser.contents)
     1890    #    self.assertEqual(self.student.flash_notice, '')
     1891    #    return
     1892
     1893    def test_edit_all_flash_notices(self):
    18851894        self.student.flash_notice = u'test'
    18861895        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    18871896        self.browser.open('http://localhost/app/faculties/fac1/dep1')
    1888         self.browser.getLink("Remove all flash notices").click()
    1889         self.assertTrue('1 flash notices have been removed' in self.browser.contents)
    1890         self.assertEqual(self.student.flash_notice, '')
     1897        self.browser.getLink("Edit all flash notices").click()
     1898        self.browser.getControl(name="form.flash_notice").value = 'Hello'
     1899        self.browser.getControl("Save flash notices").click()
     1900        self.assertTrue('1 flash notices have been edited' in self.browser.contents)
     1901        self.assertEqual(self.student.flash_notice, 'Hello')
     1902        self.browser.getLink("Edit all flash notices").click()
     1903        self.browser.getControl("Save flash notices").click()
     1904        self.assertTrue('1 flash notices have been edited' in self.browser.contents)
     1905        self.assertEqual(self.student.flash_notice, None)
     1906        logfile = os.path.join(
     1907            self.app['datacenter'].storage, 'logs', 'main.log')
     1908        logcontent = open(logfile).read()
     1909        self.assertTrue(
     1910            'zope.mgr - students.browser.EditFlashNoticesFormPage - dep1 - '
     1911            'saved flash notice: Hello' in logcontent)
     1912        self.assertTrue(
     1913            'zope.mgr - students.browser.EditFlashNoticesFormPage - dep1 - '
     1914            'saved flash notice: None' in logcontent)
    18911915        return
    18921916
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r15629 r16465  
    7676    def addFaculty(faculty):
    7777        """Add an IFactulty object.
    78 
    7978        """
     79
     80
    8081class IDepartment(IKofaObject):
    8182    """Representation of a department.
     
    137138
    138139
     140class IFlashNotice(IKofaObject):
     141    """An interface for the flash notice edit form page.
     142    """
     143
     144    flash_notice = schema.TextLine(
     145        title = _(u'Flash Notice'),
     146        description = _(
     147            u'If you save an empty field, all flash notices will be removed.'),
     148        required = False,
     149        readonly = False,
     150        )
     151
     152
    139153class ICoursesContainer(IKofaContainer):
    140154    """A container for faculties.
     
    145159        Returns the key, under which the object was stored.
    146160        """
     161
    147162
    148163class ICourse(IKofaObject):
     
    216231        default = False,
    217232        )
     233
    218234
    219235class ICertificate(IKofaObject):
     
    341357        """
    342358
     359
    343360class ICertificateCourse(IKofaObject):
    344361    """A certificatecourse is referring a course and provides some own
Note: See TracChangeset for help on using the changeset viewer.