app/soc/views/models/club_app.py
changeset 1080 d533408811ba
parent 1025 1f83f05f522b
child 1081 81cf69225a24
equal deleted inserted replaced
1079:be1aacb33b0f 1080:d533408811ba
    71     new_params['sidebar_grouping'] = 'Clubs'
    71     new_params['sidebar_grouping'] = 'Clubs'
    72 
    72 
    73     new_params['create_template'] = 'soc/models/twoline_edit.html'
    73     new_params['create_template'] = 'soc/models/twoline_edit.html'
    74     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    74     new_params['edit_template'] = 'soc/models/twoline_edit.html'
    75 
    75 
    76     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
    76     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'state',
    77         'created_on', 'last_modified_on']
    77         'created_on', 'last_modified_on']
    78     new_params['create_extra_dynafields'] = {
    78     new_params['create_extra_dynafields'] = {
    79         'backup_admin_link_id': forms.CharField(
    79         'backup_admin_link_id': forms.CharField(
    80               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    80               label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
    81               ),
    81               ),
    82         'clean_backup_admin_link_id': 
    82         'clean_backup_admin_link_id': 
    83             cleaning.clean_users_not_same('backup_admin_link_id'),
    83             cleaning.clean_users_not_same('backup_admin_link_id'),
    84         }
    84         }
    85 
    85 
       
    86     new_params['edit_extra_dynafields'] = {
       
    87         'clean_link_id' : cleaning.clean_link_id('link_id'),
       
    88         }
       
    89 
    86     patterns = [(r'^%(url_name)s/(?P<access_type>review)$',
    90     patterns = [(r'^%(url_name)s/(?P<access_type>review)$',
    87         'soc.views.models.%(module_name)s.review_overview',
    91         'soc.views.models.%(module_name)s.review_overview',
    88         'Review %(name_plural)s'),
    92         'Review %(name_plural)s'),
    89         (r'^%(url_name)s/(?P<access_type>review)/%(lnp)s$',
    93         (r'^%(url_name)s/(?P<access_type>review)/%(lnp)s$',
    90           'soc.views.models.%(module_name)s.review',
    94           'soc.views.models.%(module_name)s.review',
   120     user_entity = user_logic.logic.getForCurrentAccount()
   124     user_entity = user_logic.logic.getForCurrentAccount()
   121 
   125 
   122     is_developer = accounts.isDeveloper(user=user_entity)
   126     is_developer = accounts.isDeveloper(user=user_entity)
   123 
   127 
   124     filter = {
   128     filter = {
   125         'status': 'needs review',
   129         'state': 'needs review',
   126         }
   130         }
   127 
   131 
   128     if not is_developer:
   132     if not is_developer:
   129       # only select the applications for this user so construct a filter
   133       # only select the applications for this user so construct a filter
   130       filter['applicant'] = user_entity
   134       filter['applicant'] = user_entity
   144         request, pa_params, filter, 0)
   148         request, pa_params, filter, 0)
   145 
   149 
   146     # get all the reviewed applications now
   150     # get all the reviewed applications now
   147 
   151 
   148     # re-use the old filter, but set to only reviewed and accepted
   152     # re-use the old filter, but set to only reviewed and accepted
   149     filter['status'] = 'accepted'
   153     filter['state'] = 'accepted'
   150 
   154 
   151     aa_params = params.copy() # accepted applications
   155     aa_params = params.copy() # accepted applications
   152 
   156 
   153     if is_developer:
   157     if is_developer:
   154       aa_params['list_description'] = ugettext(
   158       aa_params['list_description'] = ugettext(
   164         request, aa_params, filter, 1)
   168         request, aa_params, filter, 1)
   165 
   169 
   166     # get all the reviewed applications that were denied
   170     # get all the reviewed applications that were denied
   167 
   171 
   168     # re use the old filter, but this time only for denied apps
   172     # re use the old filter, but this time only for denied apps
   169     filter['status'] = 'rejected'
   173     filter['state'] = 'rejected'
   170 
   174 
   171     da_params = params.copy() # denied applications
   175     da_params = params.copy() # denied applications
   172 
   176 
   173     if is_developer:
   177     if is_developer:
   174       da_params['list_description'] = ugettext(
   178       da_params['list_description'] = ugettext(
   182 
   186 
   183     contents = [pa_list, aa_list, da_list]
   187     contents = [pa_list, aa_list, da_list]
   184 
   188 
   185     if is_developer:
   189     if is_developer:
   186       # re use the old filter, but this time only for ignored apps
   190       # re use the old filter, but this time only for ignored apps
   187       filter['status'] = 'ignored'
   191       filter['state'] = 'ignored'
   188 
   192 
   189       ia_params = params.copy() # ignored applications
   193       ia_params = params.copy() # ignored applications
   190 
   194 
   191       ia_params['list_description'] = ugettext(
   195       ia_params['list_description'] = ugettext(
   192           "An overview of all ignored club applications.")
   196           "An overview of all ignored club applications.")
   215 
   219 
   216     if not entity:
   220     if not entity:
   217       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   221       fields['applicant'] = user_logic.logic.getForCurrentAccount()
   218 
   222 
   219     # the application has either been created or edited so
   223     # the application has either been created or edited so
   220     # the status needs to be set accordingly
   224     # the state needs to be set accordingly
   221     fields['status'] = 'needs review'
   225     fields['state'] = 'needs review'
   222 
   226 
   223   def _public(self, request, entity, context):
   227   def _public(self, request, entity, context):
   224     """See base._public().
   228     """See base._public().
   225     """
   229     """
   226 
   230 
   252           error, request, template=params['error_public'], context=context)
   256           error, request, template=params['error_public'], context=context)
   253 
   257 
   254     get_dict = request.GET
   258     get_dict = request.GET
   255 
   259 
   256     # check to see if we can make a decision for this application
   260     # check to see if we can make a decision for this application
   257     if 'status' in get_dict.keys():
   261     if 'state' in get_dict.keys():
   258       status_value = get_dict['status']
   262       state_value = get_dict['state']
   259 
   263 
   260       if status_value in ['accepted', 'rejected', 'ignored']:
   264       if state_value in ['accepted', 'rejected', 'ignored']:
   261         # this application has been properly reviewed update the status
   265         # this application has been properly reviewed update the state
   262         fields = {'status' : status_value}
   266         fields = {'state' : state_value}
   263 
   267 
   264         self._logic.updateEntityProperties(entity, fields)
   268         self._logic.updateEntityProperties(entity, fields)
   265         
   269         
   266         if status_value == 'accepted':
   270         if state_value == 'accepted':
   267           # the application has been accepted send out a notification
   271           # the application has been accepted send out a notification
   268           notifications.sendNewClubNotification(entity)
   272           notifications.sendNewClubNotification(entity)
   269 
   273 
   270         return self.reviewOverview(request, access_type,
   274         return self.reviewOverview(request, access_type,
   271             page_name=page_name, params=params, **kwargs)
   275             page_name=page_name, params=params, **kwargs)
   286     """
   290     """
   287 
   291 
   288     params = dicts.merge(params, self._params)
   292     params = dicts.merge(params, self._params)
   289 
   293 
   290     # only select the requests that haven't been reviewed yet
   294     # only select the requests that haven't been reviewed yet
   291     filter = {'status' : 'needs review'}
   295     filter = {'state' : 'needs review'}
   292 
   296 
   293     ur_params = params.copy()
   297     ur_params = params.copy()
   294     ur_params['list_description'] = ugettext('A list of all unhandled '
   298     ur_params['list_description'] = ugettext('A list of all unhandled '
   295         'applications.')
   299         'applications.')
   296     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   300     ur_params ['list_action'] = (redirects.getReviewRedirect, params)
   297 
   301 
   298     ur_list = helper.lists.getListContent(
   302     ur_list = helper.lists.getListContent(
   299         request, ur_params, filter, 0)
   303         request, ur_params, filter, 0)
   300 
   304 
   301     # only select the requests that haven't been turned into a group yet
   305     # only select the requests that haven't been turned into a group yet
   302     filter['status'] = 'accepted'
   306     filter['state'] = 'accepted'
   303 
   307 
   304     uh_params = params.copy()
   308     uh_params = params.copy()
   305     uh_params['list_description'] = ugettext('A list of all applications '
   309     uh_params['list_description'] = ugettext('A list of all applications '
   306         'that have been accepted but not turned into a Club yet')
   310         'that have been accepted but not turned into a Club yet')
   307     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   311     uh_params ['list_action'] = (redirects.getReviewRedirect, params)
   308 
   312 
   309     uh_list = helper.lists.getListContent(
   313     uh_list = helper.lists.getListContent(
   310         request, uh_params, filter, 1)
   314         request, uh_params, filter, 1)
   311 
   315 
   312     # only select the requests the have been rejected
   316     # only select the requests the have been rejected
   313     filter ['status'] = 'rejected'
   317     filter ['state'] = 'rejected'
   314 
   318 
   315     den_params = params.copy()
   319     den_params = params.copy()
   316     den_params['list_description'] = ugettext('A list of all applications '
   320     den_params['list_description'] = ugettext('A list of all applications '
   317         'that have been rejected')
   321         'that have been rejected')
   318     den_params ['list_action'] = (redirects.getReviewRedirect, params)
   322     den_params ['list_action'] = (redirects.getReviewRedirect, params)
   319 
   323 
   320     den_list = helper.lists.getListContent(
   324     den_list = helper.lists.getListContent(
   321         request, den_params, filter, 2)
   325         request, den_params, filter, 2)
   322 
   326 
   323     # only select the request that have been ignored
   327     # only select the request that have been ignored
   324     filter ['status'] = 'ignored'
   328     filter ['state'] = 'ignored'
   325 
   329 
   326     ign_params = params.copy()
   330     ign_params = params.copy()
   327     ign_params['list_description'] = ugettext('A list of all applications '
   331     ign_params['list_description'] = ugettext('A list of all applications '
   328         'that have been ignored')
   332         'that have been ignored')
   329     ign_params ['list_action'] = (redirects.getReviewRedirect, params)
   333     ign_params ['list_action'] = (redirects.getReviewRedirect, params)
   334     # fill contents with all the needed lists
   338     # fill contents with all the needed lists
   335     contents = [ur_list, uh_list, den_list, ign_list]
   339     contents = [ur_list, uh_list, den_list, ign_list]
   336 
   340 
   337     # call the _list method from base to display the list
   341     # call the _list method from base to display the list
   338     return self._list(request, params, contents, page_name)
   342     return self._list(request, params, contents, page_name)
       
   343 
   339 
   344 
   340 view = View()
   345 view = View()
   341 
   346 
   342 create = view.create
   347 create = view.create
   343 delete = view.delete
   348 delete = view.delete