Changeset 7908 for main/waeup.kofa/trunk/src
- Timestamp:
- 18 Mar 2012, 14:27:15 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r7868 r7908 30 30 IAuthentication, IUnauthenticatedPrincipal, ILogout) 31 31 from zope.catalog.interfaces import ICatalog 32 from zope.component import ( 33 getUtility, queryUtility, createObject, getAllUtilitiesRegisteredFor, 34 getUtilitiesFor, 35 ) 36 #from zope.component.interfaces import Invalid 37 from zope.event import notify 32 38 from zope.securitypolicy.interfaces import ( 33 39 IPrincipalRoleManager, IPrincipalRoleMap) 34 from zope.component import (35 getUtility, queryUtility, createObject, getAllUtilitiesRegisteredFor)36 #from zope.component.interfaces import Invalid37 from zope.event import notify38 40 from zope.session.interfaces import ISession 39 41 from waeup.kofa.browser import ( … … 44 46 IDepartment, IDepartmentAdd, ICourse, ICourseAdd, ICertificate, 45 47 ICertificateAdd, ICertificateCourse, ICertificateCourseAdd) 48 from waeup.kofa.browser.layout import jsaction, action, UtilityView 49 from waeup.kofa.browser.resources import warning, datepicker, tabs, datatable 46 50 from waeup.kofa.interfaces import MessageFactory as _ 47 from waeup.kofa.browser.resources import warning, datepicker, tabs, datatable48 51 from waeup.kofa.interfaces import( 49 52 IKofaObject, IUsersContainer, IUserAccount, IDataCenter, … … 51 54 ILocalRolesAssignable, DuplicationError, IConfigurationContainer, 52 55 ISessionConfiguration, ISessionConfigurationAdd, 53 IPasswordValidator, IContactForm, IKofaUtils )56 IPasswordValidator, IContactForm, IKofaUtils, ICSVExporter) 54 57 from waeup.kofa.permissions import get_users_with_local_roles, get_all_roles 55 58 from waeup.kofa.students.catalog import search as searchstudents … … 61 64 from waeup.kofa.authentication import get_principal_role_manager 62 65 from waeup.kofa.utils.helpers import get_user_account 63 from waeup.kofa.browser.layout import jsaction, action, UtilityView64 66 65 67 grok.context(IKofaObject) … … 1210 1212 return 1211 1213 1214 class ExportCSVPage(KofaPage): 1215 grok.context(IDataCenter) 1216 grok.name('export') 1217 grok.template('datacenterexportpage') 1218 grok.require('waeup.manageUniversity') 1219 label = _('Download portal data as CSV file.') 1220 pnav = 0 1221 export_button = _(u'Download') 1222 1223 def getExporters(self): 1224 utils = getUtilitiesFor(ICSVExporter) 1225 title_name_tuples = [ 1226 (util.title, name) for name, util in utils] 1227 return sorted(title_name_tuples) 1228 1229 def update(self, export=None, exporter=None): 1230 if None in (export, exporter): 1231 return 1232 self.redirect( 1233 self.url(self.context, 'export.csv') + '?exporter=%s' % exporter) 1234 return 1235 exporter = getUtility(ICSVExporter, name=exporter) 1236 csv_data = exporter.export_all(grok.getSite()) 1237 #csv_data.seek(0) 1238 self.response.setHeader( 1239 'Content-Type', 'text/csv; charset=UTF-8') 1240 return csv_data 1241 1242 class ExportCSVView(grok.View): 1243 grok.context(IDataCenter) 1244 grok.name('export.csv') 1245 grok.require('waeup.manageUniversity') 1246 1247 def render(self, exporter=None): 1248 if exporter is None: 1249 return 1250 exporter = getUtility(ICSVExporter, name=exporter) 1251 csv_data = exporter.export_all(grok.getSite()) 1252 #csv_data.seek(0) 1253 self.response.setHeader( 1254 'Content-Type', 'text/csv; charset=UTF-8') 1255 return csv_data 1256 1212 1257 class ExportXMLPage(grok.View): 1213 1258 """Deliver an XML representation of the context. -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r7819 r7908 557 557 text = _('Upload CSV file') 558 558 559 class ExportCSVButton(ActionButton): 560 grok.context(IDataCenter) 561 grok.view(DatacenterPage) 562 grok.require('waeup.manageUniversity') 563 grok.order(7) 564 icon = 'go-down-16x16.png' 565 target = '@@export' 566 text = _('Export CSV file') 567 559 568 # 560 569 # Primary navigation tabs (in upper left navigation bar)...
Note: See TracChangeset for help on using the changeset viewer.