Changeset 12186
- Timestamp:
- 9 Dec 2014, 16:45:52 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/breadcrumbs.py
r11954 r12186 24 24 25 25 from waeup.ikoba.interfaces import ( 26 IConfigurationContainer, I SessionConfiguration, IExportJobContainer)26 IConfigurationContainer, IExportJobContainer) 27 27 from waeup.ikoba.interfaces import MessageFactory as _ 28 28 from waeup.ikoba.browser.interfaces import ( … … 126 126 title = _(u'Portal Configuration') 127 127 parent_viewname = 'administration' 128 129 class SessionConfigurationBreadcrumb(Breadcrumb):130 """A breadcrumb for the configuration container.131 """132 grok.context(ISessionConfiguration)133 title = u'Portal Session Configuration'134 135 @property136 def title(self):137 session_string = self.context.getSessionString()138 return 'Session %s' % session_string139 128 140 129 class UsersContainerBreadcrumb(Breadcrumb): -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py
r11979 r12186 53 53 IIkobaXMLImporter, IIkobaXMLExporter, IBatchProcessor, 54 54 ILocalRolesAssignable, DuplicationError, IConfigurationContainer, 55 ISessionConfiguration, ISessionConfigurationAdd, IJobManager, 56 IPasswordValidator, IContactForm, IIkobaUtils, ICSVExporter, 57 application_sessions_vocab) 55 IJobManager, 56 IPasswordValidator, IContactForm, IIkobaUtils, ICSVExporter) 58 57 from waeup.ikoba.permissions import ( 59 58 get_users_with_local_roles, get_all_roles, get_all_users, … … 743 742 grok.name('index') 744 743 grok.context(IConfigurationContainer) 745 grok.template('configurationmanagepage')746 744 pnav = 0 747 745 label = _(u'Edit portal configuration') 748 taboneactions = [_('Save'), _('Update plugins')]749 tabtwoactions = [750 _('Add session configuration'),751 _('Remove selected')]752 746 form_fields = grok.AutoFields(IConfigurationContainer).omit( 753 747 'frontpage_dict') … … 763 757 msave(self, **data) 764 758 self.context.frontpage_dict = self._frontpage() 765 return766 767 @action(_('Add session configuration'), validator=NullValidator,768 style='primary')769 def addSubunit(self, **data):770 self.redirect(self.url(self.context, '@@add'))771 return772 773 def getSessionConfigurations(self):774 """Get a list of all stored session configuration objects.775 """776 for key, val in self.context.items():777 url = self.url(val)778 session_string = val.getSessionString()779 title = _('Session ${a} Configuration',780 mapping = {'a':session_string})781 yield(dict(url=url, name=key, title=title))782 783 @jsaction(_('Remove selected'))784 def delSessonConfigurations(self, **data):785 delSubobjects(self, redirect='@@index', tab='2')786 759 return 787 760 … … 794 767 grok.getSite().updatePlugins() 795 768 self.flash(_('Plugins were updated. See log file for details.')) 796 return797 798 class SessionConfigurationAddFormPage(IkobaAddFormPage):799 """Add a session configuration object to configuration container.800 """801 grok.context(IConfigurationContainer)802 grok.name('add')803 grok.require('waeup.managePortalConfiguration')804 label = _('Add session configuration')805 form_fields = grok.AutoFields(ISessionConfigurationAdd)806 pnav = 0807 808 @action(_('Add Session Configuration'), style='primary')809 def addSessionConfiguration(self, **data):810 sessionconfiguration = createObject(u'waeup.SessionConfiguration')811 self.applyData(sessionconfiguration, **data)812 try:813 self.context.addSessionConfiguration(sessionconfiguration)814 ob_class = self.__implemented__.__name__.replace('waeup.ikoba.','')815 self.context.__parent__.logger.info(816 '%s - added: %s' % (817 ob_class, sessionconfiguration.application_session))818 except KeyError:819 self.flash(_('The session chosen already exists.'), type='danger')820 return821 self.redirect(self.url(self.context, '@@index')+'#tab2')822 return823 824 @action(_('Cancel'), validator=NullValidator)825 def cancel(self):826 self.redirect(self.url(self.context, '@@index')+'#tab2')827 return828 829 class SessionConfigurationManageFormPage(IkobaEditFormPage):830 """Manage session configuration object.831 """832 grok.context(ISessionConfiguration)833 grok.name('index')834 grok.require('waeup.managePortalConfiguration')835 form_fields = grok.AutoFields(ISessionConfiguration)836 pnav = 0837 838 @property839 def label(self):840 session_string = self.context.getSessionString()841 return _('Edit academic session ${a} configuration',842 mapping = {'a':session_string})843 844 @action(_('Save'), style='primary')845 def save(self, **data):846 msave(self, **data)847 self.redirect(self.url(self.context.__parent__, '@@index')+'#tab2')848 return849 850 @action(_('Cancel'), validator=NullValidator)851 def cancel(self):852 self.redirect(self.url(self.context.__parent__, '@@index')+'#tab2')853 769 return 854 770 -
main/waeup.ikoba/trunk/src/waeup/ikoba/configuration.py
r11949 r12186 22 22 from zope.component.interfaces import IFactory 23 23 from zope.interface import implementedBy 24 from waeup.ikoba.interfaces import ( 25 ISessionConfiguration, IConfigurationContainer, ISessionConfigurationAdd, 26 application_sessions_vocab) 24 from waeup.ikoba.interfaces import IConfigurationContainer 27 25 from waeup.ikoba.utils.helpers import attrs_to_fields 28 26 29 27 class ConfigurationContainer(grok.Container): 30 28 """ 31 The node containing the session configuration models29 The node which may contain further configuration models (see waeup.kofa). 32 30 """ 33 31 34 32 grok.implements(IConfigurationContainer) 35 33 36 def addSessionConfiguration(self, sessionconfiguration):37 """Add a session configuration object.38 """39 if not ISessionConfiguration.providedBy(sessionconfiguration):40 raise TypeError(41 'ConfigurationContainers contain only '42 'ISessionConfiguration instances')43 code = unicode(sessionconfiguration.application_session)44 self[code] = sessionconfiguration45 return46 47 34 ConfigurationContainer = attrs_to_fields(ConfigurationContainer) 48 49 class SessionConfiguration(grok.Model):50 """51 Session configuration model52 """53 54 grok.implements(ISessionConfiguration, ISessionConfigurationAdd)55 56 def getSessionString(self):57 return application_sessions_vocab.getTerm(self.application_session).title58 59 SessionConfiguration = attrs_to_fields(SessionConfiguration)60 61 class SessionConfigurationFactory(grok.GlobalUtility):62 """A factory for session configuration objects.63 """64 grok.implements(IFactory)65 grok.name(u'waeup.SessionConfiguration')66 title = u"Create a new session configuration object.",67 description = u"This factory instantiates new session configurations."68 69 def __call__(self, *args, **kw):70 return SessionConfiguration(*args, **kw)71 72 def getInterfaces(self):73 return implementedBy(SessionConfiguration) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12183 r12186 141 141 142 142 self.app['configuration'].carry_over = True 143 configuration = createObject('waeup.SessionConfiguration')144 self.app['configuration'].addSessionConfiguration(configuration)145 143 146 144 # Update the catalog -
main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py
r12089 r12186 85 85 SimpleTerm(value, value, title) for title, value in terms]) 86 86 87 def application_sessions():88 curr_year = datetime.now().year89 year_range = range(1995, curr_year + 2)90 return [('%s/%s' % (year,year+1), year) for year in year_range]91 92 application_sessions_vocab = SimpleIkobaVocabulary(*application_sessions())93 87 94 88 class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory): … … 633 627 634 628 635 class ISessionConfiguration(IIkobaObject):636 """A session configuration object.637 """638 639 application_session = schema.Choice(640 title = _(u'Period'),641 source = application_sessions_vocab,642 default = None,643 required = True,644 readonly = True,645 )646 647 648 def getSessionString():649 """Returns the session string from the vocabulary.650 """651 652 653 class ISessionConfigurationAdd(ISessionConfiguration):654 """A session configuration object in add mode.655 """656 657 application_session = schema.Choice(658 title = _(u'Academic Session'),659 source = application_sessions_vocab,660 default = None,661 required = True,662 readonly = False,663 )664 665 ISessionConfigurationAdd['application_session'].order = ISessionConfiguration[666 'application_session'].order667 668 629 class IDataCenter(IIkobaObject): 669 630 """A data center. -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/catalog.py
r11954 r12186 30 30 31 31 p_id = grok.index.Field(attribute='p_id') 32 p_session = grok.index.Field(attribute='p_session')33 32 p_category = grok.index.Field(attribute='p_category') 34 33 p_item = grok.index.Field(attribute='p_item') -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/interfaces.py
r11949 r12186 19 19 from zope import schema 20 20 from waeup.ikoba.interfaces import ( 21 IIkobaObject, SimpleIkobaVocabulary, application_sessions_vocab,21 IIkobaObject, SimpleIkobaVocabulary, 22 22 ContextualDictSourceFactoryBase) 23 23 from waeup.ikoba.interfaces import MessageFactory as _ … … 64 64 required = False, 65 65 readonly = True, 66 )67 68 p_session = schema.Choice(69 title = _(u'Payment Session'),70 source = application_sessions_vocab,71 required = True,72 66 ) 73 67 -
main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_browser.py
r12077 r12186 97 97 # Add session configuration 98 98 self.app['configuration'].carry_over = True 99 configuration = createObject('waeup.SessionConfiguration')100 101 self.app['configuration'].addSessionConfiguration(configuration)102 99 self.login_path = 'http://localhost/app/login' 103 100 self.container_path = 'http://localhost/app/products' -
main/waeup.ikoba/trunk/src/waeup/ikoba/tests/test_configuration.py
r11949 r12186 21 21 from zope.interface import verify 22 22 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 23 from waeup.ikoba.configuration import ( 24 ConfigurationContainer, SessionConfiguration, SessionConfigurationFactory) 25 from waeup.ikoba.interfaces import( 26 IConfigurationContainer, ISessionConfiguration, ISessionConfigurationAdd) 23 from waeup.ikoba.configuration import ConfigurationContainer 24 from waeup.ikoba.interfaces import IConfigurationContainer 27 25 28 26 class ConfigurationTest(FunctionalTestCase): … … 33 31 super(ConfigurationTest, self).setUp() 34 32 self.confcontainer = ConfigurationContainer() 35 self.sessionconf = SessionConfiguration()36 33 return 37 34 … … 43 40 verify.verifyClass(IConfigurationContainer, ConfigurationContainer) 44 41 verify.verifyObject(IConfigurationContainer, self.confcontainer) 45 verify.verifyClass(ISessionConfiguration, SessionConfiguration)46 verify.verifyObject(ISessionConfiguration, self.sessionconf)47 verify.verifyClass(ISessionConfigurationAdd, SessionConfiguration)48 verify.verifyObject(ISessionConfigurationAdd, self.sessionconf)49 50 class SessionConfigurationFactoryTest(FunctionalTestCase):51 52 layer = FunctionalLayer53 54 def setUp(self):55 super(SessionConfigurationFactoryTest, self).setUp()56 self.factory = SessionConfigurationFactory()57 58 def tearDown(self):59 super(SessionConfigurationFactoryTest, self).tearDown()60 61 def test_interfaces(self):62 verify.verifyClass(IFactory, SessionConfigurationFactory)63 verify.verifyObject(IFactory, self.factory)64 65 def test_factory(self):66 obj = self.factory()67 assert isinstance(obj, SessionConfiguration)68 69 def test_getInterfaces(self):70 implemented_by = self.factory.getInterfaces()71 assert implemented_by.isOrExtends(ISessionConfiguration)
Note: See TracChangeset for help on using the changeset viewer.