def render(self, context, request, view, **kwargs): try: contents = render_view_group(request.root, request, 'arche_pas_social', as_type = 'generator') except ComponentLookupError: logger.warn("Can't render PASPortlet - arche_pas_social is empty.") return return render("arche_pas_social:templates/portlet.pt", {'title': self.title, 'portlet': self.portlet, 'contents': contents}, request = request)
def control_panel_participants(context, request, va, active=True, **kw): """ Participants control panel. """ if active: response = { 'context': context, 'title': va.title, 'meeting_closed': context.get_workflow_state() == 'closed', } try: response['panel_group'] = render_view_group(context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' return render('voteit.core:templates/menus/control_panel_participants.pt', response, request=request)
def context_menus(context, request, va, **kw): if request.is_moderator: try: menu_items = render_view_group(context, request, va.name, as_type='list') except ComponentLookupError: menu_items = [] if menu_items: response = { 'menu_items': menu_items, 'context': context, } return render('voteit.core:templates/menus/dropdown_actions.pt', response, request=request)
def control_panel_participants(context, request, va, active=True, **kw): """ Participants control panel. """ if active: response = { 'context': context, 'title': va.title, 'meeting_closed': context.get_workflow_state() == 'closed', } try: response['panel_group'] = render_view_group( context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' return render( 'voteit.core:templates/menus/control_panel_participants.pt', response, request=request)
def control_panel_ap(context, request, va, active=True, **kw): """ Access policy control panel. """ if active: ap_name = request.meeting.access_policy if not ap_name: ap_name = 'invite_only' ap = request.registry.queryAdapter(request.meeting, IAccessPolicy, name=ap_name) response = { 'context': context, 'title': va.title, 'access_policy': ap, 'ap_configurable': bool(ap is not None and ap.config_schema()), } try: response['panel_group'] = render_view_group(context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' return render('voteit.core:templates/menus/control_panel_ap.pt', response, request=request)
def userinfo(self): """ Special view to allow other meeting participants to see information about a user who's in the same meeting as them. Normally called via AJAX and included in a popup or similar, but also a part of the users profile page. Note that a user might have participated within a meeting, and after that lost their permission. This view has to at least display the username of that person. """ try: info_userid = self.request.subpath[0] except IndexError: info_userid = None if not info_userid in security.find_authorized_userids(self.context, (security.VIEW,)): msg = _(u"userid_not_registered_within_meeting_error", default = u"Couldn't find any user with userid '${info_userid}' within this meeting.", mapping = {'info_userid': info_userid}) raise HTTPForbidden( self.request.localizer.translate(msg) ) user = self.request.root['users'].get(info_userid) return {'contents': render_view_group(user, self.request, 'user_info', view = self)}
def control_panel_category(context, request, va, active=True, **kw): """ check_active """ check_active = va.kwargs.get('check_active', False) if check_active: is_active = bool(check_active(context, request, va)) else: is_active = True if active == is_active: response = { 'context': context, 'title': va.title, 'description': va.kwargs.get('description', ''), } try: response['panel_group'] = render_view_group(context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' renderer = va.kwargs.get('renderer', None) tpl = renderer and renderer or TPL return render(tpl, response, request=request)
def control_panel_ap(context, request, va, active=True, **kw): """ Access policy control panel. """ if active: ap_name = request.meeting.access_policy if not ap_name: ap_name = 'invite_only' ap = request.registry.queryAdapter(request.meeting, IAccessPolicy, name=ap_name) response = { 'context': context, 'title': va.title, 'access_policy': ap, 'ap_configurable': bool(ap is not None and ap.config_schema()), } try: response['panel_group'] = render_view_group( context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' return render('voteit.core:templates/menus/control_panel_ap.pt', response, request=request)
def control_panel_category(context, request, va, active=True, **kw): """ check_active """ check_active = va.kwargs.get('check_active', False) if check_active: is_active = bool(check_active(context, request, va)) else: is_active = True if active == is_active: response = { 'context': context, 'title': va.title, 'description': va.kwargs.get('description', ''), } try: response['panel_group'] = render_view_group( context, request, va.kwargs['panel_group']) except ComponentLookupError: response['panel_group'] = '' renderer = va.kwargs.get('renderer', None) tpl = renderer and renderer or TPL return render(tpl, response, request=request)
def render_view_group(self, group, context = None, **kw): if context is None: context = self.context return render_view_group(context, self.request, group, view = self, **kw)
def profile(self): return {'userinfo': render_view_group(self.context, self.request, 'user_info', view = self)}
def render_view_group(self, context, request, name, **kw): if 'api' not in kw: kw['api'] = self return render_view_group(context, request, name, **kw)
def __call__(self): return Response(render_view_group(self.context, self.request, 'context_actions', view = self))