author | Lennard de Rijk <ljvderijk@gmail.com> |
Thu, 26 Feb 2009 08:47:21 +0000 | |
changeset 1504 | f9d0bf275917 |
parent 1456 | 27e4b7ff2246 |
child 1565 | d36ad73a2060 |
permissions | -rw-r--r-- |
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 |
# |
1307
091a21cf3627
Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1296
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
791
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 Group App. |
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>', |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
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 |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
27 |
from django import http |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
28 |
from django.utils.translation import ugettext |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
|
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
30 |
from soc.logic import accounts |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
31 |
from soc.logic import cleaning |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import dicts |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
33 |
from soc.logic.helper import notifications |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic.models import group_app as group_app_logic |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
35 |
from soc.logic.models import user as user_logic |
1139
7a6f94ffcc87
Changed the url regexpr for review and added 2 missing imports.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1138
diff
changeset
|
36 |
from soc.views import helper |
7a6f94ffcc87
Changed the url regexpr for review and added 2 missing imports.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1138
diff
changeset
|
37 |
from soc.views import out_of_band |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
38 |
from soc.views.helper import decorators |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
39 |
from soc.views.helper import lists as list_helper |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
40 |
from soc.views.helper import redirects |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
41 |
from soc.views.helper import responses |
1229
ec3768cbf369
Refactored the picker so that it is more generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1225
diff
changeset
|
42 |
from soc.views.helper import widgets |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
from soc.views.models import base |
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 |
import soc.logic.models.group_app |
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 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
48 |
DEF_APPLICATION_LIST_DESCRIPTION_FMT = ugettext( |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
49 |
'Overview of %(name_plural)s which status is %(status)s') |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
50 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
51 |
|
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
class View(base.View): |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
"""View methods for the Group App model. |
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 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
def __init__(self, params=None): |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
"""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
|
58 |
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
|
59 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
Params: |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
params: a dict with params for this View |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
""" |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
new_params = {} |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
new_params['logic'] = soc.logic.models.group_app.logic |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
|
799
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
791
diff
changeset
|
67 |
new_params['name'] = "Group Application" |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
new_params['name_short'] = "Group App" |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
|
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
70 |
# use the twoline templates for these questionnaires |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
71 |
new_params['create_template'] = 'soc/models/twoline_edit.html' |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
72 |
new_params['edit_template'] = 'soc/models/twoline_edit.html' |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
73 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
74 |
patterns = [(r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$', |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
75 |
'soc.views.models.%(module_name)s.list_self', |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
76 |
'List my %(name_plural)s'), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
77 |
(r'^%(url_name)s/(?P<access_type>review_overview)/%(scope)s$', |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
78 |
'soc.views.models.%(module_name)s.review_overview', |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
79 |
'List of %(name_plural)s for reviewing'), |
1139
7a6f94ffcc87
Changed the url regexpr for review and added 2 missing imports.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1138
diff
changeset
|
80 |
(r'^%(url_name)s/(?P<access_type>review)/%(key_fields)s$', |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
81 |
'soc.views.models.%(module_name)s.review', |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
82 |
'Review %(name_short)s')] |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
83 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
84 |
new_params['extra_django_patterns'] = patterns |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
85 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
86 |
new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status', |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
87 |
'created_on', 'last_modified_on'] |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
88 |
|
1456
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
89 |
new_params['create_dynafields'] = [ |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
90 |
{'name': 'backup_admin_link_id', |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
91 |
'base': widgets.ReferenceField, |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
92 |
'passthrough': ['reference_url', 'required', 'label'], |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
93 |
'reference_url': 'user', |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
94 |
'required': False, |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
95 |
'label': params['logic'].getModel().backup_admin.verbose_name, |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
96 |
'example_text': ugettext('The link_id of the backup admin'), |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
97 |
}, |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
98 |
] |
27e4b7ff2246
Specify example_text for backup admin link id
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
99 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1365
diff
changeset
|
100 |
new_params['create_extra_dynaproperties'] = { |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
101 |
'clean_backup_admin_link_id': |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
102 |
cleaning.clean_users_not_same('backup_admin_link_id'), |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
103 |
} |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
104 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1365
diff
changeset
|
105 |
new_params['edit_extra_dynaproperties'] = { |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
106 |
'clean_link_id' : cleaning.clean_link_id('link_id'), |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
107 |
} |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
108 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
109 |
params = dicts.merge(params, new_params, sub_merge=True) |
791
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 |
super(View, self).__init__(params=params) |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
799
diff
changeset
|
112 |
|
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
113 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
114 |
def _editGet(self, request, entity, form): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
115 |
"""See base.View._editGet(). |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
116 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
117 |
|
1290
b2919e3ffdae
Brown Paper Bag Fix: L2R Appspot error logs.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1289
diff
changeset
|
118 |
if entity.backup_admin: |
1289
86a4e0e75ea6
Fixed a bug in group_app view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1255
diff
changeset
|
119 |
form.fields['backup_admin_link_id'].initial = entity.backup_admin.link_id |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
120 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
121 |
super(View, self)._editGet(request, entity, form) |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
122 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
123 |
def _editPost(self, request, entity, fields): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
124 |
"""See base.View._editPost(). |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
125 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
126 |
|
1202
8060f33a164f
Added removal of an existing group application when someone else is applying.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
127 |
if not entity: |
8060f33a164f
Added removal of an existing group application when someone else is applying.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
128 |
# set the applicant field to the current user |
1217
aeabe6bed55b
Reverted r1819 and making an application will now reserve the link_id indefinitely.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1204
diff
changeset
|
129 |
fields['applicant'] = user_logic.logic.getForCurrentAccount() |
1202
8060f33a164f
Added removal of an existing group application when someone else is applying.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
130 |
|
8060f33a164f
Added removal of an existing group application when someone else is applying.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
131 |
#set the backup_admin field with the cleaned link_id |
8060f33a164f
Added removal of an existing group application when someone else is applying.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
132 |
fields['backup_admin'] = fields['backup_admin_link_id'] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
133 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
134 |
# the application has either been created or edited so |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
135 |
# the status needs to be set accordingly |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
136 |
fields['status'] = 'needs review' |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
137 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
138 |
super(View, self)._editPost(request, entity, fields) |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
139 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
140 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
141 |
def _public(self, request, entity, context): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
142 |
"""See base._public(). |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
143 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
144 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
145 |
context['entity_type_url'] = self._params['url_name'] |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
146 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
147 |
super(View, self)._public(request, entity, context) |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
148 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
149 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
150 |
@decorators.merge_params |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
151 |
@decorators.check_access |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
152 |
def list(self, request, access_type, |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
153 |
page_name=None, params=None, filter={}, **kwargs): |
1504
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
154 |
"""Lists all notifications in separate tables, depending on their status. |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
155 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
156 |
for parameters see base.list() |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
157 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
158 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
159 |
# create the selection list |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
160 |
selection=[('needs review',(redirects.getEditRedirect, params)), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
161 |
('pre-accepted', (redirects.getEditRedirect, params)), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
162 |
('accepted', (redirects.getEditRedirect, params)), |
1504
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
163 |
('pre-rejected', (redirects.getEditRedirect, params)), |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
164 |
('rejected', (redirects.getEditRedirect, params)), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
165 |
('ignored', (redirects.getEditRedirect, params)),] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
166 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
167 |
return self._applicationListConstructor(request, params, page_name, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
168 |
filter=filter, selection=selection, **kwargs) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
169 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
170 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
171 |
def _applicationListConstructor(self, request, params, page_name, filter={}, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
172 |
selection=[], **kwargs): |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
173 |
"""Constructs the list containing applications for the given the arguments. |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
174 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
175 |
Args: |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
176 |
filter: This is the filter used for all application |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
177 |
selection: This is a list containing tuples stating the status for an |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
178 |
application and the redirect action. |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
179 |
See base.View.public() for the rest. |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
180 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
181 |
Returns: |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
182 |
HTTP Response containing the list view. |
1232
3bce6205e24e
Added pre-accpeted status to group_app.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1229
diff
changeset
|
183 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
184 |
""" |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
185 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
186 |
contents = [] |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
187 |
list_params = params.copy() |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
188 |
index = 0 |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
189 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
190 |
for choice in selection: |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
191 |
# only select the requests that have been pre-accpeted |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
192 |
filter['status'] = choice[0] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
193 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
194 |
list_params['list_description'] = ( |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
195 |
DEF_APPLICATION_LIST_DESCRIPTION_FMT % ( |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
196 |
{'name_plural': params['name_plural'], 'status': choice[0]})) |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
197 |
list_params['list_action'] = choice[1] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
198 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
199 |
list_content = list_helper.getListContent( |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
200 |
request, list_params, filter, index) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
201 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
202 |
contents += [list_content] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
203 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
204 |
index += 1 |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
205 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
206 |
# call the _list method from base to display the list |
1312
9b253b8e4d40
Fix a bug in group_app
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
207 |
if kwargs.get('context'): |
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
208 |
context = kwargs['context'] |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
209 |
else: |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
210 |
context = {} |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
211 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
212 |
return self._list(request, params, contents, page_name, context=context) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
213 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
214 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
215 |
@decorators.merge_params |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
216 |
@decorators.check_access |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
217 |
def listSelf(self, request, access_type, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
218 |
page_name=None, params=None, **kwargs): |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
219 |
"""List all applications from the current logged-in user. |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
220 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
221 |
For params see base.View.public(). |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
222 |
""" |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
223 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
224 |
user_entity = user_logic.logic.getForCurrentAccount() |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
225 |
filter = {'applicant' : user_entity} |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
226 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
227 |
if kwargs['scope_path']: |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
228 |
filter['scope_path'] = kwargs['scope_path'] |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
229 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
230 |
# create the selection list |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
231 |
selection=[('needs review',(redirects.getEditRedirect, params)), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
232 |
('accepted', (redirects.getApplicantRedirect, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
233 |
{'url_name': params['group_url_name']})), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
234 |
('rejected', (redirects.getEditRedirect, params))] |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
235 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
236 |
return self._applicationListConstructor(request, params, page_name, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
237 |
filter=filter, selection=selection, **kwargs) |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
238 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
239 |
@decorators.merge_params |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
240 |
@decorators.check_access |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
241 |
def review(self, request, access_type, |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
242 |
page_name=None, params=None, **kwargs): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
243 |
"""Handles the view containing the review of an application. |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
244 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
245 |
accepted (true or false) in the GET data will mark |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
246 |
the application accordingly. |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
247 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
248 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
249 |
For params see base.View.public(). |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
250 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
251 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
252 |
try: |
1218
569a3fe9cb88
Cleaned up getKeyNameFromFields in Logic base.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1217
diff
changeset
|
253 |
entity = self._logic.getFromKeyFieldsOr404(kwargs) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
254 |
except out_of_band.Error, error: |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
255 |
return helper.responses.errorResponse( |
1365
c31e06f66029
Fix a bug in group_app.py (not defined context was used).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1357
diff
changeset
|
256 |
error, request, template=params['error_public']) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
257 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
258 |
get_dict = request.GET |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
259 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
260 |
# check to see if we can make a decision for this application |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
261 |
if 'status' in get_dict.keys(): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
262 |
status_value = get_dict['status'] |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
263 |
|
1504
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
264 |
if status_value in ['accepted', 'rejected', 'ignored', 'pre-accepted', |
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
265 |
'pre-rejected']: |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
266 |
# this application has been properly reviewed update the status |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
267 |
|
1196
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
268 |
# only update if the status changes |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
269 |
if entity.status != status_value: |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
270 |
fields = {'status' : status_value} |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
271 |
|
1196
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
272 |
self._logic.updateEntityProperties(entity, fields) |
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
273 |
self._review(request, params, entity, status_value, **kwargs) |
1196
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
274 |
|
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
275 |
if status_value == 'accepted': |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
276 |
# the application has been accepted send out a notification |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1139
diff
changeset
|
277 |
notifications.sendNewGroupNotification(entity, params) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
278 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
279 |
# redirect to the review overview |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
280 |
fields = {'url_name': params['url_name']} |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
281 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
282 |
scope_path = entity.scope_path |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
283 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
284 |
if not scope_path: |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
285 |
scope_path = '' |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
286 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
287 |
# add scope_path to the dictionary |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
288 |
fields['scope_path'] = scope_path |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
289 |
|
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
290 |
return http.HttpResponseRedirect( |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
291 |
'/%(url_name)s/review_overview/%(scope_path)s' %fields) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
292 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
293 |
# the application has not been reviewed so show the information |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
294 |
# using the appropriate review template |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
295 |
params['public_template'] = params['review_template'] |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
296 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
297 |
return super(View, self).public(request, access_type, |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
298 |
page_name=page_name, params=params, **kwargs) |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
299 |
|
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
300 |
|
1296
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
301 |
def _review(self, request, params, app_entity, status, **kwargs): |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
302 |
"""Does any required post review processing. |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
303 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
304 |
Args: |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
305 |
request: the standard Django HTTP request object |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
306 |
params: a dict with params for this View |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
307 |
app_entity: The update application entity |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
308 |
status: The status that was given to the reviewed app_entity |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
309 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
310 |
""" |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
311 |
pass |
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
312 |
|
64918d0c97ea
Implemented the 2nd part of bulk acceptance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1290
diff
changeset
|
313 |
|
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
314 |
@decorators.merge_params |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
315 |
@decorators.check_access |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
316 |
def reviewOverview(self, request, access_type, |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
317 |
page_name=None, params=None, **kwargs): |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
318 |
"""Displays multiple lists of applications that are in a different |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
319 |
status of the application process. |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
320 |
""" |
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
321 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
322 |
selection = [('needs review',(redirects.getReviewRedirect, params)), |
1504
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
323 |
('pre-accepted', (redirects.getReviewRedirect, params)), |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
324 |
('accepted', (redirects.getReviewRedirect, params)), |
1504
f9d0bf275917
Add the ability to put GroupApplications into the pre-rejected state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1456
diff
changeset
|
325 |
('pre-rejected', (redirects.getReviewRedirect, params)), |
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
326 |
('rejected', (redirects.getReviewRedirect, params)), |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
327 |
('ignored', (redirects.getReviewRedirect, params)),] |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
328 |
|
1246
756fd7195213
Fixing r1855 that was bugged by Tortoise ^_^.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1244
diff
changeset
|
329 |
filter = {} |
756fd7195213
Fixing r1855 that was bugged by Tortoise ^_^.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1244
diff
changeset
|
330 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
331 |
if kwargs['scope_path']: |
1246
756fd7195213
Fixing r1855 that was bugged by Tortoise ^_^.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1244
diff
changeset
|
332 |
filter['scope_path'] = kwargs['scope_path'] |
1232
3bce6205e24e
Added pre-accpeted status to group_app.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1229
diff
changeset
|
333 |
|
1255
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
334 |
return self._applicationListConstructor(request, params, page_name, |
9fe8c6c54933
Redone the listing in group_app.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1253
diff
changeset
|
335 |
filter=filter, selection=selection, **kwargs) |
1138
18ef39338211
Refactored review and reviewoverview out of club_app.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
336 |