예제 #1
0
    def listRequests(self,
                     request,
                     access_type,
                     page_name=None,
                     params=None,
                     **kwargs):
        """Gives an overview of all the requests for a specific group.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: the Key Fields for the specified entity
    """

        # set the pagename to include the link_id
        page_name = '%s %s' % (page_name, kwargs['link_id'])

        # get the group from the request
        group_logic = params['logic']

        group_entity = group_logic.getFromKeyFields(kwargs)

        role_names = params['role_views'].keys()

        # list all incoming requests
        filter = {
            'group': group_entity,
            'role': role_names,
            'status': ['new', 'group_accepted', 'ignored']
        }

        # create the list parameters
        req_params = request_view.getParams()

        # define the list redirect action to the request processing page
        req_params['public_row_extra'] = lambda entity: {
            'link': redirects.getProcessRequestRedirect(entity, None)
        }
        req_params['public_field_ignore'] = ['for']
        req_params['list_description'] = ugettext(
            "An overview of the %(name)s's invites and requests." % params)

        return self.list(request,
                         access_type='allow',
                         page_name=page_name,
                         params=req_params,
                         filter=filter,
                         **kwargs)
예제 #2
0
  def requests(self, request, access_type,
               page_name=None, params=None, **kwargs):
    """Displays the unhandled requests for this user.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: not used
    """

    from soc.views.models.request import view as request_view

    req_params = request_view.getParams()

    # construct the Unhandled Invites list
    uh_params = req_params.copy()
    uh_params['public_row_extra'] = lambda entity: {
        "link": redirects.getInviteProcessRedirect(entity, None),
    }
    uh_params['list_description'] = ugettext(
        "An overview of your unhandled invites.")

    # construct the Open Requests list

    ar_params = req_params.copy()
    ar_params['public_row_action'] = {}
    ar_params['public_row_extra'] = lambda x: {}
    ar_params['list_description'] = ugettext(
        "List of your pending requests.")

    if lists.isDataRequest(request):
      return self.getRequestsListData(request, uh_params, ar_params)

    uh_list = helper.lists.getListGenerator(request, uh_params,
                                            visibility='public', idx=0)
    ar_list = helper.lists.getListGenerator(request, ar_params,
                                            visibility='public', idx=1)

    # fill contents with all the needed lists
    contents = [uh_list, ar_list]

    # call the _list method from base to display the list
    return self._list(request, req_params, contents, page_name)
예제 #3
0
파일: group.py 프로젝트: SRabbelier/Melange
  def listRequests(self, request, access_type,
                   page_name=None, params=None, **kwargs):
    """Gives an overview of all the requests for a specific group.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: the Key Fields for the specified entity
    """

    # set the pagename to include the link_id
    page_name = '%s %s' % (page_name, kwargs['link_id'])

    # get the group from the request
    group_logic = params['logic']

    group_entity = group_logic.getFromKeyFields(kwargs)

    role_names = params['role_views'].keys()

    # list all incoming requests
    filter = {
        'group': group_entity,
        'role': role_names,
        'status': ['new', 'group_accepted', 'ignored']
        }

    # create the list parameters
    req_params = request_view.getParams()

    # define the list redirect action to the request processing page
    req_params['public_row_extra'] = lambda entity: {
        'link': redirects.getProcessRequestRedirect(entity, None)
    }
    req_params['public_field_ignore'] = ['for']
    req_params['list_description'] = ugettext(
        "An overview of the %(name)s's invites and requests." % params)

    return self.list(request, access_type='allow', page_name=page_name,
                     params=req_params, filter=filter, **kwargs)
예제 #4
0
  def listRequests(self, request, access_type,
                   page_name=None, params=None, **kwargs):
    """Gives an overview of all the requests for a specific group.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: the Key Fields for the specified entity
    """

    # set the pagename to include the link_id
    page_name = '%s %s' % (page_name, kwargs['link_id'])

    # get the group from the request
    group_logic = params['logic']

    group_entity = group_logic.getFromKeyFields(kwargs)

    role_names = params['role_views'].keys()

    # list all incoming requests
    filter = {
        'scope': group_entity,
        'role': role_names,
        'status': 'new'
        }

    # create the list parameters
    inc_req_params = request_view.getParams()

    # define the list redirect action to the request processing page
    inc_req_params['list_action'] = (redirects.getProcessRequestRedirect, None)
    inc_req_params['list_description'] = ugettext(
        "An overview of the %(name)s's incoming requests." % params)

    inc_req_content = list_helper.getListContent(
        request, inc_req_params, filter, idx=0)

    # list all outstanding invites
    filter = {
        'scope': group_entity,
        'role': role_names,
        'status': 'group_accepted'
        }

    # create the list parameters
    out_inv_params = request_view.getParams()

    # define the list redirect action to the request processing page
    out_inv_params['list_action'] = (redirects.getProcessRequestRedirect, None)
    out_inv_params['list_description'] = ugettext(
        "An overview of the %(name)s's outstanding invites." % params)

    out_inv_content = list_helper.getListContent(
        request, out_inv_params, filter, idx=1)

    # list all ignored requests
    filter = {
        'scope': group_entity,
        'role': role_names,
        'status': 'ignored'
        }

    # create the list parameters
    ignored_params = request_view.getParams()

    # define the list redirect action to the request processing page
    ignored_params['list_action'] = (redirects.getProcessRequestRedirect, None)
    ignored_params['list_description'] = ugettext(
        "An overview of the %(name)s's ignored requests." % params)

    ignored_content = list_helper.getListContent(
        request, ignored_params, filter, idx=2)

    contents = [inc_req_content, out_inv_content, ignored_content]

    return self._list(request, params, contents, page_name)