def _update_stored_categories(self, data): context = aq_inner(self.context) start = time.time() idx = int(self.getFieldname()) new_value = data['content-editable-form-body'] stored = self.stored_data() records = stored['items'] record = records[idx] record['description'] = safe_unicode(new_value) records[idx] = record stored['items'] = records # store in registry here end = time.time() stored.update(dict( _runtime=str(end-start), timestamp=str(int(time.time())), updated=str(datetime.datetime.now()) )) api.portal.set_registry_record( 'meetshaus.blog.interfaces.IBlogToolSettings.blog_categories', safe_unicode(json.dumps(stored))) next_url = '{0}/@@manage-blog-categories'.format( context.absolute_url()) api.portal.show_message(_(u"The item has successfully been updated"), self.request, type='info') return self.request.response.redirect(next_url)
def update(self): context = aq_inner(self.context) self.errors = {} unwanted = ('_authenticator', 'form.button.Submit') required = ('field-name') if 'form.button.Submit' in self.request: authenticator = getMultiAdapter((context, self.request), name=u"authenticator") if not authenticator.verify(): raise Unauthorized form = self.request.form form_data = {} form_errors = {} errorIdx = 0 for value in form: if value not in unwanted: form_data[value] = safe_unicode(form[value]) if not form[value] and value in required: error = {} error['active'] = True error['msg'] = _(u"This field is required") form_errors[value] = error errorIdx += 1 else: error = {} error['active'] = False error['msg'] = form[value] form_errors[value] = error if errorIdx > 0: self.errors = form_errors else: self._update_stored_categories(form)
def render(self): context = aq_inner(self.context) next_url = context.absolute_url() created_idx = self._create_posts() msg = _(u"{0} new postings created".format(created_idx)) api.portal.show_message(message=msg, request=self.request) return self.request.response.redirect(next_url)
def title(self): """This property is used to give the title of the portlet in the "manage portlets" screen. """ return _("Categories")
def title(self): """This property is used to give the title of the portlet in the "manage portlets" screen. """ return _("Blog Monthly archive")
from zope.interface import implements from plone.portlets.interfaces import IPortletDataProvider from plone.app.portlets.portlets import base from Products.CMFCore.utils import getToolByName from zope import schema from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from meetshaus.blog.utils import find_portlet_assignment_context from meetshaus.blog.blogentry import IBlogEntry from meetshaus.blog import MessageFactory as _ MONTHVOCAB = { 'month_1': _(u'month_1'), 'month_2': _(u'month_2'), 'month_3': _(u'month_3'), 'month_4': _(u'month_4'), 'month_5': _(u'month_5'), 'month_6': _(u'month_6'), 'month_7': _(u'month_7'), 'month_8': _(u'month_8'), 'month_9': _(u'month_9'), 'month_10': _(u'month_10'), 'month_11': _(u'month_11'), 'month_12': _(u'month_12'), } class IArchivePortlet(IPortletDataProvider):