Changeset 12229 for main/waeup.ikoba/trunk/src
- Timestamp:
- 14 Dec 2014, 15:45:55 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/layout.py
r11958 r12229 201 201 if 'address' in widget.name or \ 202 202 'comment' in widget.name or \ 203 'description' in widget.name or \ 203 204 'notice' in widget.name: 204 widget.height = 6 205 if self.widgets.get('transcript_comment'): 206 self.widgets['transcript_comment'].height = 12 207 if self.widgets.get('jamb_subjects'): 208 self.widgets['jamb_subjects'].height = 6 205 widget.height = 3 209 206 210 207 class IkobaAddFormPage(UtilityView,AddForm): -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py
r12192 r12229 42 42 from zope.session.interfaces import ISession 43 43 from zope.password.interfaces import IPasswordManager 44 from waeup.ikoba.utils.helpers import html2dict 44 45 from waeup.ikoba.browser.layout import ( 45 46 IkobaPage, IkobaForm, IkobaEditFormPage, IkobaAddFormPage, … … 60 61 61 62 from waeup.ikoba.authentication import LocalRoleSetEvent 62 from waeup.ikoba.widgets.htmlwidget import HTMLDisplayWidget63 63 from waeup.ikoba.utils.helpers import get_user_account, check_csv_charset 64 64 from waeup.ikoba.mandates.mandate import PasswordMandate … … 723 723 # 724 724 725 class ConfigurationContainerDisplayFormPage(IkobaDisplayFormPage):726 """View page of the configuration container.727 """728 grok.require('waeup.managePortalConfiguration')729 grok.name('view')730 grok.context(IConfigurationContainer)731 pnav = 0732 label = _(u'View portal configuration')733 form_fields = grok.AutoFields(IConfigurationContainer)734 form_fields['frontpage'].custom_widget = HTMLDisplayWidget735 736 737 725 class ConfigurationContainerManageFormPage(IkobaEditFormPage): 738 726 """Manage page of the configuration container. We always use the … … 747 735 'frontpage_dict') 748 736 749 def _frontpage(self):750 view = ConfigurationContainerDisplayFormPage(751 self.context,self.request)752 view.setUpWidgets()753 return view.widgets['frontpage']()754 755 737 @action(_('Save'), style='primary') 756 738 def save(self, **data): 757 739 msave(self, **data) 758 self.context.frontpage_dict = self._frontpage() 740 frontpage = getattr(self.context, 'frontpage', None) 741 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 742 self.context.frontpage_dict = html2dict(frontpage, portal_language) 759 743 return 760 744 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser.py
r12228 r12229 32 32 from zope.schema.interfaces import ConstraintNotSatisfied, RequiredMissing 33 33 from zope.formlib.textwidgets import BytesDisplayWidget 34 from zope.formlib.widget import renderElement35 34 from zope.security import checkPermission 35 from waeup.ikoba.utils.helpers import html2dict 36 36 from waeup.ikoba.interfaces import MessageFactory as _ 37 37 from waeup.ikoba.interfaces import ( … … 233 233 grok.context(IHTMLDocument) 234 234 235 def _html_dict(self):236 value = getattr(self.context, 'html_multilang', None)237 if not value:238 return {}239 parts = value.split('>>')240 elements = {}241 lang = getUtility(IIkobaUtils).PORTAL_LANGUAGE242 for part in parts:243 if part[2:4] == u'<<':244 lang = part[0:2].lower()245 text = part[4:]246 elements[lang] = renderElement(u'div id="html"',247 contents=text)248 else:249 text = part250 elements[lang] = renderElement(u'div id="html"',251 contents=text)252 return elements253 254 235 @action(_('Save'), style='primary') 255 236 def save(self, **data): 256 237 msave(self, **data) 257 self.context.html_dict = self._html_dict() 238 html_multilang = getattr(self.context, 'html_multilang', None) 239 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 240 self.context.html_dict = html2dict(html_multilang, portal_language) 258 241 return 259 242 -
main/waeup.ikoba/trunk/src/waeup/ikoba/utils/helpers.py
r11949 r12229 39 39 from zope.security.management import getInteraction 40 40 from zope.pluggableauth.interfaces import IAuthenticatorPlugin 41 from zope.formlib.widget import renderElement 41 42 42 43 BUFSIZE = 8 * 1024 … … 804 805 result[key] = value 805 806 return result 807 808 809 def html2dict(value=None,portal_language='en'): 810 """Transforms a localized HTML text string into a dictionary. 811 812 Different languages must be separated by `>>xy<<` whereas 813 xy is the language code. Text parts without correct leading 814 language separator - usually the first part has no language 815 descriptor - are interpreted as texts in the portal's language. 816 The latter can be configured in waeup.srp.utils.utils.IkobaUtils. 817 """ 818 try: 819 parts = value.split('>>') 820 except: 821 return {} 822 elements = {} 823 lang = portal_language 824 for part in parts: 825 if part[2:4] == u'<<': 826 lang = part[0:2].lower() 827 text = part[4:] 828 elements[lang] = renderElement(u'div id="html"', 829 contents=text) 830 else: 831 text = part 832 elements[lang] = renderElement(u'div id="html"', 833 contents=text) 834 return elements
Note: See TracChangeset for help on using the changeset viewer.