app/soc/views/models/club_app.py
changeset 823 c11a103f103d
parent 821 5afe16b2e86b
child 836 1abdbedf4208
equal deleted inserted replaced
822:f37fed16c388 823:c11a103f103d
    34 from soc.models import group_app as group_app_model
    34 from soc.models import group_app as group_app_model
    35 from soc.views import helper
    35 from soc.views import helper
    36 from soc.views import out_of_band
    36 from soc.views import out_of_band
    37 from soc.views.helper import access
    37 from soc.views.helper import access
    38 from soc.views.helper import redirects
    38 from soc.views.helper import redirects
       
    39 from soc.views.helper import lists as list_helper
    39 from soc.views.models import group_app
    40 from soc.views.models import group_app
    40 
    41 
    41 import soc.logic.dicts
    42 import soc.logic.dicts
    42 
    43 
    43 
    44 
   108     for parameters see base.list()
   109     for parameters see base.list()
   109     """
   110     """
   110 
   111 
   111     params = dicts.merge(params, self._params)
   112     params = dicts.merge(params, self._params)
   112 
   113 
       
   114     try:
       
   115       access.checkAccess(access_type, request, params['rights'])
       
   116     except out_of_band.Error, error:
       
   117       return helper.responses.errorResponse(error, request)
       
   118 
   113     # get the current user
   119     # get the current user
   114     user_entity = user_logic.logic.getForCurrentAccount()
   120     user_entity = user_logic.logic.getForCurrentAccount()
   115 
   121 
   116     is_developer = accounts.isDeveloper(user=user_entity)
   122     is_developer = accounts.isDeveloper(user=user_entity)
   117 
   123 
       
   124     filter = {
       
   125         'application_completed': False,
       
   126         'reviewed': False,
       
   127         }
       
   128 
       
   129     if not is_developer:
       
   130       # only select the applications for this user so construct a filter
       
   131       filter['applicant'] = user_entity
       
   132 
       
   133     # Get all the pending applications
       
   134 
       
   135     pa_params = params.copy() # pending applications
       
   136 
   118     if is_developer:
   137     if is_developer:
   119       filter = {}
   138       pa_params['list_description'] = ugettext_lazy(
       
   139           "An overview all pending club applications.")
   120     else:
   140     else:
   121       # only select the applications for this user so construct a filter
   141       pa_params['list_description'] = ugettext_lazy(
   122       filter = {'applicant': user_entity}
   142           "An overview of your pending club applications.")
       
   143 
       
   144     pa_list = list_helper.getListContent(
       
   145         request, pa_params, filter, 0)
       
   146 
       
   147     # Get all the reviewed applications now
       
   148 
       
   149     # Re-use the old filter, but set to only reviewed and accepted
       
   150     filter['reviewed'] = True
       
   151     filter['accepted'] = True
       
   152 
       
   153     aa_params = params.copy() # accepted applications
   123 
   154 
   124     if is_developer:
   155     if is_developer:
   125       params['list_description'] = ugettext_lazy(
   156       aa_params['list_description'] = ugettext_lazy(
   126           "An overview all club applications.")
   157           "An overview all accepted club applications.")
   127     else:
   158     else:
   128       params['list_description'] = ugettext_lazy(
   159       aa_params['list_description'] = ugettext_lazy(
   129           "An overview of your club applications.")
   160           "An overview of your accepted club applications.")
   130 
   161 
   131     # use the generic list method with the filter. The access check in this
   162     aa_params['url_name'] = 'club'
   132     # method will trigger an errorResponse when user_entity is None
   163     aa_params['list_action'] = (redirects.getCreateRedirect, aa_params)
   133     return super(View, self).list(request, access_type,
   164 
   134         page_name, params, filter)
   165     aa_list = list_helper.getListContent(
       
   166         request, aa_params, filter, 1)
       
   167 
       
   168     # Get all the reviewd applications that were denied
       
   169 
       
   170     # Re use the old filter, but this time only for denied apps
       
   171     filter['accepted'] = False
       
   172 
       
   173     da_params = params.copy() # denied applications
       
   174 
       
   175     if is_developer:
       
   176       da_params['list_description'] = ugettext_lazy(
       
   177           "An overview all denied club applications.")
       
   178     else:
       
   179       da_params['list_description'] = ugettext_lazy(
       
   180           "An overview of your denied club applications.")
       
   181 
       
   182     da_list = list_helper.getListContent(
       
   183         request, da_params, filter, 2)
       
   184 
       
   185     # fill contents with all the needed lists
       
   186     contents = [pa_list, aa_list, da_list]
       
   187 
       
   188     # call the _list method from base to display the list
       
   189     return self._list(request, params, contents, page_name)
   135 
   190 
   136   def _editGet(self, request, entity, form):
   191   def _editGet(self, request, entity, form):
   137     """See base.View._editGet().
   192     """See base.View._editGet().
   138     """
   193     """
   139 
   194