Changeset 9311 for main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
- Timestamp:
- 7 Oct 2012, 21:52:45 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r9303 r9311 25 25 from urllib import urlencode 26 26 from zope import schema 27 from zope.i18n import translate 27 28 from zope.authentication.interfaces import ( 28 29 IAuthentication, IUnauthenticatedPrincipal, ILogout) … … 56 57 IPasswordValidator, IContactForm, IKofaUtils, ICSVExporter,) 57 58 from waeup.kofa.permissions import ( 58 get_users_with_local_roles, get_all_roles, get_all_users) 59 get_users_with_local_roles, get_all_roles, get_all_users, 60 get_users_with_role) 59 61 60 62 from waeup.kofa.students.catalog import search as searchstudents … … 836 838 cancel_button =_(u'Cancel') 837 839 840 def _notifyImportManagers(self, normalized_filename): 841 """Send email to Import Managers 842 """ 843 kofa_utils = getUtility(IKofaUtils) 844 import_managers = get_users_with_role( 845 'waeup.ImportManager', grok.getSite()) 846 rcpt_addrs = ','.join( 847 [user['user_email'] for user in import_managers if 848 user['user_email'] is not None]) 849 if rcpt_addrs: 850 config = grok.getSite()['configuration'] 851 fullname = self.request.principal.title 852 try: 853 email = self.request.principal.email 854 except AttributeError: 855 email = config.email_admin 856 username = self.request.principal.id 857 usertype = getattr(self.request.principal, 858 'user_type', 'system').title() 859 rcpt_name = _('Import Manager') 860 subject = translate( 861 _('${a} Upload', mapping = {'a':config.acronym}), 862 'waeup.kofa', 863 target_language=kofa_utils.PORTAL_LANGUAGE) 864 text = _('File ${a} uploaded.', mapping = {'a':normalized_filename}) 865 success = kofa_utils.sendContactForm( 866 fullname,email, 867 rcpt_name,rcpt_addrs, 868 username,usertype,config.name, 869 text,subject) 870 if success: 871 self.flash( 872 _('All import managers have been notified by email.')) 873 else: 874 self.flash(_('An smtp server error occurred.')) 875 return 876 838 877 def update(self, uploadfile=None, CANCEL=None, SUBMIT=None): 839 878 if CANCEL is not None: … … 864 903 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 865 904 logger.info('%s - uploaded: %s' % (ob_class, target)) 905 self._notifyImportManagers(normalized_filename) 906 866 907 except IOError: 867 908 self.flash('Error while uploading file. Please retry.')
Note: See TracChangeset for help on using the changeset viewer.