class AddForm(form.AddForm):
    implements(IBlogEntryCollectionPortlet)

    label = _(u'label_add_blogentry_collection_portlet',
              default=u'Add BlogEntry collection portlet')

    fields = field.Fields(IBlogEntryCollectionPortlet)

    def __init__(self, context, request):
        super(AddForm, self).__init__(context, request)
        self.status = None
        self._finishedAdd = None

    def __call__(self):
        IPortletPermissionChecker(aq_parent(aq_inner(self.context)))()
        return super(AddForm, self).__call__()

    def nextURL(self):
        editview = aq_parent(aq_inner(self.context))
        context = aq_parent(aq_inner(editview))
        url = str(
            getMultiAdapter((context, self.request), name=u"absolute_url"))
        return url + '/@@manage-portlets'

    @button.buttonAndHandler(_(u"label_save", default=u"Save"), name='add')
    def handleAdd(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        obj = self.createAndAdd(data)
        if obj is not None:
            # mark only as finished if we get the new object
            self._finishedAdd = True

    @button.buttonAndHandler(_(u"label_cancel", default=u"Cancel"),
                             name='cancel_add')
    def handleCancel(self, action):
        nextURL = self.nextURL()
        return self.request.response.redirect(nextURL)

    def add(self, object_):
        ob = self.context.add(object_)
        self._finishedAdd = True
        return ob

    def updateWidgets(self):
        self.fields['path'].widgetFactory = MultiContentTreeFieldWidget
        super(AddForm, self).updateWidgets()

    def create(self, data):
        return Assignment(portlet_title=data.get('portlet_title',
                                                 'BlogEntries'),
                          show_image=data.get('show_image', True),
                          path=data.get('path', []),
                          quantity=data.get('quantity', 5),
                          show_desc=data.get('show_desc', True))
Example #2
0
    def get_render_arguments(self):
        args = super(BlogLayout, self).get_render_arguments()

        args['_'] = lambda *a, **kw: translate(_(*a, **kw),
                                               context=self.request)

        return args
Example #3
0
    def get_render_arguments(self):
        args = super(BlogLayout, self).get_render_arguments()

        args['_'] = lambda *a, **kw: translate(_(*a, **kw),
                                               context=self.request)

        return args
Example #4
0
class BlogsTab(Tab):

    types = 'Blog'
    sort_on = 'sortable_title'
    show_selects = False
    show_menu = False

    columns = (
        {'column': 'Title',
         'column_title': _(u'column_title', default=u'Title'),
         'sort_index': 'sortable_title',
         'transform': helper.linked},
         {'column': 'Creator',
          'column_title': _(u'column_creator', default=u'Creator'),
          'sort_index': 'sortable_creator',
          'transform': helper.readable_author}, )
class EditForm(form.EditForm):
    implements(IBlogEntryCollectionPortlet)
    label = _(u'label_edit_blogentry_collection_portlet',
              default=u'Edit BlogEntry collection portlet')

    fields = field.Fields(IBlogEntryCollectionPortlet)

    def __init__(self, context, request):
        super(EditForm, self).__init__(context, request)
        self.status = None
        self._finishedAdd = None

    def __call__(self):
        IPortletPermissionChecker(aq_parent(aq_inner(self.context)))()
        return super(EditForm, self).__call__()

    def nextURL(self):
        editview = aq_parent(aq_inner(self.context))
        context = aq_parent(aq_inner(editview))
        url = str(
            getMultiAdapter((context, self.request), name=u"absolute_url"))
        return url + '/@@manage-portlets'

    @button.buttonAndHandler(_(u"label_save", default=u"Save"), name='apply')
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        changes = self.applyChanges(data)
        if changes:
            self.status = "Changes saved"
        else:
            self.status = "No changes"

        nextURL = self.nextURL()
        return self.request.response.redirect(nextURL)

    @button.buttonAndHandler(_(u"label_cancel", default=u"Cancel"),
                             name='cancel_add')
    def handleCancel(self, action):
        nextURL = self.nextURL()
        return self.request.response.redirect(nextURL)

    def updateWidgets(self):
        self.fields['path'].widgetFactory = MultiContentTreeFieldWidget
        super(EditForm, self).updateWidgets()
Example #6
0
    def get_render_arguments(self):
        blogentry = self.context
        args = super(BlogEntryView, self).get_render_arguments()

        args.update({
            'title':
            self.convert(blogentry.Title()),
            'text':
            self.convert(blogentry.getText()),
            'owner':
            self.convert(str(blogentry.getOwner())),
            'categories':
            ', '.join([cat.Title() for cat in blogentry.getCategories()]),
            'tags':
            ', '.join(blogentry.tags),
            '_':
            lambda *a, **kw: translate(_(*a, **kw), context=self.request),
        })

        # date
        if blogentry.getEffectiveDate():
            date = blogentry.getEffectiveDate().strftime('%d. %b %Y')
        else:
            date = translate(_(u'latex_unpublished', default=u'Unpublished'),
                             context=self.request)
        args.update({'date': date})

        # leadimage
        if blogentry.getLeadimage():
            latex_lead_img = self._generate_includegraphics_latex(
                blogentry.getLeadimage(), r'\linewidth')
            args.update({
                'leadimage': latex_lead_img,
            })

        # images in blogentry container
        latex_images = []
        images = blogentry.getFolderContents(
            {'object_provides': IATImage.__identifier__})
        for image in images:
            latex_img = self._generate_includegraphics_latex(
                image.getObject().getImage(), r'0.45\linewidth')
            latex_images.append(u'\\fbox{%s}' % latex_img)
        args.update({'images': '\n'.join(latex_images)})

        return args
class IBlogEntryCollectionPortlet(IPortletDataProvider):

    portlet_title = schema.TextLine(title=_(u'label_title', default=u'Title'),
                                    required=True)

    show_image = schema.Bool(
        title=_(u'label_show_image', default=u'Show lead images'),
        description=_(
            u'help_portlet_show_image',
            default=u'You can enable the leadimage in the configuration '
            'registry'),
        default=True)

    path = schema.List(
        title=_(u'Blogs'),
        description=_(
            u'help_portlet_blogs',
            default=u'Choose the blog of which the entries are listed. '
            'Defaults to all blogs.'),
        value_type=schema.Choice(
            source=PathSourceBinder(is_folderish=True,
                                    portal_type='Blog',
                                    navigation_tree_query=None), ),
        required=False,
    )

    quantity = schema.Int(title=_(u'label_quantity', default=u'Quantity'),
                          default=5)

    show_desc = schema.Bool(title=_(u'label_show_desc',
                                    default=u"Show Description"),
                            default=True)
Example #8
0
 def get_render_arguments(self):
     blog = self.context
     args = super(BlogView, self).get_render_arguments()
     args.update({
         'title':
         blog.Title(),
         '_':
         lambda *a, **kw: translate(_(*a, **kw), context=self.request),
     })
     return args
Example #9
0
class BlogEntriesTab(Tab):

    types = 'BlogEntry'
    sort_on = 'created'
    sort_reverse = True
    show_selects = False
    show_menu = False

    columns = (
        {'column': 'created',
         'column_title': _(u'column_created', default=u'created'),
         'transform': helper.readable_date},
        {'column': 'Title',
         'column_title': _(u'column_title', default=u'Title'),
         'sort_index': 'sortable_title',
         'transform': helper.linked},
         {'column': 'Creator',
          'column_title': _(u'column_creator', default=u'Creator'),
          'sort_index': 'sortable_creator',
          'transform': helper.readable_author}, )
Example #10
0
def objectAddedHandler(obj, event):
    """Handle IObjectAddedEvent
    """

    # adding a categories root object
    if not safe_hasattr(obj.aq_explicit, 'categories', False):
        _createObjectByType('BlogCategory', obj, 'categories',
                            excludeFromNav=True)
        category = getattr(obj.aq_explicit, 'categories', False)
        if category:
            category.setTitle(translate(_('Categories'), context=obj.REQUEST))
            category.reindexObject()
 def title(self):
     return _(u'label_portlet_title', default=u'BlogEntries collection')
Example #12
0
        widget=atapi.RichWidget(
            label='Text',
            label_msgid='ftw_label_text',
            description='',
            description_msgid='ftw_help_text',
            i18n_domain='ftw.tagging',
            rows=15,
            rooted=True,
        ),
    ),

    atapi.ReferenceField(
        name='categories',
        required=False,
        widget=ReferenceBrowserWidget(
            label=_('Categories'),
            allow_browse=False,
            show_results_without_query=True,
            restrict_browsing_to_startup_directory=True,
            base_query={"portal_type": "BlogCategory",
                        "sort_on": "sortable_title"},
            macro='category_reference_widget',
        ),
        multiValued=1,
        schemata='default',
        relationship='blog_categories',
        allowed_types=['BlogCategory'],
    ),

    atapi.BooleanField(
        name='showImages',
Example #13
0
class IBlogSettings(Interface):
    """Blog settings"""

    blog_entry_has_lead_image = schema.Bool(
        title=_(u"Show lead image in blog entries"), default=False)
 def title(self):
     return _(u'label_portlet_title', default=u'BlogEntries collection')
Example #15
0
     default_output_type='text/x-html-safe',
     widget=atapi.RichWidget(
         label='Text',
         label_msgid='ftw_label_text',
         description='',
         description_msgid='ftw_help_text',
         i18n_domain='ftw.tagging',
         rows=15,
         rooted=True,
     ),
 ),
 atapi.ReferenceField(
     name='categories',
     required=False,
     widget=ReferenceBrowserWidget(
         label=_('Categories'),
         allow_browse=False,
         show_results_without_query=True,
         restrict_browsing_to_startup_directory=True,
         base_query={
             "portal_type": "BlogCategory",
             "sort_on": "sortable_title"
         },
         macro='category_reference_widget',
     ),
     multiValued=1,
     schemata='default',
     relationship='blog_categories',
     allowed_types=['BlogCategory'],
 ),
 atapi.BooleanField(