def contents(context, request): """ Contents view. Renders either the contents view or handle the action button actions of the view. :result: Either a redirect response or a dictionary passed to the template for rendering. :rtype: pyramid.httpexceptions.HTTPFound or dict """ contents_view_js.need() buttons = contents_buttons(context, request) for button in buttons: if button.name in request.POST: children = request.POST.getall('children') if not children and button.name != u'paste': request.session.flash( _(u'You have to select items to perform an action.'), 'info') location = resource_url(context, request) + '@@contents' return HTTPFound(location=location) request.session['kotti.selected-children'] = children location = button.url(context, request) return HTTPFound(location, request=request) return {'children': context.children_with_permission(request), 'buttons': buttons, }
def contents(context, request): """ Contents view. Renders either the contents view or handle the action button actions of the view. :result: Either a redirect response or a dictionary passed to the template for rendering. :rtype: pyramid.httpexceptions.HTTPFound or dict """ contents_view_js.need() buttons = contents_buttons(context, request) for button in buttons: if button.name in request.POST: children = request.POST.getall('children') if not children and button.name != 'paste': request.session.flash( _('You have to select items to perform an action.'), 'info') location = resource_url(context, request) + '@@contents' return HTTPFound(location=location) request.session['kotti.selected-children'] = children location = button.url(context, request) return HTTPFound(location, request=request) return {'children': context.children_with_permission(request), 'buttons': buttons, }