app/soc/views/models/club_app.py
author Todd Larsen <tlarsen@google.com>
Wed, 21 Jan 2009 00:27:39 +0000
changeset 858 e79e7a22326f
parent 836 1abdbedf4208
child 875 03c674f510d8
permissions -rw-r--r--
Add an export() view, and implement it as text/text for Document. For every Model except Document, the public() view is displayed for any attempts to access the export() view. Currently, the permissions for export() are the same as for public(). This seems reasonable for Document, since anyone could extract the raw HTML from the page source anyway. The permissions should probably be different for other types of exports, such as vCard or iCard exports of profiles, CSV exports of lists, etc. Patch by: Todd Larsen Review by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Club App profiles.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  ]
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from django import forms
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from django.utils.translation import ugettext_lazy
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from soc.logic import accounts
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
from soc.logic import cleaning
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
from soc.logic import dicts
821
5afe16b2e86b Send a notifcation if a club application is accepted
Sverre Rabbelier <srabbelier@gmail.com>
parents: 818
diff changeset
    32
from soc.logic.helper import notifications
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
from soc.logic.models import user as user_logic
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    34
from soc.models import group_app as group_app_model
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
from soc.views import helper
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    36
from soc.views import out_of_band
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    37
from soc.views.helper import access
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    38
from soc.views.helper import redirects
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
    39
from soc.views.helper import lists as list_helper
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
from soc.views.models import group_app
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
import soc.logic.dicts
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
class View(group_app.View):
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    46
  """View methods for the Club Application model.
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
  """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
  def __init__(self, params=None):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    """Defines the fields and methods required for the base View class
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    to provide the user with list, public, create, edit and delete views.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
    Params:
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
      params: a dict with params for this View
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    55
    """
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
    rights = {}
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
    rights['create'] = [access.checkIsUser]
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
    rights['delete'] = [access.checkIsMyApplication]
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
    rights['edit'] = [access.checkIsMyApplication]
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    rights['list'] = [access.checkIsUser]
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    62
    rights['public'] = [access.checkIsMyApplication]
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    63
    rights['review'] = [access.checkIsDeveloper]
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
    new_params = {}
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
    new_params['rights'] = rights
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    new_params['create_template'] = 'soc/models/twoline_edit.html'
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
    new_params['edit_template'] = 'soc/models/twoline_edit.html'
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    72
    new_params['extra_dynaexclude'] = ['applicant', 'backup_admin',
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    73
        'reviewed', 'accepted', 'application_completed']
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
    new_params['create_extra_dynafields'] = {
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
        'backup_admin_link_id': forms.CharField(
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
              label=group_app_model.GroupApplication.backup_admin.verbose_name
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
              ),
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
        'clean_backup_admin_link_id': cleaning.clean_existing_user('backup_admin_link_id'),
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
        }
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    80
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    81
    patterns = [(r'^%(url_name)s/(?P<access_type>review)$',
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    82
        'soc.views.models.%(module_name)s.showReviewOverview',
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    83
        'Review %(name_plural)s'),
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    84
        (r'^%(url_name)s/(?P<access_type>review)/%(lnp)s$',
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    85
          'soc.views.models.%(module_name)s.review',
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    86
          'Review %(name_short)s')]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    87
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    88
    new_params['extra_django_patterns'] = patterns
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    89
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
    new_params['name'] = "Club Application"
803
9d0ed410bfd5 Fixed missing params in views/models/club_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 799
diff changeset
    91
    new_params['name_plural'] = "Club Applications"
799
30a912906a57 Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 798
diff changeset
    92
    new_params['name_short'] = "Club App"
