app/soc/views/models/request.py
changeset 951 026696e4a3af
parent 944 5ea2bd9e3fa6
child 953 157a20300bbc
equal deleted inserted replaced
950:8f59df49985b 951:026696e4a3af
    85     new_params['extra_dynaexclude'] = ['state', 'role_verbose']
    85     new_params['extra_dynaexclude'] = ['state', 'role_verbose']
    86     
    86     
    87     # TODO(ljvderijk) add clean field that checks to see if the user already has
    87     # TODO(ljvderijk) add clean field that checks to see if the user already has
    88     # the role that's been entered in the create form fields
    88     # the role that's been entered in the create form fields
    89     new_params['create_extra_dynafields'] = {
    89     new_params['create_extra_dynafields'] = {
    90         'role' : forms.CharField(widget=widgets.ReadOnlyInput(),
    90         'role': forms.CharField(widget=widgets.ReadOnlyInput(),
    91                                    required=True),
    91                                    required=True),
    92         'clean_link_id': cleaning.clean_existing_user('link_id')
    92         'clean_link_id': cleaning.clean_existing_user('link_id')
    93         }
    93         }
    94 
    94 
    95     new_params['edit_extra_dynafields'] = {
    95     new_params['edit_extra_dynafields'] = {
    99 
    99 
   100     patterns = [(r'^%(url_name)s/(?P<access_type>invite)/%(lnp)s$',
   100     patterns = [(r'^%(url_name)s/(?P<access_type>invite)/%(lnp)s$',
   101         'soc.views.models.%(module_name)s.invite',
   101         'soc.views.models.%(module_name)s.invite',
   102         'Create invite for %(name_plural)s'),
   102         'Create invite for %(name_plural)s'),
   103         (r'^%(url_name)s/(?P<access_type>process_invite)/%(key_fields)s$',
   103         (r'^%(url_name)s/(?P<access_type>process_invite)/%(key_fields)s$',
   104           'soc.views.models.%(module_name)s.processInvite',
   104           'soc.views.models.%(module_name)s.process_invite',
   105           'Process Invite to for a Role')]
   105           'Process Invite to for a Role')]
   106 
   106 
   107     new_params['extra_django_patterns'] = patterns
   107     new_params['extra_django_patterns'] = patterns
   108     
   108     
   109     new_params['invite_processing_template'] = 'soc/request/process_invite.html'
   109     new_params['invite_processing_template'] = 'soc/request/process_invite.html'
   120     """Creates the page upon which an invite can be processed.
   120     """Creates the page upon which an invite can be processed.
   121 
   121 
   122     Args:
   122     Args:
   123       request: the standard Django HTTP request object
   123       request: the standard Django HTTP request object
   124       access_type : the name of the access type which should be checked
   124       access_type : the name of the access type which should be checked
   125       context: dictionary containing the context for this view
   125       page_name: the page name displayed in templates as page and header title
   126       params: a dict with params for this View
   126       params: a dict with params for this View
   127       kwargs: the Key Fields for the specified entity
   127       kwargs: the Key Fields for the specified entity
   128     """
   128     """
   129 
   129 
   130     # get the context for this webpage
   130     # get the context for this webpage
   132     context['page_name'] = page_name
   132     context['page_name'] = page_name
   133     
   133     
   134     request_logic = params['logic']
   134     request_logic = params['logic']
   135 
   135 
   136     # get the request entity using the information from kwargs
   136     # get the request entity using the information from kwargs
   137     fields = {'link_id' : kwargs['link_id'],
   137     fields = {'link_id': kwargs['link_id'],
   138         'scope_path' : kwargs['scope_path'],
   138         'scope_path': kwargs['scope_path'],
   139         'role' : kwargs['role'],
   139         'role': kwargs['role'],
   140         'state' : 'group_accepted'}
   140         'state': 'group_accepted'}
   141     request_entity = request_logic.getForFields(fields, unique=True)
   141     request_entity = request_logic.getForFields(fields, unique=True)
   142     
   142     
   143     get_dict = request.GET
   143     get_dict = request.GET
   144     
   144     
   145     if 'status' in get_dict.keys():
   145     if 'status' in get_dict.keys():
   146       if get_dict['status'] == 'rejected':
   146       if get_dict['status'] == 'rejected':
   147         # this invite has been rejected mark as rejected
   147         # this invite has been rejected mark as rejected
   148         request_logic.updateModelProperties(request_entity, {
   148         request_logic.updateModelProperties(request_entity, {
   149             'state' : 'rejected'})
   149             'state': 'rejected'})
   150         
   150         
   151         # redirect to user role overview
   151         # redirect to user role overview
   152         return http.HttpResponseRedirect('/user/roles')
   152         return http.HttpResponseRedirect('/user/roles')
   153 
   153 
   154     # put the entity in the context
   154     # put the entity in the context
   169                page_name=None, params=None, **kwargs):
   169                page_name=None, params=None, **kwargs):
   170     """Displays the unhandled requests for this user.
   170     """Displays the unhandled requests for this user.
   171 
   171 
   172     Args:
   172     Args:
   173       request: the standard Django HTTP request object
   173       request: the standard Django HTTP request object
       
   174       access_type : the name of the access type which should be checked
   174       page_name: the page name displayed in templates as page and header title
   175       page_name: the page name displayed in templates as page and header title
   175       params: a dict with params for this View
   176       params: a dict with params for this View
   176       kwargs: not used
   177       kwargs: not used
   177     """
   178     """
   178 
   179 
   182 
   183 
   183     # construct the Unhandled Invites list
   184     # construct the Unhandled Invites list
   184 
   185 
   185     # only select the Invites for this user that haven't been handled yet
   186     # only select the Invites for this user that haven't been handled yet
   186     filter = {'link_id': user_entity.link_id,
   187     filter = {'link_id': user_entity.link_id,
   187               'state' : 'group_accepted'}
   188               'state': 'group_accepted'}
   188 
   189 
   189     uh_params = params.copy()
   190     uh_params = params.copy()
   190     uh_params['list_action'] = (redirects.getInviteProcessRedirect, None)
   191     uh_params['list_action'] = (redirects.getInviteProcessRedirect, None)
   191     uh_params['list_description'] = ugettext_lazy(
   192     uh_params['list_description'] = ugettext_lazy(
   192         "An overview of your unhandled invites.")
   193         "An overview of your unhandled invites.")
   196 
   197 
   197     # construct the Open Requests list
   198     # construct the Open Requests list
   198 
   199 
   199     # only select the requests from the user
   200     # only select the requests from the user
   200     # that haven't been accepted by an admin yet
   201     # that haven't been accepted by an admin yet
   201     filter = {'link_id' : user_entity.link_id,
   202     filter = {'link_id': user_entity.link_id,
   202               'state' : 'new'}
   203               'state': 'new'}
   203 
   204 
   204     ar_params = params.copy()
   205     ar_params = params.copy()
   205     ar_params['list_description'] = ugettext_lazy(
   206     ar_params['list_description'] = ugettext_lazy(
   206         "List of your pending requests.")
   207         "List of your pending requests.")
   207 
   208 
   220 create = view.create
   221 create = view.create
   221 edit = view.edit
   222 edit = view.edit
   222 delete = view.delete
   223 delete = view.delete
   223 list = view.list
   224 list = view.list
   224 list_self = view.listSelf
   225 list_self = view.listSelf
   225 processInvite = view.processInvite
   226 process_invite = view.processInvite
   226 public = view.public
   227 public = view.public
   227 export = view.export
   228 export = view.export
   228 
   229