app/soc/views/models/club_app.py
changeset 892 c3cdb581ffd2
parent 890 b3bf833c4580
child 893 2dba566e4bf8
equal deleted inserted replaced
891:3d40190f35b6 892:c3cdb581ffd2
    69     new_params['logic'] = club_app_logic.logic
    69     new_params['logic'] = club_app_logic.logic
    70 
    70 
    71     new_params['create_template'] = 'soc/models/twoline_edit.html'
    71     new_params['create_template'] = 'soc/models/twoline_edit.html'
    72     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    72     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    73 
    73 
    74     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin',
    74     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
    75         'reviewed', 'accepted', 'application_completed', 
       
    76         'created_on', 'last_modified_on']
    75         'created_on', 'last_modified_on']
    77     new_params['create_extra_dynafields'] = {
    76     new_params['create_extra_dynafields'] = {
    78         'backup_admin_link_id': forms.CharField(
    77         'backup_admin_link_id': forms.CharField(
    79               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    78               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    80               ),
    79               ),
   119     user_entity = user_logic.logic.getForCurrentAccount()
   118     user_entity = user_logic.logic.getForCurrentAccount()
   120 
   119 
   121     is_developer = accounts.isDeveloper(user=user_entity)
   120     is_developer = accounts.isDeveloper(user=user_entity)
   122 
   121 
   123     filter = {
   122     filter = {
   124         'application_completed': False,
   123         'status': 'needs review',
   125         'reviewed': False,
       
   126         }
   124         }
   127 
   125 
   128     if not is_developer:
   126     if not is_developer:
   129       # only select the applications for this user so construct a filter
   127       # only select the applications for this user so construct a filter
   130       filter['applicant'] = user_entity
   128       filter['applicant'] = user_entity
   144         request, pa_params, filter, 0)
   142         request, pa_params, filter, 0)
   145 
   143 
   146     # Get all the reviewed applications now
   144     # Get all the reviewed applications now
   147 
   145 
   148     # Re-use the old filter, but set to only reviewed and accepted
   146     # Re-use the old filter, but set to only reviewed and accepted
   149     filter['reviewed'] = True
   147     filter['status'] = 'accepted'
   150     filter['accepted'] = True
       
   151 
   148 
   152     aa_params = params.copy() # accepted applications
   149     aa_params = params.copy() # accepted applications
   153 
   150 
   154     if is_developer:
   151     if is_developer:
   155       aa_params['list_description'] = ugettext_lazy(
   152       aa_params['list_description'] = ugettext_lazy(
   162     aa_params['list_action'] = (redirects.getApplicantRedirect, aa_params)
   159     aa_params['list_action'] = (redirects.getApplicantRedirect, aa_params)
   163 
   160 
   164     aa_list = list_helper.getListContent(
   161     aa_list = list_helper.getListContent(
   165         request, aa_params, filter, 1)
   162         request, aa_params, filter, 1)
   166 
   163 
   167     # Get all the reviewd applications that were denied
   164     # Get all the reviewed applications that were denied
   168 
   165 
   169     # Re use the old filter, but this time only for denied apps
   166     # Re use the old filter, but this time only for denied apps
   170     filter['accepted'] = False
   167     filter['status'] = 'rejected'
   171 
   168 
   172     da_params = params.copy() # denied applications
   169     da_params = params.copy() # denied applications
   173 
   170 
   174     if is_developer:
   171     if is_developer:
   175       da_params['list_description'] = ugettext_lazy(
   172       da_params['list_description'] = ugettext_lazy(
   201 
   198 
   202     if not entity:
   199     if not entity:
   203       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   200       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   204 
   201 
   205     # the application has either been created or edited so
   202     # the application has either been created or edited so
   206     # the review status needs to be set accordingly
   203     # the status needs to be set accordingly
   207     fields['reviewed'] = False
   204     fields['status'] = 'needs review'
   208     fields['accepted'] = False
       
   209 
   205 
   210   def _public(self, request, entity, context):
   206   def _public(self, request, entity, context):
   211     """See base._public().
   207     """See base._public().
   212     """
   208     """
   213 
   209 
   239           error, request, template=params['error_public'], context=context)
   235           error, request, template=params['error_public'], context=context)
   240 
   236 
   241     get_dict = request.GET
   237     get_dict = request.GET
   242 
   238 
   243     # check to see if we can make a decision for this application
   239     # check to see if we can make a decision for this application
   244     if 'accepted' in get_dict.keys():
   240     if 'status' in get_dict.keys():
   245       accepted_value = get_dict['accepted']
   241       status_value = get_dict['status']
   246 
   242 
   247       fields = {'reviewed' : False}
   243       if status_value in ['accepted', 'rejected', 'ignored']:
   248 
   244         # this application has been properly reviewed update the status
   249       if accepted_value == 'true':
   245         fields = {'status' : status_value}
   250         # the application has been accepted
   246 
   251         fields['accepted'] = True
       
   252         fields['reviewed'] = True
       
   253         notifications.sendNewClubNotification(entity)
       
   254       elif accepted_value == 'false':
       
   255         # the application has been denied
       
   256         fields['accepted'] = False
       
   257         fields['reviewed'] = True
       
   258 
       
   259       if fields['reviewed']:
       
   260         # the application has either been denied or accepted
       
   261         # mark it as reviewed and update accordingly
       
   262         application = self._logic.getFromFields(link_id=kwargs['link_id'])
   247         application = self._logic.getFromFields(link_id=kwargs['link_id'])
   263         self._logic.updateModelProperties(application, fields)
   248         self._logic.updateModelProperties(application, fields)
   264 
   249 
   265         return self.reviewOverview(request, access_type,
   250         return self.reviewOverview(request, access_type,
   266             page_name=page_name, params=params, **kwargs)
   251             page_name=page_name, params=params, **kwargs)
   281     """
   266     """
   282 
   267 
   283     params = dicts.merge(params, self._params)
   268     params = dicts.merge(params, self._params)
   284 
   269 
   285     # only select the requests that haven't been reviewed yet
   270     # only select the requests that haven't been reviewed yet
   286     filter = {'reviewed' : False}
   271     filter = {'status' : 'needs review'}
   287 
   272 
   288     ur_params = params.copy()
   273     ur_params = params.copy()
   289     ur_params['list_description'] = ugettext_lazy('A list of all unhandled '
   274     ur_params['list_description'] = ugettext_lazy('A list of all unhandled '
   290         'applications.')
   275         'applications.')
   291     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   276     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   292 
   277 
   293     ur_list = helper.lists.getListContent(
   278     ur_list = helper.lists.getListContent(
   294         request, ur_params, filter, 0)
   279         request, ur_params, filter, 0)
   295 
   280 
   296     # only select the requests that haven't been turned into a group yet
   281     # only select the requests that haven't been turned into a group yet
   297     filter = {'accepted' : True,
   282     filter['status'] = 'accepted'
   298         'application_completed' : False}
       
   299 
   283 
   300     uh_params = params.copy()
   284     uh_params = params.copy()
   301     uh_params['list_description'] = ugettext_lazy('A list of all applications '
   285     uh_params['list_description'] = ugettext_lazy('A list of all applications '
   302         'that have been accepted but not turned into a Club yet')
   286         'that have been accepted but not turned into a Club yet')
   303     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   287     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   304 
   288 
   305     uh_list = helper.lists.getListContent(
   289     uh_list = helper.lists.getListContent(
   306         request, uh_params, filter, 0)
   290         request, uh_params, filter, 0)
   307 
   291 
   308     #only select the requests the have been denied
   292     #only select the requests the have been denied
   309     filter = {'reviewed' : True,
   293     filter ['status'] = 'rejected'
   310         'accepted' : False}
       
   311 
   294 
   312     den_params = params.copy()
   295     den_params = params.copy()
   313     den_params['list_description'] = ugettext_lazy('A list of all applications '
   296     den_params['list_description'] = ugettext_lazy('A list of all applications '
   314         'that have been denied')
   297         'that have been denied')
   315     den_params ['list_action'] = (redirects.getReviewRedirect, params)
   298     den_params ['list_action'] = (redirects.getReviewRedirect, params)