author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 25 Oct 2009 18:48:22 -0700 | |
changeset 3054 | 6ca30967d1bb |
parent 2782 | 3944749338d3 |
permissions | -rw-r--r-- |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
837
bc1c951bf3a0
Add missing blank line in soc.views.helper.params module. Fix docstring typo in soc.views.models.role module. Add missing dots at the end of sentences in soc.logic.cleaning and soc.view.models.user_self modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
755
diff
changeset
|
17 |
"""Views for Role profiles. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
] |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
1118
d2a2268b3227
When moving stuff please make sure that all your belongings are safely secured.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1116
diff
changeset
|
26 |
from django import forms |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
27 |
from django import http |
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
964
diff
changeset
|
28 |
from django.utils.translation import ugettext |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
|
1116
5a9d4c2d6748
Moved create_extra_dynafields from club_admin and member to role.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1115
diff
changeset
|
30 |
from soc.logic import cleaning |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
from soc.logic import dicts |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
32 |
from soc.logic.models import user as user_logic |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
33 |
from soc.logic.models.request import logic as request_logic |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
34 |
from soc.views.helper import decorators |
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
616
diff
changeset
|
35 |
from soc.views.helper import redirects |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
36 |
from soc.views.helper import responses |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
from soc.views.models import base |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
38 |
from soc.views.models import request as request_view |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
import soc.models.request |
646
860e17e5118f
Remove cyclic imports by moving response method of out_of_band.Error class to soc.views.helper.responses module as errorResponse function. Apply changes to affected files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
624
diff
changeset
|
41 |
import soc.views.helper.lists |
860e17e5118f
Remove cyclic imports by moving response method of out_of_band.Error class to soc.views.helper.responses module as errorResponse function. Apply changes to affected files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
624
diff
changeset
|
42 |
import soc.views.helper.responses |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
import soc.views.helper.widgets |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
|
1346
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
46 |
ROLE_VIEWS = {} |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
47 |
|
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
48 |
|
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
49 |
def addRole(view): |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
50 |
"""Adds the specified view to the known role views. |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
51 |
""" |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
52 |
|
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
53 |
global ROLE_VIEWS |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
54 |
params = view.getParams() |
2666
5de9eba17661
Use role_name from Role Logic as key to store the different Role Views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2656
diff
changeset
|
55 |
role_logic = params['logic'] |
5de9eba17661
Use role_name from Role Logic as key to store the different Role Views.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2656
diff
changeset
|
56 |
name = role_logic.role_name |
1346
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
57 |
ROLE_VIEWS[name] = view |
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
58 |
|
b3bbc6fa18ef
Keep a global list of all known Roles
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
59 |
|
657
c781de4f6d39
Rename role.RoleView to role.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
60 |
class View(base.View): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
495
diff
changeset
|
61 |
"""Views for all entities that inherit from Role. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
All views that only Role entities have are defined in this subclass. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
""" |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
65 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
964
diff
changeset
|
66 |
DEF_INVITE_INSTRUCTION_MSG_FMT = ugettext( |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
67 |
'Please use this form to invite someone to become a %s for %s.') |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
|
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
69 |
DEF_REQUEST_INSTRUCTION_MSG_FMT = ugettext( |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
70 |
'Please use this form to request to become a %s for %s.') |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
71 |
|
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
72 |
DEF_INVITE_ERROR_MSG_FMT = ugettext( |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
73 |
'This user can not receive an invite to become a %(name)s. <br/>' |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
74 |
'Please make sure there is no outstanding invite or request and ' |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
75 |
'be sure that this user is not a %(name)s.') |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
76 |
|
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
77 |
DEF_REQUEST_ERROR_MSG_FMT = ugettext( |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
78 |
'You can not request to become a %(name)s. <br/>' |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
79 |
'Please make sure there is no outstanding invite or request and ' |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
80 |
'be sure that you are not a %(name)s already.') |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
81 |
|
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
82 |
|
616
580b1c21b808
Fixed requests not working anymore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
572
diff
changeset
|
83 |
def __init__(self, params=None): |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
84 |
"""Defines the fields and methods required for the base View class |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
85 |
to provide the user with list, public, create, edit and delete views. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
Args: |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
654
diff
changeset
|
88 |
params: This dictionary should be filled with the parameters |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
90 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
91 |
new_params = {} |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
92 |
|
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
93 |
patterns = params.get('extra_django_patterns') |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
94 |
|
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
95 |
if not patterns: |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
96 |
patterns = [] |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
97 |
|
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
98 |
if params.get('allow_requests_and_invites'): |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
99 |
# add patterns concerning requests and invites |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
100 |
patterns += [(r'^%(url_name)s/(?P<access_type>invite)/%(scope)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
101 |
'%(module_package)s.%(module_name)s.invite', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
102 |
'Create invite for %(name)s'), |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
103 |
(r'^%(url_name)s/(?P<access_type>accept_invite)/(?P<id>[0-9]*)$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
104 |
'%(module_package)s.%(module_name)s.accept_invite', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
105 |
'Accept invite for %(name)s'), |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
106 |
(r'^%(url_name)s/(?P<access_type>process_request)/(?P<id>[0-9]*)$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
107 |
'%(module_package)s.%(module_name)s.process_request', |
2748
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
108 |
'Process request'), |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
109 |
(r'^%(url_name)s/(?P<access_type>request)/%(scope)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
110 |
'%(module_package)s.%(module_name)s.role_request', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
111 |
'Create a Request to become %(name)s')] |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
112 |
elif params.get('allow_invites'): |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
113 |
# add patterns concerning only invites |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
114 |
patterns += [(r'^%(url_name)s/(?P<access_type>invite)/%(scope)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
115 |
'%(module_package)s.%(module_name)s.invite', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
116 |
'Create invite for %(name)s'), |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
117 |
(r'^%(url_name)s/(?P<access_type>accept_invite)/(?P<id>[0-9]*)$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
118 |
'%(module_package)s.%(module_name)s.accept_invite', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
119 |
'Accept invite for %(name)s'), |
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
120 |
(r'^%(url_name)s/(?P<access_type>process_request)/%(scope)s/%(lnp)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
121 |
'%(module_package)s.%(module_name)s.process_request', |
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
122 |
'Process request for %(name)s')] |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
123 |
|
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
124 |
# add manage pattern |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
125 |
patterns += [(r'^%(url_name)s/(?P<access_type>manage)/%(scope)s/%(lnp)s$', |
2782
3944749338d3
Dotted path to the views in URL patterns is changed to a params parameter.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2759
diff
changeset
|
126 |
'%(module_package)s.%(module_name)s.manage', |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
127 |
'Manage a %(name)s'),] |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
128 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
129 |
new_params['extra_django_patterns'] = patterns |
663
c2dcae606699
Make base.View.create lookup the scope if appropriate
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
130 |
new_params['scope_redirect'] = redirects.getInviteRedirect |
1376
ee386b5b56d7
Parameterized the role view manage redirect.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1357
diff
changeset
|
131 |
new_params['manage_redirect'] = redirects.getListRolesRedirect |
1357
3dd1507aa723
Prepare all views for a new modular approach to JS loading
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1346
diff
changeset
|
132 |
|
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
133 |
new_params['create_template'] = 'soc/role/edit.html' |
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
134 |
new_params['edit_template'] = 'soc/role/edit.html' |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
135 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1384
diff
changeset
|
136 |
new_params['create_extra_dynaproperties'] = { |
1175
b39345efab20
Make longitude and latitude hidden fields not required in soc.views.models.role module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1152
diff
changeset
|
137 |
'latitude':forms.fields.FloatField(widget=forms.HiddenInput, |
1176
c211191e7d81
Fixed access related bugs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1175
diff
changeset
|
138 |
required=False), |
1175
b39345efab20
Make longitude and latitude hidden fields not required in soc.views.models.role module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1152
diff
changeset
|
139 |
'longitude': forms.fields.FloatField(widget=forms.HiddenInput, |
1176
c211191e7d81
Fixed access related bugs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1175
diff
changeset
|
140 |
required=False), |
2656
25210120d67b
Added validation to email fields where needed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2361
diff
changeset
|
141 |
'email': forms.fields.EmailField(required=True), |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
142 |
'clean_link_id': cleaning.clean_existing_user('link_id'), |
2759
5a8bd9d7725c
Set ASCII-only cleaner for first and last name when dealing with roles.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2748
diff
changeset
|
143 |
'clean_given_name': cleaning.clean_ascii_only('given_name'), |
5a8bd9d7725c
Set ASCII-only cleaner for first and last name when dealing with roles.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2748
diff
changeset
|
144 |
'clean_surname': cleaning.clean_ascii_only('surname'), |
1990
fea8bdb43992
Automagically convert '+' to '00' in phone numbers
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1963
diff
changeset
|
145 |
'clean_phone': cleaning.clean_phone_number('phone'), |
1722
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
146 |
'clean_res_street': cleaning.clean_ascii_only('res_street'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
147 |
'clean_res_city': cleaning.clean_ascii_only('res_city'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
148 |
'clean_res_state': cleaning.clean_ascii_only('res_state'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
149 |
'clean_res_postalcode': cleaning.clean_ascii_only('res_postalcode'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
150 |
'clean_ship_street': cleaning.clean_ascii_only('ship_street'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
151 |
'clean_ship_city': cleaning.clean_ascii_only('ship_city'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
152 |
'clean_ship_state': cleaning.clean_ascii_only('ship_state'), |
7f285e96cb17
All address fields for roles and groups can now only use characters that can successfully be converted to ASCII.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1660
diff
changeset
|
153 |
'clean_ship_postalcode': cleaning.clean_ascii_only('ship_postalcode'), |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
154 |
'clean_home_page': cleaning.clean_url('home_page'), |
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
155 |
'clean_blog': cleaning.clean_url('blog'), |
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
156 |
'clean_photo_url': cleaning.clean_url('photo_url'), |
1116
5a9d4c2d6748
Moved create_extra_dynafields from club_admin and member to role.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1115
diff
changeset
|
157 |
'scope_path': forms.CharField(widget=forms.HiddenInput, |
5a9d4c2d6748
Moved create_extra_dynafields from club_admin and member to role.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1115
diff
changeset
|
158 |
required=True), |
5a9d4c2d6748
Moved create_extra_dynafields from club_admin and member to role.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1115
diff
changeset
|
159 |
} |
5a9d4c2d6748
Moved create_extra_dynafields from club_admin and member to role.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1115
diff
changeset
|
160 |
|
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
161 |
new_params['extra_dynaexclude'] = ['user', 'status', 'agreed_to_tos_on'] |
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1067
diff
changeset
|
162 |
|
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1067
diff
changeset
|
163 |
params = dicts.merge(params, new_params, sub_merge=True) |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
657
diff
changeset
|
164 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
654
diff
changeset
|
165 |
super(View, self).__init__(params=params) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
166 |
|
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
167 |
# add manage template |
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2076
diff
changeset
|
168 |
template = 'soc/%(module_name)s/manage.html' % self._params |
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2076
diff
changeset
|
169 |
self._params['manage_template'] = template |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
170 |
|
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2076
diff
changeset
|
171 |
if self._params.get('show_in_roles_overview'): |
1384
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1376
diff
changeset
|
172 |
# add to roles overview |
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1376
diff
changeset
|
173 |
addRole(self) |
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1376
diff
changeset
|
174 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
175 |
@decorators.merge_params |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
176 |
@decorators.check_access |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
708
diff
changeset
|
177 |
def invite(self, request, access_type, |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
178 |
page_name=None, params=None, **kwargs): |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
179 |
"""Creates the page on which an invite can be send out. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
180 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
181 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
182 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
183 |
access_type : the name of the access type which should be checked |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
184 |
context: dictionary containing the context for this view |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
185 |
params: a dict with params for this View |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
186 |
kwargs: the Key Fields for the specified entity |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
187 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
188 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
189 |
# get the context for this webpage |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
190 |
context = responses.getUniversalContext(request) |
1357
3dd1507aa723
Prepare all views for a new modular approach to JS loading
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1346
diff
changeset
|
191 |
responses.useJavaScript(context, params['js_uses_all']) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
192 |
context['page_name'] = page_name |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
193 |
|
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
194 |
group_entity = params['group_logic'].getFromKeyName(kwargs['scope_path']) |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
195 |
|
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
196 |
context['instruction_message'] = (self.DEF_INVITE_INSTRUCTION_MSG_FMT % |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
197 |
(params['name'], group_entity.name)) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
198 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
199 |
if request.method == 'POST': |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
200 |
return self.invitePost(request, context, params, group_entity, **kwargs) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
201 |
else: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
202 |
# request.method == 'GET' |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
203 |
return self.inviteGet(request, context, params, **kwargs) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
204 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
205 |
def inviteGet(self, request, context, params, **kwargs): |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
206 |
"""Handles the GET request concerning the view that creates an invite |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
207 |
for attaining a certain Role. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
208 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
209 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
210 |
request: the standard Django HTTP request object |
959
b6e8750c9407
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
952
diff
changeset
|
211 |
context: dictionary containing the context for this view |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
212 |
params: a dict with params for this View |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
213 |
kwargs: the Key Fields for the specified entity |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
214 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
215 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
216 |
# get the request view parameters and initialize the invite form |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
217 |
request_params = request_view.view.getParams() |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
218 |
form = request_params['invite_form']() |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
219 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
220 |
# construct the appropriate response |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
221 |
return super(View, self)._constructResponse(request, entity=None, |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
222 |
context=context, form=form, params=request_params) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
223 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
224 |
def invitePost(self, request, context, params, group_entity, **kwargs): |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
225 |
"""Handles the POST request concerning the view that creates an invite |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
226 |
for attaining a certain Role. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
227 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
228 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
229 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
230 |
page_name: the page name displayed in templates as page and header title |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
231 |
params: a dict with params for this View |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
232 |
group_entity: Group entity which this invite is from |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
233 |
kwargs: the Key Fields for the specified entity |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
234 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
235 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
236 |
# get the request view parameters and populate the form using POST data |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
237 |
request_params = request_view.view.getParams() |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
238 |
form = request_params['invite_form'](request.POST) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
239 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
240 |
if not form.is_valid(): |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
241 |
# return the invalid form response |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
242 |
return self._constructResponse(request, entity=None, context=context, |
1195
cbef45d75942
Fixed a bug where a GMAP error message would be displayed when the form was not valid.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1176
diff
changeset
|
243 |
form=form, params=request_params) |
708
89f1a8c2ea59
Some cleanups in role.py and site.py and create()
Sverre Rabbelier <srabbelier@gmail.com>
parents:
668
diff
changeset
|
244 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
245 |
# collect the cleaned data from the valid form |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
246 |
_, form_fields = soc.views.helper.forms.collectCleanedFields(form) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
247 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
248 |
# create the fields for the new request entity |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
249 |
request_fields = { |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
250 |
'user': form_fields['user_id'], |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
251 |
'group': group_entity, |
2668
7fd0951332ef
Use role_name where needed for creating/handling requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2666
diff
changeset
|
252 |
'role': params['logic'].role_name, |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
253 |
'status': 'group_accepted'} |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
254 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
255 |
if not request_logic.isValidNewRequest(request_fields, params['logic']): |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
256 |
# not a valid invite |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
257 |
context['error_message'] = self.DEF_INVITE_ERROR_MSG_FMT % ( |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
258 |
params) |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
259 |
return super(View, self)._constructResponse(request, entity=None, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
260 |
context=context, form=form, params=request_params) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
261 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
262 |
# create the request entity |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
263 |
request_logic.updateOrCreateFromFields(request_fields) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
264 |
|
990
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
265 |
group_view = params.get('group_view') |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
266 |
|
990
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
267 |
if not group_view: |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
268 |
return http.HttpResponseRedirect('/') |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
269 |
else: |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
270 |
# redirect to the requests list |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
271 |
return http.HttpResponseRedirect( |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
272 |
redirects.getListRequestsRedirect(group_entity, group_view.getParams())) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
273 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
274 |
@decorators.merge_params |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
275 |
@decorators.check_access |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
276 |
def acceptInvite(self, request, access_type, |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
277 |
page_name=None, params=None, **kwargs): |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
278 |
"""Creates the page process an invite into a Role. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
279 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
280 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
281 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
282 |
access_type : the name of the access type which should be checked |
959
b6e8750c9407
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
952
diff
changeset
|
283 |
page_name: the page name displayed in templates as page and header title |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
284 |
params: a dict with params for this View |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
285 |
kwargs: contains the ID for the Request entity |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
286 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
287 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
288 |
request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
289 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
290 |
# get the context for this webpage |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
291 |
context = responses.getUniversalContext(request) |
1357
3dd1507aa723
Prepare all views for a new modular approach to JS loading
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1346
diff
changeset
|
292 |
responses.useJavaScript(context, params['js_uses_all']) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
293 |
context['page_name'] = page_name |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
294 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
295 |
if request.method == 'POST': |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
296 |
return self.acceptInvitePost(request, context, params, request_entity, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
297 |
**kwargs) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
298 |
else: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
299 |
# request.method == 'GET' |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
300 |
return self.acceptInviteGet(request, context, params, request_entity, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
301 |
**kwargs) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
302 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
303 |
def acceptInviteGet(self, request, context, params, request_entity, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
304 |
**kwargs): |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
305 |
"""Handles the GET request concerning the creation of a Role via an |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
306 |
invite. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
307 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
308 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
309 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
310 |
context: dictionary containing the context for this view |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
311 |
params: a dict with params for this View |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
312 |
request_entity: Request that is being accepted |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
313 |
kwargs: contains the ID for the Request entity |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
314 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
315 |
|
959
b6e8750c9407
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
952
diff
changeset
|
316 |
# create the form using the scope_path and link_id from kwargs |
b6e8750c9407
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
952
diff
changeset
|
317 |
# as initial value |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
318 |
fields = {'link_id': request_entity.user.link_id, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
319 |
'scope_path': request_entity.group.key().id_or_name()} |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
320 |
form = params['invited_create_form'](initial=fields) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
321 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
322 |
# construct the appropriate response |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
323 |
return super(View, self)._constructResponse(request, entity=None, |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
324 |
context=context, form=form, params=params) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
325 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
326 |
def acceptInvitePost(self, request, context, params, request_entity, **kwargs): |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
327 |
"""Handles the POST request concerning the creation of a Role via an |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
328 |
invite. |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
329 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
330 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
331 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
332 |
context: dictionary containing the context for this view |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
333 |
params: a dict with params for this View |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
334 |
request_entity: Request that is being accepted |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
335 |
kwargs: contains the ID for the Request entity |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
336 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
337 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
338 |
# populate the form using the POST data |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
339 |
form = params['invited_create_form'](request.POST) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
340 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
341 |
if not form.is_valid(): |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
342 |
# return the invalid form response |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
343 |
return self._constructResponse(request, entity=None, context=context, |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
344 |
form=form, params=params) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
345 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
346 |
# collect the cleaned data from the valid form |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
347 |
key_name, fields = soc.views.helper.forms.collectCleanedFields(form) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
348 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
349 |
# set the user and link_id fields to the right property |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
350 |
fields['user'] = request_entity.user |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
351 |
fields['link_id'] = request_entity.user.link_id |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
352 |
fields['scope'] = request_entity.group |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
353 |
fields['scope_path'] = request_entity.group.key().id_or_name() |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
354 |
# make sure that this role becomes active once more in case this user |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
355 |
# has been reinvited |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
356 |
fields ['status'] = 'active' |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
357 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
358 |
# call the post process method |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
359 |
self._acceptInvitePost(fields, request, context, params, **kwargs) |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
360 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
361 |
# get the key_name for the new entity |
1218
569a3fe9cb88
Cleaned up getKeyNameFromFields in Logic base.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1196
diff
changeset
|
362 |
key_name = self._logic.getKeyNameFromFields(fields) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
363 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
364 |
# create new Role entity |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
365 |
entity = self._logic.updateOrCreateFromKeyName(fields, key_name) |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
366 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
367 |
# mark the request as completed |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
368 |
request_fields = {'status': 'completed'} |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
369 |
request_logic.updateEntityProperties(request_entity, request_fields) |
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
370 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
371 |
# redirect to the roles overview page |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
372 |
return http.HttpResponseRedirect('/user/roles') |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
373 |
|
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
374 |
def _acceptInvitePost(self, fields, request, context, params, **kwargs): |
959
b6e8750c9407
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
952
diff
changeset
|
375 |
"""Used to post-process data after the fields have been cleaned. |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
376 |
|
944
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
377 |
Args: |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
378 |
fields : the cleaned fields from the role form |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
379 |
request: the standard Django HTTP request object |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
380 |
context: dictionary containing the context for this view |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
381 |
params: a dict with params for this View |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
382 |
kwargs: the Key Fields for the specified entity |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
383 |
""" |
5ea2bd9e3fa6
Refactored invite system from club_admin to role to make the system work with host as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
908
diff
changeset
|
384 |
pass |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
385 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
386 |
@decorators.merge_params |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
387 |
@decorators.check_access |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
388 |
def manage(self, request, access_type, |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
389 |
page_name=None, params=None, **kwargs): |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
390 |
"""Handles the request concerning the view that let's |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
391 |
you manage a role's status. |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
392 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
393 |
Args: |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
394 |
request: the standard Django HTTP request object |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
395 |
page_name: the page name displayed in templates as page and header title |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
396 |
params: a dict with params for this View |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
397 |
kwargs: the Key Fields for the specified entity |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
398 |
""" |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
399 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
400 |
# get the context for this webpage |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
401 |
context = responses.getUniversalContext(request) |
1357
3dd1507aa723
Prepare all views for a new modular approach to JS loading
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1346
diff
changeset
|
402 |
responses.useJavaScript(context, params['js_uses_all']) |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
403 |
context['page_name'] = page_name |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
404 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
405 |
logic = params['logic'] |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
406 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
407 |
# get the entity for the given fields in kwargs |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
408 |
fields = {'scope_path': kwargs['scope_path'], |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
409 |
'link_id': kwargs['link_id']} |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
410 |
role_entity = logic.getForFields(kwargs, unique=True) |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
411 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
412 |
# get the redirect for the cancel button or when the resignation is done |
1376
ee386b5b56d7
Parameterized the role view manage redirect.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1357
diff
changeset
|
413 |
redirect = params['manage_redirect'](role_entity.scope, |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
414 |
params['group_view'].getParams()) |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
415 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
416 |
# check to see if resign is true |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
417 |
get_dict = request.GET |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
418 |
resign = get_dict.get('resign') |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
419 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
420 |
if resign == 'true': |
1730
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
421 |
|
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1948
diff
changeset
|
422 |
resign_error = params['logic'].canResign(role_entity) |
1730
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
423 |
|
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1948
diff
changeset
|
424 |
if not resign_error: |
1730
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
425 |
# change the status of this role_entity to invalid |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
426 |
fields = {'status': 'invalid'} |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
427 |
logic.updateEntityProperties(role_entity, fields) |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
428 |
|
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
429 |
# redirect to the roles listing |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
430 |
return http.HttpResponseRedirect(redirect) |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
431 |
else: |
2d877bb10306
Important roles can now not resign if they are the last in their group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1723
diff
changeset
|
432 |
# show error to the user |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1948
diff
changeset
|
433 |
context['resign_error'] = ugettext(resign_error %params) |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
434 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
435 |
# set the appropriate context |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
436 |
context['entity'] = role_entity |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
437 |
context['url_name'] = params['url_name'] |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
438 |
context['cancel_redirect'] = redirect |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
439 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
440 |
# get the manage template |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
441 |
template = params['manage_template'] |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
442 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
443 |
# return a proper response |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
444 |
return responses.respond(request, template, context=context) |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
445 |
|
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
446 |
@decorators.merge_params |
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
447 |
@decorators.check_access |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
448 |
def request(self, request, access_type, |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
449 |
page_name=None, params=None, **kwargs): |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
450 |
"""Handles the request concerning the view that creates a request |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
451 |
for attaining a certain Role. |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
452 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
453 |
Args: |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
454 |
request: the standard Django HTTP request object |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
455 |
page_name: the page name displayed in templates as page and header title |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
456 |
params: a dict with params for this View |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
457 |
kwargs: the Key Fields for the specified entity |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
458 |
""" |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
459 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
460 |
# get the context for this webpage |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
461 |
context = responses.getUniversalContext(request) |
1357
3dd1507aa723
Prepare all views for a new modular approach to JS loading
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1346
diff
changeset
|
462 |
responses.useJavaScript(context, params['js_uses_all']) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
463 |
context['page_name'] = page_name |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
464 |
|
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
465 |
group_entity = params['group_logic'].getFromKeyName(kwargs['scope_path']) |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
466 |
|
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
467 |
context['instruction_message'] = (self.DEF_REQUEST_INSTRUCTION_MSG_FMT % |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
468 |
(params['name'], group_entity.name)) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
469 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
470 |
if request.method == 'POST': |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
471 |
return self.requestPost(request, context, params, group_entity, **kwargs) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
472 |
else: |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
473 |
# request.method == 'GET' |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
474 |
return self.requestGet(request, context, params, **kwargs) |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
475 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
476 |
def requestGet(self, request, context, params, **kwargs): |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
477 |
"""Handles the GET request concerning the creation of a request |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
478 |
to attain a role. |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
479 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
480 |
Args: |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
481 |
request: the standard Django HTTP request object |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
482 |
context: dictionary containing the context for this view |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
483 |
params: a dict with params for this View |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
484 |
kwargs: the Key Fields for the specified entity |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
485 |
""" |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
486 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
487 |
# get the request view parameters and initialize the create form |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
488 |
request_params = request_view.view.getParams() |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
489 |
form = request_params['request_form']() |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
490 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
491 |
# construct the appropriate response |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
492 |
return super(View, self)._constructResponse(request, entity=None, |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
493 |
context=context, form=form, params=request_params) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
494 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
495 |
def requestPost(self, request, context, params, group_entity, **kwargs): |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
496 |
"""Handles the POST request concerning the creation of a request |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
497 |
to attain a role. |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
498 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
499 |
Args: |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
500 |
request: the standard Django HTTP request object |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
501 |
context: dictionary containing the context for this view |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
502 |
params: a dict with params for this View |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
503 |
group_entity: the Group entity this request is for |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
504 |
kwargs: the Key Fields for the specified entity |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
505 |
""" |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
506 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
507 |
# get the request view parameters and populate the form using POST data |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
508 |
request_params = request_view.view.getParams() |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
509 |
form = request_params['request_form'](request.POST) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
510 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
511 |
if not form.is_valid(): |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
512 |
# return the invalid form response |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
513 |
return self._constructResponse(request, entity=None, context=context, |
1195
cbef45d75942
Fixed a bug where a GMAP error message would be displayed when the form was not valid.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1176
diff
changeset
|
514 |
form=form, params=request_params) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
515 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
516 |
_, fields = soc.views.helper.forms.collectCleanedFields(form) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
517 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
518 |
# set the fields for the new request |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
519 |
user_entity = user_logic.logic.getForCurrentAccount() |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
520 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
521 |
request_fields = { |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
522 |
'user': user_entity, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
523 |
'group' : group_entity, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
524 |
'message': fields['message'], |
2668
7fd0951332ef
Use role_name where needed for creating/handling requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2666
diff
changeset
|
525 |
'role' : params['logic'].role_name, |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
526 |
'status' : 'new'} |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
527 |
|
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
528 |
if not request_logic.isValidNewRequest(request_fields, params['logic']): |
1084
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
529 |
# not a valid request |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
530 |
context['error_message'] = self.DEF_REQUEST_ERROR_MSG_FMT % ( |
9c4221f7b747
Requests can now not be created when you already have a similar request or already have the role the request is for.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
531 |
params) |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
532 |
return super(View, self)._constructResponse(request, entity=None, |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
533 |
context=context, form=form, params=request_params) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
534 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
535 |
# create the request entity |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
536 |
request_logic.updateOrCreateFromFields(request_fields) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
537 |
|
1947
af360d1017df
Fixed redirect after creating/rejecting a request/invite.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1937
diff
changeset
|
538 |
# redirect to requests overview |
af360d1017df
Fixed redirect after creating/rejecting a request/invite.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1937
diff
changeset
|
539 |
return http.HttpResponseRedirect('/user/requests') |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
540 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
541 |
@decorators.merge_params |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
542 |
@decorators.check_access |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
543 |
def processRequest(self, request, access_type, |
1152
b82caf7bb17c
Add Google Maps integration for Role profiles create/edit views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1129
diff
changeset
|
544 |
page_name=None, params=None, **kwargs): |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
545 |
"""Creates the page upon which a request can be processed. |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
546 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
547 |
Args: |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
548 |
request: the standard Django HTTP request object |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
549 |
access_type : the name of the access type which should be checked |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
550 |
page_name: the page name displayed in templates as page and header title |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
551 |
params: a dict with params for this View |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
552 |
kwargs: the Key Fields for the specified entity |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
553 |
""" |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
554 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
555 |
# get the request entity using the information from kwargs |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
556 |
request_entity = request_logic.getFromIDOr404(int(kwargs['id'])) |
1756
0a332ff872bf
The process_request template now properly differentiate between a request in "new" and "group_accepted" state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1730
diff
changeset
|
557 |
|
2748
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
558 |
# get the context for this webpage |
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
559 |
context = responses.getUniversalContext(request) |
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
560 |
responses.useJavaScript(context, params['js_uses_all']) |
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
561 |
|
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
562 |
context['page_name'] = '%s from %s to become a %s' %( |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
563 |
page_name, request_entity.user.name, params['name']) |
2748
7fbc98f3adde
Updated several page titles to contain more information.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2678
diff
changeset
|
564 |
|
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
565 |
get_dict = request.GET |
1756
0a332ff872bf
The process_request template now properly differentiate between a request in "new" and "group_accepted" state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1730
diff
changeset
|
566 |
|
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
567 |
if 'status' in get_dict.keys(): |
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
568 |
if get_dict['status'] in ['group_accepted', 'rejected', 'ignored']: |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
569 |
# update the request_entity and redirect away from this page |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1084
diff
changeset
|
570 |
request_status = get_dict['status'] |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
571 |
|
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:
1195
diff
changeset
|
572 |
# only update when the status is changing |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1195
diff
changeset
|
573 |
if request_status != request_entity.status: |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
574 |
request_logic.updateEntityProperties(request_entity, { |
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:
1195
diff
changeset
|
575 |
'status': get_dict['status']}) |
11dbdf12d7c2
Only do the update routine when the status changes for group_app's and role requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1195
diff
changeset
|
576 |
|
990
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
577 |
group_view = params.get('group_view') |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
578 |
if not group_view: |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
579 |
return http.HttpResponseRedirect('/') |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
580 |
else: |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
581 |
# redirect to the requests list |
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
582 |
return http.HttpResponseRedirect( |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
583 |
redirects.getListRequestsRedirect(request_entity.group, |
990
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
584 |
group_view.getParams())) |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
585 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
586 |
# put the entity in the context |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
587 |
context['entity'] = request_entity |
1756
0a332ff872bf
The process_request template now properly differentiate between a request in "new" and "group_accepted" state.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1730
diff
changeset
|
588 |
context['request_status'] = request_entity.status |
3054
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
589 |
context['role_verbose'] = params['name'] |
6ca30967d1bb
Made changes to the Role View to facilitate the use of the ID-based Requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2782
diff
changeset
|
590 |
context['url_name'] = params['url_name'] |
962
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
591 |
|
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
592 |
#display the request processing page using the appropriate template |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
593 |
template = request_view.view.getParams()['request_processing_template'] |
606871fda11c
Added request creation and processing to role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
959
diff
changeset
|
594 |
|
963
24c0a9da6360
Parameterized patterns in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
962
diff
changeset
|
595 |
return responses.respond(request, template, context=context) |