Changeset 12227
- Timestamp:
- 14 Dec 2014, 14:59:41 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/documents
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser.py
r12225 r12227 32 32 from zope.schema.interfaces import ConstraintNotSatisfied, RequiredMissing 33 33 from zope.formlib.textwidgets import BytesDisplayWidget 34 from zope.formlib.widget import renderElement 34 35 from zope.security import checkPermission 35 36 from waeup.ikoba.interfaces import MessageFactory as _ … … 48 49 49 50 from waeup.ikoba.documents.interfaces import ( 50 IDocumentsContainer, IPublicDocument, I DocumentsUtils)51 IDocumentsContainer, IPublicDocument, IHTMLDocument, IDocumentsUtils) 51 52 52 53 grok.context(IIkobaObject) # Make IKofaObject the default context … … 165 166 166 167 168 class HTMLDocumentDisplayFormPage(DocumentDisplayFormPage): 169 """ Page to display html document data 170 """ 171 grok.context(IHTMLDocument) 172 grok.template('htmldocumentpage') 173 174 @property 175 def form_fields(self): 176 return grok.AutoFields(self.context.form_fields_interface).omit( 177 'html_dict', 'html_multilang') 178 179 @property 180 def html(self): 181 lang = self.request.cookies.get('ikoba.language') 182 html = self.context.html_dict.get(lang,'') 183 if html =='': 184 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 185 html = self.context.html_dict.get(portal_language,'') 186 return html 187 188 167 189 class DocumentManageFormPage(IkobaEditFormPage, 168 190 LocalRoleAssignmentUtilityView): … … 176 198 177 199 taboneactions = [_('Save'),_('Cancel')] 178 tabt woactions1 = [_('Remove selected local roles')]179 tabt woactions2 = [_('Add local role')]200 tabthreeactions1 = [_('Remove selected local roles')] 201 tabthreeactions2 = [_('Add local role')] 180 202 181 203 deletion_warning = _('Are you sure?') … … 204 226 def delLocalRoles(self, **data): 205 227 return del_local_roles(self,2,**data) 228 229 230 class HTMLDocumentManageFormPage(DocumentManageFormPage): 231 """ View to manage htmldocument data 232 """ 233 grok.context(IHTMLDocument) 234 235 def _html_dict(self): 236 value = getattr(self.context, 'html_multilang', '') 237 parts = value.split('>>') 238 elements = {} 239 lang = getUtility(IIkobaUtils).PORTAL_LANGUAGE 240 for part in parts: 241 if part[2:4] == u'<<': 242 lang = part[0:2].lower() 243 text = part[4:] 244 elements[lang] = renderElement(u'div id="html"', 245 contents=text) 246 else: 247 text = part 248 elements[lang] = renderElement(u'div id="html"', 249 contents=text) 250 return elements 251 252 @action(_('Save'), style='primary') 253 def save(self, **data): 254 msave(self, **data) 255 self.context.html_dict = self._html_dict() 256 return 206 257 207 258 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser_templates/documentmanagepage.pt
r12225 r12227 4 4 <ul class="tabs nav nav-tabs" data-tabs="tabs"> 5 5 <li class="active"> 6 <a href="#tab1" data-toggle="tab" i18n:translate=""> Settings</a>6 <a href="#tab1" data-toggle="tab" i18n:translate="">Metadata</a> 7 7 </li> 8 8 <li> … … 64 64 <div tal:condition="view/availableActions"> 65 65 <span tal:repeat="action view/actions" tal:omit-tag=""> 66 <input tal:condition="python:action.label in view.tabt woactions1"66 <input tal:condition="python:action.label in view.tabthreeactions1" 67 67 tal:replace="structure action/render"/> 68 68 </span> … … 91 91 <div tal:condition="view/availableActions"> 92 92 <span tal:repeat="action view/actions" tal:omit-tag=""> 93 <input tal:condition="python:action.label in view.tabt woactions2"93 <input tal:condition="python:action.label in view.tabthreeactions2" 94 94 tal:replace="structure action/render"/> 95 95 </span> -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py
r12225 r12227 153 153 form_fields_interface = IHTMLDocument 154 154 155 def __init__(self, *args, **kw): 156 super(HTMLDocument, self).__init__(*args, **kw) 157 self.html_dict = None 158 155 159 HTMLDocument = attrs_to_fields(HTMLDocument) 156 160 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py
r12225 r12227 70 70 """ 71 71 72 description = schema.Text( 73 title = _(u'Description'), 74 required = False, 75 ) 72 76 73 77 … … 83 87 """ 84 88 89 html_dict = Attribute('Content as language dictionary with values in html format') 90 91 html_multilang = schema.Text( 92 title = _(u'Content in HTML format'), 93 required = False, 94 ) 95 85 96 86 97 class IDocumentsUtils(Interface):
Note: See TracChangeset for help on using the changeset viewer.