author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 22 Jan 2009 16:04:48 +0000 | |
changeset 901 | d580a057103d |
parent 896 | 445f3e8a44d9 |
child 907 | 3786030d5952 |
permissions | -rw-r--r-- |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Clubs. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
800
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
] |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
from google.appengine.api import users |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
27 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
28 |
from django import http |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
from django import forms |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
from soc.logic import dicts |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic.models import user as user_logic |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
878
diff
changeset
|
33 |
from soc.logic.models import club_app as club_app_logic |
800
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
34 |
from soc.logic.models import club as club_logic |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
35 |
from soc.views import out_of_band |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
800
diff
changeset
|
36 |
from soc.views.helper import access |
878
fdfab50cc9df
Fix trailing whitespace and apply decorators
Sverre Rabbelier <srabbelier@gmail.com>
parents:
877
diff
changeset
|
37 |
from soc.views.helper import decorators |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
38 |
from soc.views.helper import dynaform |
896
445f3e8a44d9
Fixed import sorting and indentation in soc/views/models/club.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
884
diff
changeset
|
39 |
from soc.views.helper import responses |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
from soc.views.helper import widgets |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
from soc.views.models import base |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
import soc.logic.models.club |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
44 |
import soc.views.helper |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
class View(base.View): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
"""View methods for the Club model. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
49 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
def __init__(self, params=None): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
"""Defines the fields and methods required for the base View class |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
to provide the user with list, public, create, edit and delete views. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
Params: |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
params: a dict with params for this View |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
|
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
800
diff
changeset
|
59 |
rights = {} |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
60 |
rights['create'] = [access.checkIsHost] |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
61 |
rights['edit'] = [access.checkIsClubAdminForClub] |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
878
diff
changeset
|
62 |
rights['delete'] = [access.checkIsHost] |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
878
diff
changeset
|
63 |
rights['list'] = [access.checkIsHost] |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
64 |
rights['applicant'] = [access.checkIsApplicationAccepted(club_app_logic)] |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
800
diff
changeset
|
65 |
|
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
66 |
new_params = {} |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
new_params['logic'] = soc.logic.models.club.logic |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
800
diff
changeset
|
68 |
new_params['rights'] = rights |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
69 |
new_params['name'] = "Club" |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
70 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
71 |
patterns = [] |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
73 |
page_name = "Club Creation via Accepted Application" |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
74 |
patterns += [(r'^%(url_name)s/(?P<access_type>applicant)/%(key_fields)s$', |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
75 |
'soc.views.models.%(module_name)s.applicant', page_name)] |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
76 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
77 |
new_params['extra_django_patterns'] = patterns |
799
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
790
diff
changeset
|
78 |
|
846
65daaf006399
Remove member_template from extra_dynaexclude in soc.views.models.club since member_template is only available in Organization as of recent commit.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
814
diff
changeset
|
79 |
new_params['extra_dynaexclude'] = ['founder', 'home'] |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
80 |
new_params['edit_extra_dynafields'] = { |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
'founded_by': forms.CharField(widget=widgets.ReadOnlyInput(), |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
82 |
required=False), |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
} |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
84 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
85 |
params = dicts.merge(params, new_params) |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
86 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
87 |
super(View, self).__init__(params=params) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
88 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
89 |
# create and store the special form for applicants |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
90 |
updated_fields = { |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
91 |
'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
92 |
required=False)} |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
93 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
94 |
applicant_create_form = dynaform.extendDynaForm( |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
95 |
dynaform = self._params['create_form'], |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
96 |
dynafields = updated_fields) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
97 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
98 |
params['applicant_create_form'] = applicant_create_form |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
99 |
|
878
fdfab50cc9df
Fix trailing whitespace and apply decorators
Sverre Rabbelier <srabbelier@gmail.com>
parents:
877
diff
changeset
|
100 |
@decorators.merge_params |
fdfab50cc9df
Fix trailing whitespace and apply decorators
Sverre Rabbelier <srabbelier@gmail.com>
parents:
877
diff
changeset
|
101 |
@decorators.check_access |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
102 |
def applicant(self, request, access_type, |
896
445f3e8a44d9
Fixed import sorting and indentation in soc/views/models/club.py
Lennard de Rijk <ljvderijk@gmail.com>
parents:
884
diff
changeset
|
103 |
page_name=None, params=None, **kwargs): |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
104 |
"""Handles the creation of a club via an approved club application. |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
105 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
106 |
Args: |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
107 |
request: the standard Django HTTP request object |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
108 |
page_name: the page name displayed in templates as page and header title |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
109 |
params: a dict with params for this View |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
110 |
kwargs: the Key Fields for the specified entity |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
111 |
""" |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
112 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
113 |
# get the context for this webpage |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
114 |
context = responses.getUniversalContext(request) |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
115 |
context['page_name'] = page_name |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
116 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
117 |
if request.method == 'POST': |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
118 |
return self.applicantPost(request, context, params, **kwargs) |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
119 |
else: |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
120 |
# request.method == 'GET' |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
121 |
return self.applicantGet(request, context, params, **kwargs) |
800
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
122 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
123 |
def applicantGet(self, request, context, params, **kwargs): |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
124 |
"""Handles the GET request concerning the creation of a club via an |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
125 |
approved club application. |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
126 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
127 |
Args: |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
128 |
request: the standard Django HTTP request object |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
129 |
context: dictionary containing the context for this view |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
130 |
params: a dict with params for this View |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
131 |
kwargs: the Key Fields for the specified entity |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
132 |
""" |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
133 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
134 |
# find the application |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
878
diff
changeset
|
135 |
key_fields = club_app_logic.logic.getKeyFieldsFromDict(kwargs) |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
878
diff
changeset
|
136 |
application = club_app_logic.logic.getFromFields(**key_fields) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
137 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
138 |
# extract the application fields |
800
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
139 |
field_names = application.properties().keys() |
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
140 |
fields = dict( [(i, getattr(application, i)) for i in field_names] ) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
141 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
142 |
# create the form using the fields from the application as the initial value |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
143 |
form = params['applicant_create_form'](initial=fields) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
144 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
145 |
# construct the appropriate response |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
146 |
return super(View, self)._constructResponse(request, entity=None, |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
147 |
context=context, form=form, params=params) |
800
738f6335b0e2
Added a create method that uses an existing application
Sverre Rabbelier <srabbelier@gmail.com>
parents:
799
diff
changeset
|
148 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
149 |
def applicantPost(self, request, context, params, **kwargs): |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
150 |
"""Handles the POST request concerning the creation of a club via an |
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
151 |
approved club application. |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
152 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
153 |
Args: |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
154 |
request: the standard Django HTTP request object |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
155 |
context: dictionary containing the context for this view |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
156 |
params: a dict with params for this View |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
157 |
kwargs: the Key Fields for the specified entity |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
158 |
""" |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
159 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
160 |
# populate the form using the POST data |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
161 |
form = params['applicant_create_form'](request.POST) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
162 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
163 |
if not form.is_valid(): |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
164 |
# return the invalid form response |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
165 |
return self._constructResponse(request, entity=None, context=context, |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
166 |
form=form, params=params) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
167 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
168 |
# collect the cleaned data from the valid form |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
169 |
key_name, fields = soc.views.helper.forms.collectCleanedFields(form) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
170 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
171 |
# fill in the founder of the club |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
172 |
account = users.get_current_user() |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
173 |
user = user_logic.logic.getForFields({'account': account}, unique=True) |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
174 |
fields['founder'] = user |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
175 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
176 |
if not key_name: |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
177 |
key_fields = self._logic.getKeyFieldsFromDict(fields) |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
178 |
key_name = self._logic.getKeyNameForFields(key_fields) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
179 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
180 |
# create the club entity |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
181 |
entity = self._logic.updateOrCreateFromKeyName(fields, key_name) |
877
b2575da44c36
Fix whitespace damage
Sverre Rabbelier <srabbelier@gmail.com>
parents:
869
diff
changeset
|
182 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
183 |
# redirect to notifications list to see the admin invite |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
184 |
return http.HttpResponseRedirect('/notification/list') |
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
185 |
|
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
186 |
def _editGet(self, request, entity, form): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
187 |
"""See base.View._editGet(). |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
188 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
189 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
190 |
# fill in the founded_by with data from the entity |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
191 |
form.fields['founded_by'].initial = entity.founder.name |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
192 |
super(View, self)._editGet(request, entity, form) |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
193 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
194 |
def _editPost(self, request, entity, fields): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
195 |
"""See base.View._editPost(). |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
196 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
197 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
198 |
if not entity: |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
199 |
# only if we are creating a new entity we should fill in founder |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
200 |
account = users.get_current_user() |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
201 |
user = user_logic.logic.getForFields({'account': account}, unique=True) |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
202 |
fields['founder'] = user |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
203 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
204 |
super(View, self)._editPost(request, entity, fields) |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
205 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
206 |
|
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
207 |
view = View() |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
208 |
|
869
cd17698846ce
Added a new view to help with application -> group process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
858
diff
changeset
|
209 |
applicant = view.applicant |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
210 |
create = view.create |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
211 |
delete = view.delete |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
212 |
edit = view.edit |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
213 |
list = view.list |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
214 |
public = view.public |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
846
diff
changeset
|
215 |
export = view.export |
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
846
diff
changeset
|
216 |