Changeset 9011 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 18 Jul 2012, 06:01:56 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r8984 r9011 67 67 from waeup.kofa.widgets.htmlwidget import HTMLDisplayWidget 68 68 from waeup.kofa.authentication import get_principal_role_manager 69 from waeup.kofa.utils.helpers import get_user_account , msave69 from waeup.kofa.utils.helpers import get_user_account 70 70 from waeup.kofa.mandates.mandate import PasswordMandate 71 71 … … 157 157 return 158 158 159 # Save function used for save methods in pages 160 def msave(view, **data): 161 changed_fields = view.applyData(view.context, **data) 162 # Turn list of lists into single list 163 if changed_fields: 164 changed_fields = reduce(lambda x,y: x+y, changed_fields.values()) 165 fields_string = ' + '.join(changed_fields) 166 view.flash(_('Form has been saved.')) 167 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 168 if fields_string: 169 grok.getSite().logger.info('%s - saved: %s' % (ob_class, fields_string)) 170 return 171 159 172 # 160 173 # Login/logout and language switch pages... … … 373 386 def entries(self): 374 387 return () 375 376 class ReindexPage(UtilityView, grok.View):377 """ Reindex view.378 379 Reindexes a catalog. For managers only.380 """381 grok.context(IUniversity)382 grok.name('reindex')383 grok.require('waeup.managePortal')384 385 def update(self,ctlg=None):386 if ctlg is None:387 self.flash('No catalog name provided.')388 return389 cat = queryUtility(ICatalog, name='%s_catalog' % ctlg)390 if cat is None:391 self.flash('%s_catalog does not exist' % ctlg)392 return393 self.context.logger.info(394 'Catalog `%s_catalog` re-indexing started.' % ctlg)395 cat.updateIndexes()396 no_of_entries = cat.values()[0].documentCount()397 self.flash('%d %s re-indexed.' % (no_of_entries,ctlg))398 self.context.logger.info(399 'Re-indexing of %d objects finished.' % no_of_entries)400 return401 402 def render(self):403 self.redirect(self.url(self.context, '@@index'))404 return405 388 406 389 # -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r8984 r9011 1868 1868 self.assertTrue('An email with' in self.browser.contents) 1869 1869 1870 def test_reindex(self):1871 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')1872 self.browser.open('http://localhost/app/reindex')1873 self.assertTrue('No catalog name provided' in self.browser.contents)1874 self.browser.open('http://localhost/app/reindex?ctlg=xyz')1875 self.assertTrue('xyz_catalog does not exist' in self.browser.contents)1876 cat = queryUtility(ICatalog, name='students_catalog')1877 results = cat.searchResults(student_id=(None, None))1878 self.assertEqual(len(results),1)1879 cat.clear()1880 results = cat.searchResults(student_id=(None, None))1881 self.assertEqual(len(results),0)1882 self.browser.open('http://localhost/app/reindex?ctlg=students')1883 self.assertTrue('1 students re-indexed' in self.browser.contents)1884 results = cat.searchResults(student_id=(None, None))1885 self.assertEqual(len(results),1)1886 1887 1870 def test_change_current_mode(self): 1888 1871 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') -
main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py
r8739 r9011 683 683 writer.writerow(row) 684 684 return tmp_path 685 686 # Save function used for save methods in pages687 def msave(view, **data):688 changed_fields = view.applyData(view.context, **data)689 # Turn list of lists into single list690 if changed_fields:691 changed_fields = reduce(lambda x,y: x+y, changed_fields.values())692 fields_string = ' + '.join(changed_fields)693 view.flash(_('Form has been saved.'))694 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','')695 if fields_string:696 grok.getSite().logger.info('%s - saved: %s' % (ob_class, fields_string))697 return
Note: See TracChangeset for help on using the changeset viewer.