app/soc/views/models/club_app.py
changeset 1085 0afbdd0905ef
parent 1083 b8018d7a9f23
child 1115 0a723ff3d27c
equal deleted inserted replaced
1084:9c4221f7b747 1085:0afbdd0905ef
    72     new_params['sidebar_grouping'] = 'Clubs'
    72     new_params['sidebar_grouping'] = 'Clubs'
    73 
    73 
    74     new_params['create_template'] = 'soc/models/twoline_edit.html'
    74     new_params['create_template'] = 'soc/models/twoline_edit.html'
    75     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    75     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    76 
    76 
    77     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'state',
    77     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
    78         'created_on', 'last_modified_on']
    78         'created_on', 'last_modified_on']
    79     new_params['create_extra_dynafields'] = {
    79     new_params['create_extra_dynafields'] = {
    80         'backup_admin_link_id': forms.CharField(
    80         'backup_admin_link_id': forms.CharField(
    81               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    81               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    82               ),
    82               ),
   127     user_entity = user_logic.logic.getForCurrentAccount()
   127     user_entity = user_logic.logic.getForCurrentAccount()
   128 
   128 
   129     is_developer = accounts.isDeveloper(user=user_entity)
   129     is_developer = accounts.isDeveloper(user=user_entity)
   130 
   130 
   131     filter = {
   131     filter = {
   132         'state': 'needs review',
   132         'status': 'needs review',
   133         }
   133         }
   134 
   134 
   135     if not is_developer:
   135     if not is_developer:
   136       # only select the applications for this user so construct a filter
   136       # only select the applications for this user so construct a filter
   137       filter['applicant'] = user_entity
   137       filter['applicant'] = user_entity
   151         request, pa_params, filter, 0)
   151         request, pa_params, filter, 0)
   152 
   152 
   153     # get all the reviewed applications now
   153     # get all the reviewed applications now
   154 
   154 
   155     # re-use the old filter, but set to only reviewed and accepted
   155     # re-use the old filter, but set to only reviewed and accepted
   156     filter['state'] = 'accepted'
   156     filter['status'] = 'accepted'
   157 
   157 
   158     aa_params = params.copy() # accepted applications
   158     aa_params = params.copy() # accepted applications
   159 
   159 
   160     if is_developer:
   160     if is_developer:
   161       aa_params['list_description'] = ugettext(
   161       aa_params['list_description'] = ugettext(
   171         request, aa_params, filter, 1)
   171         request, aa_params, filter, 1)
   172 
   172 
   173     # get all the reviewed applications that were denied
   173     # get all the reviewed applications that were denied
   174 
   174 
   175     # re use the old filter, but this time only for denied apps
   175     # re use the old filter, but this time only for denied apps
   176     filter['state'] = 'rejected'
   176     filter['status'] = 'rejected'
   177 
   177 
   178     da_params = params.copy() # denied applications
   178     da_params = params.copy() # denied applications
   179 
   179 
   180     if is_developer:
   180     if is_developer:
   181       da_params['list_description'] = ugettext(
   181       da_params['list_description'] = ugettext(
   189 
   189 
   190     contents = [pa_list, aa_list, da_list]
   190     contents = [pa_list, aa_list, da_list]
   191 
   191 
   192     if is_developer:
   192     if is_developer:
   193       # re use the old filter, but this time only for ignored apps
   193       # re use the old filter, but this time only for ignored apps
   194       filter['state'] = 'ignored'
   194       filter['status'] = 'ignored'
   195 
   195 
   196       ia_params = params.copy() # ignored applications
   196       ia_params = params.copy() # ignored applications
   197 
   197 
   198       ia_params['list_description'] = ugettext(
   198       ia_params['list_description'] = ugettext(
   199           "An overview of all ignored club applications.")
   199           "An overview of all ignored club applications.")
   222 
   222 
   223     if not entity:
   223     if not entity:
   224       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   224       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   225 
   225 
   226     # the application has either been created or edited so
   226     # the application has either been created or edited so
   227     # the state needs to be set accordingly
   227     # the status needs to be set accordingly
   228     fields['state'] = 'needs review'
   228     fields['status'] = 'needs review'
   229 
   229 
   230   def _public(self, request, entity, context):
   230   def _public(self, request, entity, context):
   231     """See base._public().
   231     """See base._public().
   232     """
   232     """
   233 
   233 
   259           error, request, template=params['error_public'], context=context)
   259           error, request, template=params['error_public'], context=context)
   260 
   260 
   261     get_dict = request.GET
   261     get_dict = request.GET
   262 
   262 
   263     # check to see if we can make a decision for this application
   263     # check to see if we can make a decision for this application
   264     if 'state' in get_dict.keys():
   264     if 'status' in get_dict.keys():
   265       state_value = get_dict['state']
   265       status_value = get_dict['status']
   266 
   266 
   267       if state_value in ['accepted', 'rejected', 'ignored']:
   267       if status_value in ['accepted', 'rejected', 'ignored']:
   268         # this application has been properly reviewed update the state
   268         # this application has been properly reviewed update the status
   269         fields = {'state' : state_value}
   269         fields = {'status' : status_value}
   270 
   270 
   271         self._logic.updateEntityProperties(entity, fields)
   271         self._logic.updateEntityProperties(entity, fields)
   272         
   272         
   273         if state_value == 'accepted':
   273         if status_value == 'accepted':
   274           # the application has been accepted send out a notification
   274           # the application has been accepted send out a notification
   275           notifications.sendNewClubNotification(entity)
   275           notifications.sendNewClubNotification(entity)
   276 
   276 
   277         return self.reviewOverview(request, access_type,
   277         return self.reviewOverview(request, access_type,
   278             page_name=page_name, params=params, **kwargs)
   278             page_name=page_name, params=params, **kwargs)
   286 
   286 
   287   @decorators.merge_params
   287   @decorators.merge_params
   288   @decorators.check_access
   288   @decorators.check_access
   289   def reviewOverview(self, request, access_type,
   289   def reviewOverview(self, request, access_type,
   290              page_name=None, params=None, **kwargs):
   290              page_name=None, params=None, **kwargs):
   291     """Displays multiple lists of applications that are in different
   291     """Displays multiple lists of applications that are in a different
   292     states of the application process.
   292     status of the application process.
   293     """
   293     """
   294 
   294 
   295     params = dicts.merge(params, self._params)
   295     params = dicts.merge(params, self._params)
   296 
   296 
   297     # only select the requests that haven't been reviewed yet
   297     # only select the requests that haven't been reviewed yet
   298     filter = {'state' : 'needs review'}
   298     filter = {'status' : 'needs review'}
   299 
   299 
   300     ur_params = params.copy()
   300     ur_params = params.copy()
   301     ur_params['list_description'] = ugettext('A list of all unhandled '
   301     ur_params['list_description'] = ugettext('A list of all unhandled '
   302         'applications.')
   302         'applications.')
   303     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   303     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   304 
   304 
   305     ur_list = helper.lists.getListContent(
   305     ur_list = helper.lists.getListContent(
   306         request, ur_params, filter, 0)
   306         request, ur_params, filter, 0)
   307 
   307 
   308     # only select the requests that haven't been turned into a group yet
   308     # only select the requests that haven't been turned into a group yet
   309     filter['state'] = 'accepted'
   309     filter['status'] = 'accepted'
   310 
   310 
   311     uh_params = params.copy()
   311     uh_params = params.copy()
   312     uh_params['list_description'] = ugettext('A list of all applications '
   312     uh_params['list_description'] = ugettext('A list of all applications '
   313         'that have been accepted but not turned into a Club yet')
   313         'that have been accepted but not turned into a Club yet')
   314     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   314     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   315 
   315 
   316     uh_list = helper.lists.getListContent(
   316     uh_list = helper.lists.getListContent(
   317         request, uh_params, filter, 1)
   317         request, uh_params, filter, 1)
   318 
   318 
   319     # only select the requests the have been rejected
   319     # only select the requests the have been rejected
   320     filter ['state'] = 'rejected'
   320     filter ['status'] = 'rejected'
   321 
   321 
   322     den_params = params.copy()
   322     den_params = params.copy()
   323     den_params['list_description'] = ugettext('A list of all applications '
   323     den_params['list_description'] = ugettext('A list of all applications '
   324         'that have been rejected')
   324         'that have been rejected')
   325     den_params ['list_action'] = (redirects.getReviewRedirect, params)
   325     den_params ['list_action'] = (redirects.getReviewRedirect, params)
   326 
   326 
   327     den_list = helper.lists.getListContent(
   327     den_list = helper.lists.getListContent(
   328         request, den_params, filter, 2)
   328         request, den_params, filter, 2)
   329 
   329 
   330     # only select the request that have been ignored
   330     # only select the request that have been ignored
   331     filter ['state'] = 'ignored'
   331     filter ['status'] = 'ignored'
   332 
   332 
   333     ign_params = params.copy()
   333     ign_params = params.copy()
   334     ign_params['list_description'] = ugettext('A list of all applications '
   334     ign_params['list_description'] = ugettext('A list of all applications '
   335         'that have been ignored')
   335         'that have been ignored')
   336     ign_params ['list_action'] = (redirects.getReviewRedirect, params)
   336     ign_params ['list_action'] = (redirects.getReviewRedirect, params)