app/soc/views/models/club_app.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 31 Jan 2009 13:48:48 +0000
changeset 1107 a878188e225c
parent 1085 0afbdd0905ef
child 1115 0a723ff3d27c
permissions -rw-r--r--
Added status to program. Also added a new access_check and changed the program edit template to the basic one without edit timeline button. Changed the program menu to show more helpful links like Edit Timeline. Patch by: Lennard de Rijk Reviewed 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
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
    27
from django.utils.translation import ugettext
791
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
1081
81cf69225a24 Added a cleaning method to club_app view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1080
diff changeset
    33
from soc.logic import models as model_logic
882
267e31f1a0b6 Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 876
diff changeset
    34
from soc.logic.models import club_app as club_app_logic
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
from soc.logic.models import user as user_logic
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
from soc.views import helper
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    37
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
    38
from soc.views.helper import access
876
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
    39
from soc.views.helper import decorators
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    40
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
    41
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
    42
from soc.views.models import group_app
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
import soc.logic.dicts
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
class View(group_app.View):
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    48
  """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
    49
  """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
  def __init__(self, params=None):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    """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
    53
    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
    54
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
    Params:
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
      params: a dict with params for this View
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    57
    """
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
1007
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 986
diff changeset
    59
    rights = access.Checker(params)
1012
73f0b61f2d9d Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1007
diff changeset
    60
    rights['create'] = ['checkIsUser']
1007
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 986
diff changeset
    61
    rights['delete'] = [('checkIsMyApplication', club_app_logic)]
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 986
diff changeset
    62
    rights['edit'] = [('checkIsMyApplication', club_app_logic)]
1012
73f0b61f2d9d Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1007
diff changeset
    63
    rights['list'] = ['checkIsUser']
1007
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 986
diff changeset
    64
    rights['public'] = [('checkIsMyApplication', club_app_logic)]
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 986
diff changeset
    65
    rights['review'] = ['checkIsHost']
791
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 = {}
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['rights'] = rights
882
267e31f1a0b6 Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 876
diff changeset
    70
    new_params['logic'] = club_app_logic.logic
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
1025
1f83f05f522b Add grouping to the existing views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1012
diff changeset
    72
    new_params['sidebar_grouping'] = 'Clubs'
1f83f05f522b Add grouping to the existing views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1012
diff changeset
    73
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
    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
    75
    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
    76
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
    77
    new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
882
267e31f1a0b6 Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 876
diff changeset
    78
        'created_on', 'last_modified_on']
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
    new_params['create_extra_dynafields'] = {
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
        'backup_admin_link_id': forms.CharField(
882
267e31f1a0b6 Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 876
diff changeset
    81
              label=soc.models.club_app.ClubApplication.backup_admin.verbose_name
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
              ),
886
f5847f24c56e Added clean_existing_user_not_equal_to_current to clean the backup Administrator field in an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 885
diff changeset
    83
        'clean_backup_admin_link_id': 
905
70eb2493a346 Rename clean_existing_user_not_equal_to_current function to clean_users_not_same in soc.logic.cleaning module and fix affected files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 902
diff changeset
    84
            cleaning.clean_users_not_same('backup_admin_link_id'),
1083
b8018d7a9f23 Moved clean_club_app_link_id to cleaning.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1081
diff changeset
    85
        'clean_link_id': cleaning.clean_new_club_link_id('link_id', 
b8018d7a9f23 Moved clean_club_app_link_id to cleaning.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1081
diff changeset
    86
            model_logic.club, club_app_logic)
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
        }
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    88
1080
d533408811ba Changed status in group app model to state.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1025
diff changeset
    89
    new_params['edit_extra_dynafields'] = {
d533408811ba Changed status in group app model to state.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1025
diff changeset
    90
        'clean_link_id' : cleaning.clean_link_id('link_id'),
d533408811ba Changed status in group app model to state.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1025
diff changeset
    91
        }
d533408811ba Changed status in group app model to state.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1025
diff changeset
    92
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    93
    patterns = [(r'^%(url_name)s/(?P<access_type>review)$',
875
03c674f510d8 Renamed showReviewOverview to review_overview and reviewOverview
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    94
        'soc.views.models.%(module_name)s.review_overview',
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    95
        'Review %(name_plural)s'),
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
    96
        (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
    97
          '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
    98
          'Review %(name_short)s')]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
    99
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   100
    new_params['extra_django_patterns'] = patterns
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   101
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
    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
   103
    new_params['name_plural'] = "Club Applications"
799
30a912906a57 Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 798
diff changeset
   104
    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
   105
    new_params['url_name'] = "club_app"
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   106
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   107
    new_params['sidebar_additional'] = [
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   108
        ('/%(url_name)s/review' % new_params,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   109
         'Review %(name_plural)s' % new_params, 'review')]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   110
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   111
    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
   112
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
    params = dicts.merge(params, new_params)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
    super(View, self).__init__(params=params)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   116
