- Timestamp:
- 13 Nov 2014, 14:40:27 (10 years ago)
- Location:
- main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/browser/pages.py
r11947 r11949 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """ Viewing components for Kofa objects.18 """ Viewing components for Ikoba objects. 19 19 """ 20 20 # XXX: All csv ops should move to a dedicated module soon … … 42 42 from zope.session.interfaces import ISession 43 43 from zope.password.interfaces import IPasswordManager 44 from waeup. kofa.browser.layout import (45 KofaPage, KofaForm, KofaEditFormPage, KofaAddFormPage,46 KofaDisplayFormPage, NullValidator)47 from waeup. kofa.browser.interfaces import (44 from waeup.ikoba.browser.layout import ( 45 IkobaPage, IkobaForm, IkobaEditFormPage, IkobaAddFormPage, 46 IkobaDisplayFormPage, NullValidator) 47 from waeup.ikoba.browser.interfaces import ( 48 48 IUniversity, ICaptchaManager, IChangePassword) 49 from waeup. kofa.browser.layout import jsaction, action, UtilityView50 from waeup. kofa.interfaces import MessageFactory as _51 from waeup. kofa.interfaces import(52 I KofaObject, IUsersContainer, IUserAccount, IDataCenter,53 I KofaXMLImporter, IKofaXMLExporter, IBatchProcessor,49 from waeup.ikoba.browser.layout import jsaction, action, UtilityView 50 from waeup.ikoba.interfaces import MessageFactory as _ 51 from waeup.ikoba.interfaces import( 52 IIkobaObject, IUsersContainer, IUserAccount, IDataCenter, 53 IIkobaXMLImporter, IIkobaXMLExporter, IBatchProcessor, 54 54 ILocalRolesAssignable, DuplicationError, IConfigurationContainer, 55 55 ISessionConfiguration, ISessionConfigurationAdd, IJobManager, 56 IPasswordValidator, IContactForm, I KofaUtils, ICSVExporter,56 IPasswordValidator, IContactForm, IIkobaUtils, ICSVExporter, 57 57 application_sessions_vocab) 58 from waeup. kofa.permissions import (58 from waeup.ikoba.permissions import ( 59 59 get_users_with_local_roles, get_all_roles, get_all_users, 60 60 get_users_with_role) 61 61 62 from waeup. kofa.authentication import LocalRoleSetEvent63 from waeup. kofa.widgets.htmlwidget import HTMLDisplayWidget64 from waeup. kofa.utils.helpers import get_user_account, check_csv_charset65 from waeup. kofa.mandates.mandate import PasswordMandate66 from waeup. kofa.datacenter import DataCenterFile62 from waeup.ikoba.authentication import LocalRoleSetEvent 63 from waeup.ikoba.widgets.htmlwidget import HTMLDisplayWidget 64 from waeup.ikoba.utils.helpers import get_user_account, check_csv_charset 65 from waeup.ikoba.mandates.mandate import PasswordMandate 66 from waeup.ikoba.datacenter import DataCenterFile 67 67 68 68 FORBIDDEN_CHARACTERS = (160,) 69 69 70 grok.context(I KofaObject)70 grok.context(IIkobaObject) 71 71 grok.templatedir('templates') 72 72 … … 81 81 role_manager.assignRoleToPrincipal(localrole, user) 82 82 notify(LocalRoleSetEvent(view.context, localrole, user, granted=True)) 83 ob_class = view.__implemented__.__name__.replace('waeup. kofa.','')83 ob_class = view.__implemented__.__name__.replace('waeup.ikoba.','') 84 84 grok.getSite().logger.info( 85 85 '%s - added: %s|%s' % (ob_class, user, localrole)) … … 113 113 _('Local role successfully removed: ${a}', 114 114 mapping = {'a':', '.join(deleted)})) 115 ob_class = view.__implemented__.__name__.replace('waeup. kofa.','')115 ob_class = view.__implemented__.__name__.replace('waeup.ikoba.','') 116 116 grok.getSite().logger.info( 117 117 '%s - removed: %s' % (ob_class, ', '.join(deleted))) … … 147 147 view.flash(_('Successfully removed: ${a}', 148 148 mapping = {'a': ', '.join(deleted)})) 149 ob_class = view.__implemented__.__name__.replace('waeup. kofa.','')149 ob_class = view.__implemented__.__name__.replace('waeup.ikoba.','') 150 150 grok.getSite().logger.info( 151 151 '%s - removed: %s' % (ob_class, ', '.join(deleted))) … … 188 188 fields_string = ' + '.join(changed_fields) 189 189 view.flash(_('Form has been saved.')) 190 ob_class = view.__implemented__.__name__.replace('waeup. kofa.','')190 ob_class = view.__implemented__.__name__.replace('waeup.ikoba.','') 191 191 if fields_string: 192 192 grok.getSite().logger.info('%s - %s - saved: %s' % (ob_class, view.context.__name__, fields_string)) … … 210 210 time_delta = None 211 211 if start_time: 212 tz = getUtility(I KofaUtils).tzinfo212 tz = getUtility(IIkobaUtils).tzinfo 213 213 time_delta = datetime.now(tz) - start_time 214 214 start_time = start_time.astimezone(tz).strftime( … … 252 252 # 253 253 254 class LoginPage( KofaPage):254 class LoginPage(IkobaPage): 255 255 """A login page, available for all objects. 256 256 """ 257 257 grok.name('login') 258 grok.context(I KofaObject)258 grok.context(IIkobaObject) 259 259 grok.require('waeup.Public') 260 260 label = _(u'Login') … … 288 288 289 289 290 class LogoutPage( KofaPage):290 class LogoutPage(IkobaPage): 291 291 """A logout page. Calling this page will log the current user out. 292 292 """ 293 grok.context(I KofaObject)293 grok.context(IIkobaObject) 294 294 grok.require('waeup.Public') 295 295 grok.name('logout') … … 299 299 auth = getUtility(IAuthentication) 300 300 ILogout(auth).logout(self.request) 301 self.flash(_("You have been logged out. Thanks for using WAeUP Kofa!"))301 self.flash(_("You have been logged out. Thanks for using WAeUP Ikoba!")) 302 302 self.redirect(self.application_url() + '/index') 303 303 return 304 304 305 305 306 class LanguageChangePage( KofaPage):306 class LanguageChangePage(IkobaPage): 307 307 """ Language switch 308 308 """ 309 grok.context(I KofaObject)309 grok.context(IIkobaObject) 310 310 grok.name('change_language') 311 311 grok.require('waeup.Public') 312 312 313 313 def update(self, lang='en', view_name='@@index'): 314 self.response.setCookie(' kofa.language', lang, path='/')314 self.response.setCookie('ikoba.language', lang, path='/') 315 315 self.redirect(self.url(self.context, view_name)) 316 316 return … … 323 323 # 324 324 325 class ContactAdminForm( KofaForm):325 class ContactAdminForm(IkobaForm): 326 326 grok.name('contactadmin') 327 327 #grok.context(IUniversity) … … 357 357 usertype = getattr(self.request.principal, 358 358 'user_type', 'system').title() 359 kofa_utils = getUtility(IKofaUtils)360 success = kofa_utils.sendContactForm(359 ikoba_utils = getUtility(IIkobaUtils) 360 success = ikoba_utils.sendContactForm( 361 361 fullname,email, 362 362 self.config.name_admin,self.config.email_admin, … … 392 392 # No need to flash something. 393 393 return 394 kofa_utils = getUtility(IKofaUtils)395 success = kofa_utils.sendContactForm(394 ikoba_utils = getUtility(IIkobaUtils) 395 success = ikoba_utils.sendContactForm( 396 396 data['fullname'],data['email_from'], 397 397 self.config.name_admin,self.config.email_admin, … … 408 408 # 409 409 410 class UniversityPage( KofaDisplayFormPage):410 class UniversityPage(IkobaDisplayFormPage): 411 411 """ The main university page. 412 412 """ … … 419 419 @property 420 420 def frontpage(self): 421 lang = self.request.cookies.get(' kofa.language')421 lang = self.request.cookies.get('ikoba.language') 422 422 html = self.context['configuration'].frontpage_dict.get(lang,'') 423 423 if html =='': 424 portal_language = getUtility(I KofaUtils).PORTAL_LANGUAGE424 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 425 425 html = self.context[ 426 426 'configuration'].frontpage_dict.get(portal_language,'') 427 427 if html =='': 428 return _(u'<h1>Welcome to WAeUP. Kofa</h1>')428 return _(u'<h1>Welcome to WAeUP.Ikoba</h1>') 429 429 else: 430 430 return html 431 431 432 class AdministrationPage( KofaPage):432 class AdministrationPage(IkobaPage): 433 433 """ The administration overview page. 434 434 """ … … 448 448 449 449 name = 'General news feed' 450 description = 'waeup. kofa now supports RSS 2.0 feeds :-)'450 description = 'waeup.ikoba now supports RSS 2.0 feeds :-)' 451 451 language = None 452 452 date = None … … 477 477 # 478 478 479 class UsersContainerPage( KofaPage):479 class UsersContainerPage(IkobaPage): 480 480 """Overview page for all local users. 481 481 """ … … 494 494 self.flash(_('User account ${a} successfully deleted.', 495 495 mapping = {'a': userid})) 496 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')496 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 497 497 self.context.__parent__.logger.info( 498 498 '%s - removed: %s' % (ob_class, userid)) … … 521 521 return site_roles_string 522 522 523 class AddUserFormPage( KofaAddFormPage):523 class AddUserFormPage(IkobaAddFormPage): 524 524 """Add a user account. 525 525 """ … … 555 555 self.flash(_('User account ${a} successfully added.', 556 556 mapping = {'a': name})) 557 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')557 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 558 558 self.context.__parent__.logger.info( 559 559 '%s - added: %s' % (ob_class, name)) … … 564 564 self.redirect(self.url(self.context)) 565 565 566 class UserManageFormPage( KofaEditFormPage):566 class UserManageFormPage(IkobaEditFormPage): 567 567 """Manage a user account. 568 568 """ … … 604 604 fields_string = ' + '.join(changed_fields) 605 605 if fields_string: 606 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')606 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 607 607 self.context.__parent__.logger.info( 608 608 '%s - %s edited: %s' % ( … … 635 635 usertype = getattr(self.request.principal, 636 636 'user_type', 'system').title() 637 kofa_utils = getUtility(IKofaUtils)638 success = kofa_utils.sendContactForm(637 ikoba_utils = getUtility(IIkobaUtils) 638 success = ikoba_utils.sendContactForm( 639 639 self.request.principal.title,email, 640 640 self.context.title,self.context.email, … … 660 660 self.widgets['title'].displayWidth = 30 661 661 662 class MyRolesPage( KofaPage):662 class MyRolesPage(IkobaPage): 663 663 """Display site roles and local roles assigned to officers. 664 664 """ … … 691 691 # 692 692 693 class ConfigurationContainerDisplayFormPage( KofaDisplayFormPage):693 class ConfigurationContainerDisplayFormPage(IkobaDisplayFormPage): 694 694 """View page of the configuration container. 695 695 """ … … 703 703 704 704 705 class ConfigurationContainerManageFormPage( KofaEditFormPage):705 class ConfigurationContainerManageFormPage(IkobaEditFormPage): 706 706 """Manage page of the configuration container. We always use the 707 707 manage page in the UI not the view page, thus we use the index name here. … … 763 763 return 764 764 765 class SessionConfigurationAddFormPage( KofaAddFormPage):765 class SessionConfigurationAddFormPage(IkobaAddFormPage): 766 766 """Add a session configuration object to configuration container. 767 767 """ … … 779 779 try: 780 780 self.context.addSessionConfiguration(sessionconfiguration) 781 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')781 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 782 782 self.context.__parent__.logger.info( 783 783 '%s - added: %s' % ( … … 794 794 return 795 795 796 class SessionConfigurationManageFormPage( KofaEditFormPage):796 class SessionConfigurationManageFormPage(IkobaEditFormPage): 797 797 """Manage session configuration object. 798 798 """ … … 824 824 # 825 825 826 class DatacenterPage( KofaEditFormPage):826 class DatacenterPage(IkobaEditFormPage): 827 827 grok.context(IDataCenter) 828 828 grok.name('index') … … 854 854 self.flash(_('Successfully deleted: ${a}', 855 855 mapping = {'a': ', '.join(deleted)})) 856 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')856 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 857 857 self.context.logger.info( 858 858 '%s - deleted: %s' % (ob_class, ', '.join(deleted))) 859 859 return 860 860 861 class DatacenterFinishedPage( KofaEditFormPage):861 class DatacenterFinishedPage(IkobaEditFormPage): 862 862 grok.context(IDataCenter) 863 863 grok.name('processed') … … 873 873 return super(DatacenterFinishedPage, self).update() 874 874 875 class DatacenterUploadPage( KofaPage):875 class DatacenterUploadPage(IkobaPage): 876 876 grok.context(IDataCenter) 877 877 grok.name('upload') … … 904 904 mail_table += '%s: %s ...\n' % (line[0], data) 905 905 # Collect all recipient addresses 906 kofa_utils = getUtility(IKofaUtils)906 ikoba_utils = getUtility(IIkobaUtils) 907 907 import_managers = get_users_with_role( 908 908 'waeup.ImportManager', grok.getSite()) … … 924 924 _('${a}: ${b} uploaded', 925 925 mapping = {'a':config.acronym, 'b':filename}), 926 'waeup. kofa',927 target_language= kofa_utils.PORTAL_LANGUAGE)926 'waeup.ikoba', 927 target_language=ikoba_utils.PORTAL_LANGUAGE) 928 928 text = _("""File: ${a} 929 929 Importer: ${b} … … 938 938 'd':uploadfile.lines - 1, 939 939 'e':mail_table}) 940 success = kofa_utils.sendContactForm(940 success = ikoba_utils.sendContactForm( 941 941 fullname,email, 942 942 rcpt_name,rcpt_addrs, … … 983 983 target = os.path.join(self.context.storage, normalized_filename) 984 984 filecontent = uploadfile.read() 985 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')985 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 986 986 logger = self.context.logger 987 987 … … 1060 1060 1061 1061 def render(self): 1062 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1062 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1063 1063 self.context.logger.info( 1064 1064 '%s - downloaded: %s' % (ob_class, self.filename)) … … 1083 1083 1084 1084 def render(self): 1085 #ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1085 #ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1086 1086 #self.context.logger.info( 1087 1087 # '%s - skeleton downloaded: %s' % (ob_class, self.filename)) … … 1094 1094 return csv_data 1095 1095 1096 class DatacenterImportStep1( KofaPage):1096 class DatacenterImportStep1(IkobaPage): 1097 1097 """Manual import step 1: choose file 1098 1098 """ … … 1119 1119 if select is not None: 1120 1120 # A filename was selected 1121 session = ISession(self.request)['waeup. kofa']1121 session = ISession(self.request)['waeup.ikoba'] 1122 1122 session['import_filename'] = select 1123 1123 self.redirect(self.url(self.context, '@@import2')) 1124 1124 1125 class DatacenterImportStep2( KofaPage):1125 class DatacenterImportStep2(IkobaPage): 1126 1126 """Manual import step 2: choose processor 1127 1127 """ … … 1191 1191 def update(self, mode=None, importer=None, 1192 1192 back1=None, cancel=None, proceed=None): 1193 session = ISession(self.request)['waeup. kofa']1193 session = ISession(self.request)['waeup.ikoba'] 1194 1194 self.filename = session.get('import_filename', None) 1195 1195 … … 1226 1226 self.flash(warnings, type='warning') 1227 1227 1228 class DatacenterImportStep3( KofaPage):1228 class DatacenterImportStep3(IkobaPage): 1229 1229 """Manual import step 3: modify header 1230 1230 """ … … 1309 1309 1310 1310 def update(self, headerfield=None, back2=None, cancel=None, proceed=None): 1311 session = ISession(self.request)['waeup. kofa']1311 session = ISession(self.request)['waeup.ikoba'] 1312 1312 self.filename = session.get('import_filename', None) 1313 1313 self.mode = session.get('import_mode', None) … … 1338 1338 self.flash(warnings, type='warning') 1339 1339 1340 class DatacenterImportStep4( KofaPage):1340 class DatacenterImportStep4(IkobaPage): 1341 1341 """Manual import step 4: do actual import 1342 1342 """ … … 1359 1359 self.redirect(self.url(self.context, '@@import1')) 1360 1360 return 1361 session = ISession(self.request)['waeup. kofa']1361 session = ISession(self.request)['waeup.ikoba'] 1362 1362 self.filename = session.get('import_filename', None) 1363 1363 self.mode = session.get('import_mode', None) … … 1402 1402 mapping = {'a':linenum - self.warn_num})) 1403 1403 1404 class DatacenterLogsOverview( KofaPage):1404 class DatacenterLogsOverview(IkobaPage): 1405 1405 grok.context(IDataCenter) 1406 1406 grok.name('logs') … … 1418 1418 self.files = self.context.getLogFiles() 1419 1419 1420 class DatacenterLogsFileview( KofaPage):1420 class DatacenterLogsFileview(IkobaPage): 1421 1421 grok.context(IDataCenter) 1422 1422 grok.name('show') … … 1456 1456 return 1457 1457 1458 class DatacenterSettings( KofaPage):1458 class DatacenterSettings(IkobaPage): 1459 1459 grok.context(IDataCenter) 1460 1460 grok.name('manage') … … 1489 1489 if newpath: 1490 1490 self.flash(_('New storage path succefully set.')) 1491 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1491 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1492 1492 self.context.logger.info( 1493 1493 '%s - storage path set: %s' % (ob_class, newpath)) … … 1495 1495 return 1496 1496 1497 class ExportCSVPage( KofaPage):1497 class ExportCSVPage(IkobaPage): 1498 1498 grok.context(IDataCenter) 1499 1499 grok.name('export') … … 1519 1519 job_id = self.context.start_export_job( 1520 1520 exporter, self.request.principal.id) 1521 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1521 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1522 1522 self.context.logger.info( 1523 1523 '%s - exported: %s, job_id=%s' % (ob_class, exporter, job_id)) … … 1525 1525 entry = self.context.entry_from_job_id(job_id) 1526 1526 self.context.delete_export_entry(entry) 1527 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1527 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1528 1528 self.context.logger.info( 1529 1529 '%s - discarded: job_id=%s' % (ob_class, job_id)) … … 1560 1560 #self.context.delete_export_entry( 1561 1561 # self.context.entry_from_job_id(job_id)) 1562 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1562 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1563 1563 self.context.logger.info( 1564 1564 '%s - downloaded: %s, job_id=%s' % (ob_class, filename, job_id)) 1565 1565 return result 1566 1566 1567 class ChangePasswordRequestPage( KofaForm):1567 class ChangePasswordRequestPage(IkobaForm): 1568 1568 """Captcha'd page for all kind of users to request a password change. 1569 1569 """ … … 1613 1613 return 1614 1614 # Change password 1615 kofa_utils = getUtility(IKofaUtils)1616 password = kofa_utils.genPassword()1615 ikoba_utils = getUtility(IIkobaUtils) 1616 password = ikoba_utils.genPassword() 1617 1617 mandate = PasswordMandate() 1618 1618 mandate.params['password'] = password … … 1625 1625 url_info = u'Confirmation link: %s' % mandate_url 1626 1626 msg = _('You have successfully requested a password for the') 1627 success = kofa_utils.sendCredentials(1627 success = ikoba_utils.sendCredentials( 1628 1628 IUserAccount(user),password,url_info,msg) 1629 1629 if success: … … 1632 1632 else: 1633 1633 self.flash(_('An smtp server error occurred.'), type='danger') 1634 ob_class = self.__implemented__.__name__.replace('waeup. kofa.','')1634 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','') 1635 1635 self.context.logger.info( 1636 1636 '%s - %s - %s' % (ob_class, data['identifier'], data['email']))
Note: See TracChangeset for help on using the changeset viewer.