Changeset 8388 for main/waeup.kofa/trunk
- Timestamp:
- 9 May 2012, 08:39:01 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r8365 r8388 61 61 grok.context(IKofaObject) # Make IKofaObject the default context 62 62 63 class ApplicantsRootPage(Kofa Page):63 class ApplicantsRootPage(KofaDisplayFormPage): 64 64 grok.context(IApplicantsRoot) 65 65 grok.name('index') 66 66 grok.require('waeup.Public') 67 form_fields = grok.AutoFields(IApplicantsRoot) 68 form_fields['description'].custom_widget = HTMLDisplayWidget 67 69 label = _('Application Section') 68 70 pnav = 3 … … 70 72 def update(self): 71 73 super(ApplicantsRootPage, self).update() 72 #datatable.need() 73 return 74 return 75 76 @property 77 def introduction(self): 78 # Here we know that the cookie has been set 79 lang = self.request.cookies.get('kofa.language') 80 html = self.context.description_dict.get(lang,'') 81 if html == '': 82 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 83 html = self.context.description_dict.get(portal_language,'') 84 return html 74 85 75 86 class ApplicantsRootManageFormPage(KofaEditFormPage): … … 77 88 grok.name('manage') 78 89 grok.template('applicantsrootmanagepage') 90 form_fields = grok.AutoFields(IApplicantsRoot) 79 91 label = _('Manage application section') 80 92 pnav = 3 81 93 grok.require('waeup.manageApplication') 82 taboneactions = [_(' Add applicants container'), _('Remove selected'),83 _('Cancel')]84 tabt woactions1 = [_('Remove selected local roles')]85 tabt woactions2 = [_('Add local role')]94 taboneactions = [_('Save')] 95 tabtwoactions = [_('Add applicants container'), _('Remove selected')] 96 tabthreeactions1 = [_('Remove selected local roles')] 97 tabthreeactions2 = [_('Add local role')] 86 98 subunits = _('Applicants Containers') 87 99 … … 90 102 datatable.need() 91 103 warning.need() 104 self.tab1 = self.tab2 = self.tab3 = '' 105 qs = self.request.get('QUERY_STRING', '') 106 if not qs: 107 qs = 'tab1' 108 setattr(self, qs, 'active') 92 109 return super(ApplicantsRootManageFormPage, self).update() 93 110 … … 109 126 def delApplicantsContainers(self, **data): 110 127 form = self.request.form 111 child_id = form['val_id'] 128 if form.has_key('val_id'): 129 child_id = form['val_id'] 130 else: 131 self.flash(_('No container selected!')) 132 self.redirect(self.url(self.context, '@@manage')+'?tab2') 133 return 112 134 if not isinstance(child_id, list): 113 135 child_id = [child_id] … … 123 145 self.flash(_('Successfully removed: ${a}', 124 146 mapping = {'a':', '.join(deleted)})) 125 self.redirect(self.url(self.context, '@@manage') )147 self.redirect(self.url(self.context, '@@manage')+'?tab2') 126 148 return 127 149 … … 131 153 return 132 154 133 @action(_('Cancel'), validator=NullValidator)134 def cancel(self, **data):135 self.redirect(self.url(self.context))136 return137 138 155 @action(_('Add local role'), validator=NullValidator) 139 156 def addLocalRole(self, **data): … … 143 160 def delLocalRoles(self, **data): 144 161 return del_local_roles(self,3,**data) 162 163 def _description(self): 164 view = ApplicantsRootPage( 165 self.context,self.request) 166 view.setUpWidgets() 167 return view.widgets['description']() 168 169 @action(_('Save'), style='primary') 170 def save(self, **data): 171 self.applyData(self.context, **data) 172 self.context.description_dict = self._description() 173 self.flash(_('Form has been saved.')+'?tab1') 174 return 145 175 146 176 class ApplicantsContainerAddFormPage(KofaAddFormPage): … … 236 266 lang = self.request.cookies.get('kofa.language') 237 267 html = self.context.description_dict.get(lang,'') 238 if html == '':268 if html == '': 239 269 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 240 270 html = self.context.description_dict.get(portal_language,'') 241 if html =='': 242 return '' 243 else: 244 return html 271 return html 245 272 246 273 @property -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantsrootmanagepage.pt
r7811 r8388 2 2 i18n:domain="waeup.kofa" method="POST" enctype="multipart/form-data"> 3 3 <ul class="tabs" data-tabs="tabs"> 4 <li class="active">4 <li tal:attributes="class view/tab1"> 5 5 <a href="#tab-1"> 6 <span i18n:translate="">Introduction 7 </span></a> 8 </li> 9 <li tal:attributes="class view/tab2"> 10 <a href="#tab-2"> 6 11 <span tal:content="view/subunits">Contents 7 12 </span></a> 8 13 </li> 9 <li >10 <a href="#tab- 2">14 <li tal:attributes="class view/tab3"> 15 <a href="#tab-3"> 11 16 <span i18n:translate="">Local Roles 12 17 </span></a> … … 14 19 </ul> 15 20 <div class="tab-content"> 16 <div id="tab-1" class="active"> 21 <div id="tab-1" tal:attributes="class view/tab1"> 22 <table class="form-table"> 23 <tbody> 24 <tal:widgets content="structure provider:widgets" /> 25 </tbody> 26 </table> 27 28 <div tal:condition="view/availableActions"> 29 <span tal:repeat="action view/actions" tal:omit-tag=""> 30 <input tal:condition="python:action.label in view.taboneactions" 31 tal:replace="structure action/render"/> 32 </span> 33 </div> 34 </div> 35 <div id="tab-2" tal:attributes="class view/tab2"> 17 36 <h3 tal:content="view/subunits">SUBUNITS</h3> 18 37 <table class="display dataTableManage"> … … 43 62 <div tal:condition="view/availableActions"> 44 63 <span tal:repeat="action view/actions" tal:omit-tag=""> 45 <input tal:condition="python:action.label in view.tab oneactions"64 <input tal:condition="python:action.label in view.tabtwoactions" 46 65 tal:replace="structure action/render"/> 47 66 </span> 48 67 </div> 49 68 </div> 50 <div id="tab-2"> <br /> 69 <div id="tab-3" tal:attributes="class view/tab3"> 70 <br /> 51 71 <table class="display dataTableManage"> 52 72 <thead> … … 74 94 <div tal:condition="view/availableActions"> 75 95 <span tal:repeat="action view/actions" tal:omit-tag=""> 76 <input tal:condition="python:action.label in view.tabt woactions1"96 <input tal:condition="python:action.label in view.tabthreeactions1" 77 97 tal:replace="structure action/render"/> 78 98 </span> … … 96 116 <div tal:condition="view/availableActions"> 97 117 <span tal:repeat="action view/actions" tal:omit-tag=""> 98 <input tal:condition="python:action.label in view.tabt woactions2"118 <input tal:condition="python:action.label in view.tabthreeactions2" 99 119 tal:replace="structure action/render"/> 100 120 </span> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantsrootpage.pt
r7811 r8388 1 <span tal:condition="view/introduction" tal:omit-tag=""> 2 <span tal:content="structure view/introduction">INTRODUCTION</span> 3 <br /> 4 </span> 5 1 6 <table i18n:domain="waeup.kofa"> 2 7 <thead> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r8365 r8388 149 149 """A container for university applicants containers. 150 150 """ 151 pass 151 152 description = schema.Text( 153 title = _(u'Human readable description in HTML format'), 154 required = False, 155 default = u'''This text can been seen by anonymous users. 156 Here we put multi-lingual general information about the application procedure. 157 >>de<< 158 Dieser Text kann von anonymen Benutzern gelesen werden. 159 Hier koennen mehrsprachige Informationen fuer Antragsteller hinterlegt werden.''' 160 ) 161 162 description_dict = Attribute( 163 """Content as language dictionary with values in HTML format.""") 152 164 153 165 class IApplicantsContainer(IKofaObject): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/root.py
r7819 r8388 23 23 from hurry.query.interfaces import IQuery 24 24 from zope.component import getUtility 25 from zope.schema import getFields 25 26 from waeup.kofa.interfaces import IKofaPluggable 26 27 from waeup.kofa.applicants.interfaces import IApplicantsRoot 27 28 from waeup.kofa.utils.logger import Logger 29 from waeup.kofa.utils.helpers import attrs_to_fields 28 30 29 31 class ApplicantsRoot(grok.Container, Logger): … … 34 36 35 37 local_roles = [] 38 39 #: A dictionary to hold per language translations of description string. 40 description_dict = {} 36 41 37 42 logger_name = 'waeup.kofa.${sitename}.applicants' … … 44 49 target, ob_class, comment)) 45 50 return 51 52 ApplicantsRoot = attrs_to_fields(ApplicantsRoot) 46 53 47 54 class ApplicantsPlugin(grok.GlobalUtility): … … 78 85 site_name = getattr(site, '__name__', '<Unnamed Site>') 79 86 if IApplicantsRoot.providedBy(app_folder): 80 # Applicants up to date. Return. 81 logger.info( 82 '%s: Updating site at %s: Nothing to do.' % ( 83 self.log_prefix, site_name,) 84 ) 87 items = getFields(IApplicantsRoot).items() 88 nothing_to_do = True 89 for i in items: 90 if not hasattr(app_folder,i[0]): 91 nothing_to_do = False 92 setattr(app_folder,i[0],i[1].missing_value) 93 logger.info( 94 '%s: %s added to root.' % (self.log_prefix,i[0])) 95 # can be removed after upgrading uniben 96 if not hasattr(app_folder, 'description_dict'): 97 nothing_to_do = False 98 setattr(app_folder,'description_dict',{}) 99 logger.info( 100 '%s: description_dict added to root.' % self.log_prefix) 101 if nothing_to_do: 102 logger.info( 103 '%s: Updating site at %s: Nothing to do.' % ( 104 self.log_prefix, site_name,) 105 ) 85 106 return 86 107 elif app_folder is not None: -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r8346 r8388 237 237 # Managers can add and delete applicants containers 238 238 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 239 self.browser.open(self.manage_root_path)240 self.browser.getControl("Cancel").click()241 self.assertEqual(self.browser.url, self.root_path)242 239 self.browser.open(self.manage_root_path) 243 240 self.browser.getControl("Add applicants container").click()
Note: See TracChangeset for help on using the changeset viewer.