Add a 'pending/accepted/denied' seperation to club_app list
authorSverre Rabbelier <srabbelier@gmail.com>
Tue, 20 Jan 2009 00:11:38 +0000
changeset 823 c11a103f103d
parent 822 f37fed16c388
child 824 e964dca75527
Add a 'pending/accepted/denied' seperation to club_app list This is not only to make it easier to see which applictions have been accepted, but also to make it possible to redirect to /club/create for the accepted applications, rather than to /club_app/edit. Patch by: Sverre Rabbelier
app/soc/views/models/club_app.py
--- a/app/soc/views/models/club_app.py	Tue Jan 20 00:11:21 2009 +0000
+++ b/app/soc/views/models/club_app.py	Tue Jan 20 00:11:38 2009 +0000
@@ -36,6 +36,7 @@
 from soc.views import out_of_band
 from soc.views.helper import access
 from soc.views.helper import redirects
+from soc.views.helper import lists as list_helper
 from soc.views.models import group_app
 
 import soc.logic.dicts
@@ -110,28 +111,82 @@
 
     params = dicts.merge(params, self._params)
 
+    try:
+      access.checkAccess(access_type, request, params['rights'])
+    except out_of_band.Error, error:
+      return helper.responses.errorResponse(error, request)
+
     # get the current user
     user_entity = user_logic.logic.getForCurrentAccount()
 
     is_developer = accounts.isDeveloper(user=user_entity)
 
+    filter = {
+        'application_completed': False,
+        'reviewed': False,
+        }
+
+    if not is_developer:
+      # only select the applications for this user so construct a filter
+      filter['applicant'] = user_entity
+
+    # Get all the pending applications
+
+    pa_params = params.copy() # pending applications
+
     if is_developer:
-      filter = {}
+      pa_params['list_description'] = ugettext_lazy(
+          "An overview all pending club applications.")
     else:
-      # only select the applications for this user so construct a filter
-      filter = {'applicant': user_entity}
+      pa_params['list_description'] = ugettext_lazy(
+          "An overview of your pending club applications.")
+
+    pa_list = list_helper.getListContent(
+        request, pa_params, filter, 0)
+
+    # Get all the reviewed applications now
+
+    # Re-use the old filter, but set to only reviewed and accepted
+    filter['reviewed'] = True
+    filter['accepted'] = True
+
+    aa_params = params.copy() # accepted applications
 
     if is_developer:
-      params['list_description'] = ugettext_lazy(
-          "An overview all club applications.")
+      aa_params['list_description'] = ugettext_lazy(
+          "An overview all accepted club applications.")
     else:
-      params['list_description'] = ugettext_lazy(
-          "An overview of your club applications.")
+      aa_params['list_description'] = ugettext_lazy(
+          "An overview of your accepted club applications.")
+
+    aa_params['url_name'] = 'club'
+    aa_params['list_action'] = (redirects.getCreateRedirect, aa_params)
+
+    aa_list = list_helper.getListContent(
+        request, aa_params, filter, 1)
+
+    # Get all the reviewd applications that were denied
+
+    # Re use the old filter, but this time only for denied apps
+    filter['accepted'] = False
+
+    da_params = params.copy() # denied applications
 
-    # use the generic list method with the filter. The access check in this
-    # method will trigger an errorResponse when user_entity is None
-    return super(View, self).list(request, access_type,
-        page_name, params, filter)
+    if is_developer:
+      da_params['list_description'] = ugettext_lazy(
+          "An overview all denied club applications.")
+    else:
+      da_params['list_description'] = ugettext_lazy(
+          "An overview of your denied club applications.")
+
+    da_list = list_helper.getListContent(
+        request, da_params, filter, 2)
+
+    # fill contents with all the needed lists
+    contents = [pa_list, aa_list, da_list]
+
+    # call the _list method from base to display the list
+    return self._list(request, params, contents, page_name)
 
   def _editGet(self, request, entity, form):
     """See base.View._editGet().