803
9d0ed410bfd5 Fixed missing params in views/models/club_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 799
diff changeset
    93
    new_params['url_name'] = "club_app"
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    95
    new_params['sidebar_additional'] = [
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    96
        ('/%(url_name)s/review' % new_params,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    97
         'Review %(name_plural)s' % new_params, 'review')]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    98
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    99
    new_params['review_template'] = 'soc/club_app/review.html'
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   100
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
    params = dicts.merge(params, new_params)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
    super(View, self).__init__(params=params)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   105
  def list(self, request, access_type,
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   106
           page_name=None, params=None, filter=None):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   107
    """Lists all notifications that the current logged in user has stored.
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
    for parameters see base.list()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   111
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   112
    params = dicts.merge(params, self._params)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   114
    try:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   115
      access.checkAccess(access_type, request, params['rights'])
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   116
    except out_of_band.Error, error:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   117
      return helper.responses.errorResponse(error, request)
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   118
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
    # get the current user
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
    user_entity = user_logic.logic.getForCurrentAccount()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   121
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
    is_developer = accounts.isDeveloper(user=user_entity)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   124
    filter = {
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   125
        'application_completed': False,
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   126
        'reviewed': False,
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   127
        }
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   128
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   129
    if not is_developer:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   130
      # only select the applications for this user so construct a filter
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   131
      filter['applicant'] = user_entity
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   132
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   133
    # Get all the pending applications
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   134
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   135
    pa_params = params.copy() # pending applications
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   136
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
    if is_developer:
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   138
      pa_params['list_description'] = ugettext_lazy(
836
1abdbedf4208 Add missing 'of' word to list description strings in soc.views.models.club_app module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 823
diff changeset
   139
          "An overview of all pending club applications.")
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
    else:
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   141
      pa_params['list_description'] = ugettext_lazy(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   142
          "An overview of your pending club applications.")
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   143
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   144
    pa_list = list_helper.getListContent(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   145
        request, pa_params, filter, 0)
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   146
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   147
    # Get all the reviewed applications now
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   148
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   149
    # Re-use the old filter, but set to only reviewed and accepted
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   150
    filter['reviewed'] = True
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   151
    filter['accepted'] = True
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   152
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   153
    aa_params = params.copy() # accepted applications
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
    if is_developer:
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   156
      aa_params['list_description'] = ugettext_lazy(
836
1abdbedf4208 Add missing 'of' word to list description strings in soc.views.models.club_app module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 823
diff changeset
   157
          "An overview of all accepted club applications.")
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
    else:
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   159
      aa_params['list_description'] = ugettext_lazy(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   160
          "An overview of your accepted club applications.")
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   161
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   162
    aa_params['url_name'] = 'club'
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   163
    aa_params['list_action'] = (redirects.getCreateRedirect, aa_params)
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   164
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   165
    aa_list = list_helper.getListContent(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   166
        request, aa_params, filter, 1)
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   167
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   168
    # Get all the reviewd applications that were denied
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   169
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   170
    # Re use the old filter, but this time only for denied apps
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   171
    filter['accepted'] = False
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   172
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   173
    da_params = params.copy() # denied applications
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   174
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   175
    if is_developer:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   176
      da_params['list_description'] = ugettext_lazy(
836
1abdbedf4208 Add missing 'of' word to list description strings in soc.views.models.club_app module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 823
diff changeset
   177
          "An overview of all denied club applications.")
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   178
    else:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   179
      da_params['list_description'] = ugettext_lazy(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   180
          "An overview of your denied club applications.")
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   181
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   182
    da_list = list_helper.getListContent(
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   183
        request, da_params, filter, 2)
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   184
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   185
    # fill contents with all the needed lists
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   186
    contents = [pa_list, aa_list, da_list]
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   187
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   188
    # call the _list method from base to display the list
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   189
    return self._list(request, params, contents, page_name)
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   190
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   191
  def _editGet(self, request, entity, form):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   192
    """See base.View._editGet().
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   193
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   194
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   195
    form.fields['backup_admin_link_id'].initial = entity.backup_admin.link_id
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   196
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   197
  def _editPost(self, request, entity, fields):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   198
    """See base.View._editPost().
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   199
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   200
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   201
    fields['backup_admin'] = fields['backup_admin_link_id']
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   202
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   203
    if not entity:
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   204
      fields['applicant'] = user_logic.logic.getForCurrentAccount()
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   205
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   206
    # the application has either been created or edited so
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   207
    # the review status needs to be set accordingly
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   208
    fields['reviewed'] = False
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   209
    fields['accepted'] = False
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   210
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   211
  def _public(self, request, entity, context):
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   212
    """See base._public().
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   213
    """
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   214
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   215
    context['entity_type_url'] = self._params['url_name']
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   216
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   217
  def review(self, request, access_type,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   218
             page_name=None, params=None, **kwargs):
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   219
    """Handles the view containing the review of an application.
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   220
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   221
    accepted (true or false) in the GET data will mark
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   222
    the application accordingly.
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   223
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   224
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   225
    For params see base.View.public().
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   226
    """
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   227
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   228
    params = dicts.merge(params, self._params)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   229
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   230
    try:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   231
      access.checkAccess(access_type, request, rights=params['rights'])
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   232
    except out_of_band.Error, error:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   233
      return helper.responses.errorResponse(error, request)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   234
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   235
    # create default template context for use with any templates
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   236
    context = helper.responses.getUniversalContext(request)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   237
    context['page_name'] = page_name
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   238
    entity = None
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   239
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   240
    try:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   241
      key_fields = self._logic.getKeyFieldsFromDict(kwargs)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   242
      entity = self._logic.getIfFields(key_fields)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   243
    except out_of_band.Error, error:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   244
      return helper.responses.errorResponse(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   245
          error, request, template=params['error_public'], context=context)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   246
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   247
    get_dict = request.GET
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   248
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   249
    # check to see if we can make a decision for this application
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   250
    if 'accepted' in get_dict.keys():
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   251
      accepted_value = get_dict['accepted']
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   252
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   253
      fields = {'reviewed' : False}
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   254
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   255
      if accepted_value == 'true':
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   256
        # the application has been accepted
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   257
        fields['accepted'] = True
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   258
        fields['reviewed'] = True
821
5afe16b2e86b Send a notifcation if a club application is accepted
Sverre Rabbelier <srabbelier@gmail.com>
parents: 818
diff changeset
   259
        notifications.sendNewClubNotification(entity)
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   260
      elif accepted_value == 'false':
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   261
        # the application has been denied
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   262
        fields['accepted'] = False
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   263
        fields['reviewed'] = True
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   264
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   265
      if fields['reviewed']:
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   266
        # the application has either been denied or accepted
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   267
        # mark it as reviewed and update accordingly
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   268
        application = self._logic.getFromFields(link_id=kwargs['link_id'])
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   269
        self._logic.updateModelProperties(application, fields)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   270
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   271
        return self.showReviewOverview(request, access_type,
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   272
            page_name=page_name, params=params, **kwargs)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   273
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   274
    # the application has not been reviewed so show the information
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   275
    # using the appropriate review template
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   276
    params['public_template'] = params['review_template']
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   277
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   278
    return super(View, self).public(request, access_type,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   279
        page_name=page_name, params=params, **kwargs)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   280
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   281
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   282
  def showReviewOverview(self, request, access_type,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   283
             page_name=None, params=None, **kwargs):
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   284
    """Displays multiple lists of applications that are in different
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   285
    states of the application process.
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   286
    """
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   287
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   288
    params = dicts.merge(params, self._params)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   289
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   290
    # only select the requests that haven't been reviewed yet
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   291
    filter = {'reviewed' : False}
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   292
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   293
    ur_params = params.copy()
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   294
    ur_params['list_description'] = ugettext_lazy('A list of all unhandled '
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   295
        'applications.')
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   296
    ur_params ['list_action'] = (redirects.getReviewRedirect, params)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   297
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   298
    ur_list = helper.lists.getListContent(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   299
        request, ur_params, filter, 0)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   300
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   301
    # only select the requests that haven't been turned into a group yet
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   302
    filter = {'accepted' : True,
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   303
        'application_completed' : False}
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   304
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   305
    uh_params = params.copy()
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   306
    uh_params['list_description'] = ugettext_lazy('A list of all applications '
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   307
        'that have been accepted but not turned into a Club yet')
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   308
    uh_params ['list_action'] = (redirects.getReviewRedirect, params)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   309
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   310
    uh_list = helper.lists.getListContent(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   311
        request, uh_params, filter, 0)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   312
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   313
    #only select the requests the have been denied
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   314
    filter = {'reviewed' : True,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   315
        'accepted' : False}
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   316
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   317
    den_params = params.copy()
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   318
    den_params['list_description'] = ugettext_lazy('A list of all applications '
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   319
        'that have been denied')
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   320
    den_params ['list_action'] = (redirects.getReviewRedirect, params)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   321
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   322
    den_list = helper.lists.getListContent(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   323
        request, den_params, filter, 0)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   324
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   325
    # fill contents with all the needed lists
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   326
    contents = [ur_list, uh_list, den_list]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   327
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   328
    # call the _list method from base to display the list
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   329
    return self._list(request, params, contents, page_name)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   330
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   331
view = View()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   332
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   333
create = view.create
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   334
delete = view.delete
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   335
edit = view.edit
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   336
list = view.list
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   337
public = view.public
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 836
diff changeset
   338
export = view.export
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   339
review = view.review
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   340
showReviewOverview = view.showReviewOverview
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 836
diff changeset
   341