Changeset 16465 for main/waeup.kofa/trunk
- Timestamp:
- 16 Apr 2021, 15:12:37 (4 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16459 r16465 5 5 ======================= 6 6 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. 8 8 9 9 1.7 (2021-04-13) -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r16459 r16465 560 560 "'All students, who requested clearance in this department, will be cleared. Are you sure?'") 561 561 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 579 class EditFlashDepartmentStudentsActionButton(ManageActionButton): 580 """ 'Edit all flash notices' button for departments. 564 581 """ 565 582 grok.context(IDepartment) … … 567 584 grok.name('removeflashdepartmentstudents') 568 585 grok.require('waeup.manageStudent') 569 icon = 'actionicon_ wipe.png'570 text = _(' Removeall flash notices')571 target = ' removeflash'586 icon = 'actionicon_flash.png' 587 text = _('Edit all flash notices') 588 target = 'edit_flash_notices' 572 589 grok.order(5) 573 574 @property575 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 590 579 591 class ManageCourseActionButton(ManageActionButton): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r16459 r16465 43 43 from waeup.kofa.browser.interfaces import ICaptchaManager 44 44 from waeup.kofa.browser.layout import ( 45 KofaPage, Kofa EditFormPage, KofaAddFormPage, KofaDisplayFormPage,45 KofaPage, KofaFormPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage, 46 46 NullValidator, jsaction, action, UtilityView) 47 47 from waeup.kofa.browser.pages import ( … … 56 56 from waeup.kofa.mandates.mandate import PasswordMandate, ParentsPasswordMandate 57 57 from waeup.kofa.university.interfaces import ( 58 IDepartment, ICertificate, ICourse )58 IDepartment, ICertificate, ICourse, IFlashNotice) 59 59 from waeup.kofa.university.certificate import ( 60 60 VirtualCertificateExportJobContainer) … … 3796 3796 return 3797 3797 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 3821 class EditFlashNoticesFormPage(KofaFormPage): 3822 """Edit all flash notices of students in a department. 3800 3823 """ 3801 3824 grok.context(IDepartment) 3802 grok.name('removeflash') 3825 grok.name('edit_flash_notices') 3826 grok.template('editflashnotices') 3803 3827 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): 3806 3837 cat = queryUtility(ICatalog, name='students_catalog') 3807 3838 students = cat.searchResults( … … 3810 3841 num = 0 3811 3842 for student in students: 3812 student.flash_notice = u''3843 student.flash_notice = data['flash_notice'] 3813 3844 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)) 3815 3850 self.redirect(self.url(self.context)) 3816 3851 return 3817 3852 3818 def render(self): 3819 return 3853 @action(_('Cancel'), validator=NullValidator) 3854 def cancel(self, **data): 3855 self.redirect(self.url(self.context)) 3820 3856 3821 3857 class EditScoresPage(KofaPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r16459 r16465 1882 1882 return 1883 1883 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): 1885 1894 self.student.flash_notice = u'test' 1886 1895 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1887 1896 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) 1891 1915 return 1892 1916 -
main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py
r15629 r16465 76 76 def addFaculty(faculty): 77 77 """Add an IFactulty object. 78 79 78 """ 79 80 80 81 class IDepartment(IKofaObject): 81 82 """Representation of a department. … … 137 138 138 139 140 class 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 139 153 class ICoursesContainer(IKofaContainer): 140 154 """A container for faculties. … … 145 159 Returns the key, under which the object was stored. 146 160 """ 161 147 162 148 163 class ICourse(IKofaObject): … … 216 231 default = False, 217 232 ) 233 218 234 219 235 class ICertificate(IKofaObject): … … 341 357 """ 342 358 359 343 360 class ICertificateCourse(IKofaObject): 344 361 """A certificatecourse is referring a course and provides some own
Note: See TracChangeset for help on using the changeset viewer.