Beispiel #1
0
  def processInvite(self, request, access_type,
                   page_name=None, params=None, **kwargs):
    """Creates the page upon which an invite can be processed.

    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
    """

    from soc.views.models.role import ROLE_VIEWS

    # get the context for this webpage
    context = responses.getUniversalContext(request)
    helper.responses.useJavaScript(context, params['js_uses_all'])

    # get the request entity using the information from kwargs
    request_entity = request_logic.getFromIDOr404(int(kwargs['id']))

    invite_accepted_redirect = redirects.getInviteAcceptedRedirect(
        request_entity, self._params)

    role_params = ROLE_VIEWS[request_entity.role].getParams()

    role_logic = role_params['logic']
    if not role_logic.canRejectInvite(request_entity.group):
      return http.HttpResponseRedirect(invite_accepted_redirect)

    # set the page name using the request_entity
    context['page_name'] = '%s %s for %s' % (page_name, 
        role_params['name'], request_entity.group.name)

    get_dict = request.GET

    # TODO(ljvderijk): Should be made a POST request.
    if 'status' in get_dict.keys():
      if get_dict['status'] == 'canceled':
        # this invite has been canceled mark as such
        request_logic.updateEntityProperties(request_entity, {
            'status': 'canceled'})

        # redirect to user request overview
        return http.HttpResponseRedirect('/user/requests')

    # put the entity in the context
    context['entity'] = request_entity
    context['module_name'] = params['module_name']
    context['role_name'] = role_params['name']
    context['invite_accepted_redirect'] = (invite_accepted_redirect)

    #display the invite processing page using the appropriate template
    template = params['invite_processing_template']

    return responses.respond(request, template, context=context)
Beispiel #2
0
    def processInvite(self,
                      request,
                      access_type,
                      page_name=None,
                      params=None,
                      **kwargs):
        """Creates the page upon which an invite can be processed.

    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
    """

        from soc.views.models.role import ROLE_VIEWS

        # get the context for this webpage
        context = responses.getUniversalContext(request)
        helper.responses.useJavaScript(context, params['js_uses_all'])

        # get the request entity using the information from kwargs
        request_entity = request_logic.getFromIDOr404(int(kwargs['id']))

        role_params = ROLE_VIEWS[request_entity.role].getParams()

        # set the page name using the request_entity
        context['page_name'] = '%s %s for %s' % (
            page_name, role_params['name'], request_entity.group.name)

        get_dict = request.GET

        if 'status' in get_dict.keys():
            if get_dict['status'] == 'rejected':
                # this invite has been rejected mark as rejected
                request_logic.updateEntityProperties(request_entity,
                                                     {'status': 'rejected'})

                # redirect to user request overview
                return http.HttpResponseRedirect('/user/requests')

        # put the entity in the context
        context['entity'] = request_entity
        context['module_name'] = params['module_name']
        context['role_name'] = role_params['name']
        context['invite_accepted_redirect'] = (
            redirects.getInviteAcceptedRedirect(request_entity, self._params))

        #display the invite processing page using the appropriate template
        template = params['invite_processing_template']

        return responses.respond(request, template, context=context)
Beispiel #3
0
  def processInvite(self, request, access_type,
                   page_name=None, params=None, **kwargs):
    """Creates the page upon which an invite can be processed.

    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
    """

    # get the context for this webpage
    context = responses.getUniversalContext(request)
    helper.responses.useJavaScript(context, params['js_uses_all'])

    request_logic = params['logic']

    # get the request entity using the information from kwargs
    fields = {'link_id': kwargs['link_id'],
        'scope_path': kwargs['scope_path'],
        'role': kwargs['role'],
        'status': 'group_accepted'}
    request_entity = request_logic.getForFields(fields, unique=True)

    # set the page name using the request_entity
    context['page_name'] = '%s %s' % (page_name, 
        request_entity.role_verbose)

    get_dict = request.GET

    if 'status' in get_dict.keys():
      if get_dict['status'] == 'rejected':
        # this invite has been rejected mark as rejected
        request_logic.updateEntityProperties(request_entity, {
            'status': 'rejected'})

        # redirect to user request overview
        return http.HttpResponseRedirect('/user/requests')

    # put the entity in the context
    context['entity'] = request_entity
    context['module_name'] = params['module_name']
    context['invite_accepted_redirect'] = (
        redirects.getInviteAcceptedRedirect(request_entity, self._params))

    #display the invite processing page using the appropriate template
    template = params['invite_processing_template']

    return responses.respond(request, template, context=context)