def acceptInvite(self, request, access_type, page_name=None, params=None, **kwargs): """Creates the page process an invite into a Role. 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: contains the ID for the Request entity """ request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) # get the context for this webpage context = responses.getUniversalContext(request) responses.useJavaScript(context, params['js_uses_all']) context['page_name'] = page_name if request.method == 'POST': return self.acceptInvitePost(request, context, params, request_entity, **kwargs) else: # request.method == 'GET' return self.acceptInviteGet(request, context, params, request_entity, **kwargs)
def processRequest(self, request, access_type, page_name=None, params=None, **kwargs): """Creates the page upon which a request 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 request entity using the information from kwargs request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) # get the context for this webpage context = responses.getUniversalContext(request) responses.useJavaScript(context, params['js_uses_all']) context['page_name'] = '%s from %s to become a %s' % ( page_name, request_entity.user.name, params['name']) # TODO(ljvderijk): Should be a POST request get_dict = request.GET if 'status' in get_dict.keys(): if get_dict['status'] in [ 'group_accepted', 'rejected', 'withdrawn', 'ignored' ]: # update the request_entity and redirect away from this page request_status = get_dict['status'] # only update when the status is changing if request_status != request_entity.status: request_logic.updateEntityProperties( request_entity, {'status': get_dict['status']}) group_view = params.get('group_view') if not group_view: return http.HttpResponseRedirect('/') else: # redirect to the requests list return http.HttpResponseRedirect( redirects.getListRequestsRedirect( request_entity.group, group_view.getParams())) # put the entity in the context context['entity'] = request_entity context['request_status'] = request_entity.status context['role_verbose'] = params['name'] context['url_name'] = params['url_name'] #display the request processing page using the appropriate template template = request_view.view.getParams()['request_processing_template'] return responses.respond(request, template, context=context)
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)
def processRequest(self, request, access_type, page_name=None, params=None, **kwargs): """Creates the page upon which a request 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 request entity using the information from kwargs request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) # get the context for this webpage context = responses.getUniversalContext(request) responses.useJavaScript(context, params['js_uses_all']) context['page_name'] = '%s from %s to become a %s' % ( page_name, request_entity.user.name, params['name']) # TODO(ljvderijk): Should be a POST request get_dict = request.GET if 'status' in get_dict.keys(): if get_dict['status'] in ['group_accepted', 'rejected', 'withdrawn', 'ignored']: # update the request_entity and redirect away from this page request_status = get_dict['status'] # only update when the status is changing if request_status != request_entity.status: request_logic.updateEntityProperties(request_entity, { 'status': get_dict['status']}) group_view = params.get('group_view') if not group_view: return http.HttpResponseRedirect('/') else: # redirect to the requests list return http.HttpResponseRedirect( redirects.getListRequestsRedirect(request_entity.group, group_view.getParams())) # put the entity in the context context['entity'] = request_entity context['request_status'] = request_entity.status context['role_verbose'] = params['name'] context['url_name'] = params['url_name'] #display the request processing page using the appropriate template template = request_view.view.getParams()['request_processing_template'] return responses.respond(request, template, context=context)
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)
def acceptOrgAdminIntivation(self, request, access_type, page_name=None, params=None, **kwargs): """Creates the page process an invite into an OrgAdmin role. """ request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) # get the context for this webpage context = responses.getUniversalContext(request) responses.useJavaScript(context, params['js_uses_all']) context['page_name'] = page_name return acceptInvitation(request, context, params, request_entity, 'org_admin', **kwargs)