876
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   117
  @decorators.merge_params
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   118
  @decorators.check_access
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
  def list(self, request, access_type,
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
           page_name=None, params=None, filter=None):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   121
    """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
   122
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
    for parameters see base.list()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   126
    # get the current user
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   127
    user_entity = user_logic.logic.getForCurrentAccount()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
    is_developer = accounts.isDeveloper(user=user_entity)
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   131
    filter = {
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   132
        'status': 'needs review',
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   133
        }
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
    if not is_developer:
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   136
      # 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
   137
      filter['applicant'] = user_entity
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   138
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   139
    # get all the pending applications
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   140
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   141
    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
   142
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
    if is_developer:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   144
      pa_params['list_description'] = ugettext(
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
   145
          "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
   146
    else:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   147
      pa_params['list_description'] = ugettext(
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   148
          "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
   149
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   150
    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
   151
        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
   152
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   153
    # get all the reviewed applications now
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   154
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   155
    # re-use the old filter, but set to only reviewed and accepted
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   156
    filter['status'] = 'accepted'
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   157
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   158
    aa_params = params.copy() # accepted applications
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   159
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   160
    if is_developer:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   161
      aa_params['list_description'] = ugettext(
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
   162
          "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
   163
    else:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   164
      aa_params['list_description'] = ugettext(
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   165
          "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
   166
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   167
    aa_params['url_name'] = 'club'
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 884
diff changeset
   168
    aa_params['list_action'] = (redirects.getApplicantRedirect, aa_params)
823
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
    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
   171
        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
   172
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   173
    # get all the reviewed applications that were denied
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   174
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   175
    # re use the old filter, but this time only for denied apps
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   176
    filter['status'] = 'rejected'
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   177
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   178
    da_params = params.copy() # denied applications
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   179
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   180
    if is_developer:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   181
      da_params['list_description'] = ugettext(
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
   182
          "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
   183
    else:
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   184
      da_params['list_description'] = ugettext(
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   185
          "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
   186
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   187
    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
   188
        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
   189
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   190
    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
   191
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   192
    if is_developer:
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   193
      # re use the old filter, but this time only for ignored apps
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   194
      filter['status'] = 'ignored'
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   195
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   196
      ia_params = params.copy() # ignored applications
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   197
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   198
      ia_params['list_description'] = ugettext(
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   199
          "An overview of all ignored club applications.")
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   200
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   201
      ia_list = list_helper.getListContent(
894
11afeeba198c Corrected the list index parameters in soc/views/models/club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents: 893
diff changeset
   202
          request, ia_params, filter, 3)
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   203
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   204
      contents += [ia_list]
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   205
823
c11a103f103d Add a 'pending/accepted/denied' seperation to club_app list
Sverre Rabbelier <srabbelier@gmail.com>
parents: 821
diff changeset
   206
    # 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
   207
    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
   208
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   209
  def _editGet(self, request, entity, form):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   210
    """See base.View._editGet().
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   211
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   212
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   213
    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
   214
939
b341698bf3b1 Make reference picker work for create too
Sverre Rabbelier <srabbelier@gmail.com>
parents: 905
diff changeset
   215
    super(View, self)._editGet(request, entity, form)
b341698bf3b1 Make reference picker work for create too
Sverre Rabbelier <srabbelier@gmail.com>
parents: 905
diff changeset
   216
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   217
  def _editPost(self, request, entity, fields):
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   218
    """See base.View._editPost().
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   219
    """
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   220
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   221
    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
   222
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   223
    if not entity:
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   224
      fields['applicant'] = user_logic.logic.getForCurrentAccount()
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   225
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   226
    # the application has either been created or edited so
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   227
    # the status needs to be set accordingly
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   228
    fields['status'] = 'needs review'
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
  def _public(self, request, entity, context):
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   231
    """See base._public().
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   232
    """
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   233
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   234
    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
   235
