Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
 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)}
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 def profile(self):
     return {'userinfo': render_view_group(self.context, self.request, 'user_info', view = self)}
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 def __call__(self):
     return Response(render_view_group(self.context, self.request, 'context_actions', view = self))