876
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   236
  @decorators.merge_params
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   237
  @decorators.check_access
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   238
  def review(self, request, access_type,
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   239
             page_name=None, params=None, **kwargs):
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   240
    """Handles the view containing the review of an application.
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   241
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   242
    accepted (true or false) in the GET data will mark
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   243
    the application accordingly.
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   244
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   245
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   246
    For params see base.View.public().
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   247
    """
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
    # 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
   250
    context = helper.responses.getUniversalContext(request)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   251
    context['page_name'] = page_name
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   252
    entity = None
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   253
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   254
    try:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   255
      key_fields = self._logic.getKeyFieldsFromDict(kwargs)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   256
      entity = self._logic.getIfFields(key_fields)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   257
    except out_of_band.Error, error:
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   258
      return helper.responses.errorResponse(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   259
          error, request, template=params['error_public'], context=context)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   260
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   261
    get_dict = request.GET
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   262
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   263
    # check to see if we can make a decision for this application
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   264
    if 'status' in get_dict.keys():
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   265
      status_value = get_dict['status']
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   266
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   267
      if status_value in ['accepted', 'rejected', 'ignored']:
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   268
        # this application has been properly reviewed update the status
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   269
        fields = {'status' : status_value}
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   270
986
e9611a2288ca Rename ModelProperties to EntityProperties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 970
diff changeset
   271
        self._logic.updateEntityProperties(entity, fields)
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   272
        
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   273
        if status_value == 'accepted':
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   274
          # the application has been accepted send out a notification
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   275
          notifications.sendNewClubNotification(entity)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   276
875
03c674f510d8 Renamed showReviewOverview to review_overview and reviewOverview
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   277
        return self.reviewOverview(request, access_type,
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   278
            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
   279
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   280
    # 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
   281
    # using the appropriate review template
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   282
    params['public_template'] = params['review_template']
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   283
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   284
    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
   285
        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
   286
876
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   287
  @decorators.merge_params
0c1329d4b514 Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 875
diff changeset
   288
  @decorators.check_access
875
03c674f510d8 Renamed showReviewOverview to review_overview and reviewOverview
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   289
  def reviewOverview(self, request, access_type,
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   290
             page_name=None, params=None, **kwargs):
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   291
    """Displays multiple lists of applications that are in a different
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   292
    status of the application process.
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   293
    """
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   294
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   295
    params = dicts.merge(params, self._params)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   296
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   297
    # only select the requests that haven't been reviewed yet
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   298
    filter = {'status' : 'needs review'}
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   299
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   300
    ur_params = params.copy()
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   301
    ur_params['list_description'] = ugettext('A list of all unhandled '
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   302
        'applications.')
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   303
    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
   304
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   305
    ur_list = helper.lists.getListContent(
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   306
        request, ur_params, filter, 0)
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   307
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   308
    # only select the requests that haven't been turned into a group yet
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   309
    filter['status'] = 'accepted'
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   310
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   311
    uh_params = params.copy()
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   312
    uh_params['list_description'] = ugettext('A list of all applications '
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   313
        '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
   314
    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
   315
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   316
    uh_list = helper.lists.getListContent(
894
11afeeba198c Corrected the list index parameters in soc/views/models/club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents: 893
diff changeset
   317
        request, uh_params, filter, 1)
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   318
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   319
    # only select the requests the have been rejected
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   320
    filter ['status'] = 'rejected'
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_params = params.copy()
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   323
    den_params['list_description'] = ugettext('A list of all applications '
902
0cc7a76f0eb3 Fixed one style error and one typo.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 897
diff changeset
   324
        'that have been rejected')
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   325
    den_params ['list_action'] = (redirects.getReviewRedirect, params)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   326
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   327
    den_list = helper.lists.getListContent(
894
11afeeba198c Corrected the list index parameters in soc/views/models/club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents: 893
diff changeset
   328
        request, den_params, filter, 2)
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   329
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   330
    # only select the request that have been ignored
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1083
diff changeset
   331
    filter ['status'] = 'ignored'
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   332
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   333
    ign_params = params.copy()
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 944
diff changeset
   334
    ign_params['list_description'] = ugettext('A list of all applications '
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   335
        'that have been ignored')
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   336
    ign_params ['list_action'] = (redirects.getReviewRedirect, params)
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   337
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   338
    ign_list = helper.lists.getListContent(
894
11afeeba198c Corrected the list index parameters in soc/views/models/club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents: 893
diff changeset
   339
        request, ign_params, filter, 3)
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   340
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   341
    # fill contents with all the needed lists
893
2dba566e4bf8 Added Ignored applications to the list view.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 892
diff changeset
   342
    contents = [ur_list, uh_list, den_list, ign_list]
818
ddd102e82107 Fixed whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents: 803
diff changeset
   343
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   344
    # 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
   345
    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
   346
1080
d533408811ba Changed status in group app model to state.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1025
diff changeset
   347
791
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   348
view = View()
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   349
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   350
create = view.create
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   351
delete = view.delete
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   352
edit = view.edit
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   353
list = view.list
30da180c4bca Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   354
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
   355
export = view.export
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 791
diff changeset
   356
review = view.review
875
03c674f510d8 Renamed showReviewOverview to review_overview and reviewOverview
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   357
review_overview = view.reviewOverview
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 836
diff changeset
   358