author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 22 Nov 2008 23:08:26 +0000 | |
changeset 572 | 1b3e7280743a |
parent 569 | 96d9655a7538 |
child 586 | a4a36b06a870 |
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 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
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 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Requests. |
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>', |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
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 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
from google.appengine.api import users |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from django import forms |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
from django.utils.translation import ugettext_lazy |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import dicts |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
from soc.logic import validate |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic.models import sponsor as sponsor_logic |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
from soc.logic.models import user as user_logic |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
from soc.views import helper |
557 | 37 |
from soc.views import out_of_band |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
from soc.views.helper import widgets |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
from soc.views.models import base |
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
40 |
from soc.views.models import role as role_view |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
import soc.models.request |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
import soc.logic.models.request |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
import soc.logic.dicts |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
import soc.views.helper |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
import soc.views.helper.widgets |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
495
diff
changeset
|
48 |
|
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
class CreateForm(helper.forms.BaseForm): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
"""Django form displayed when Developer creates a Request. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
class Meta: |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
model = soc.models.request.Request |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
#: list of model fields which will *not* be gathered by the form |
569
96d9655a7538
Remove inheritance_line from Form meta class excludes in all currently used forms.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
562
diff
changeset
|
57 |
exclude = ['scope', 'scope_path', 'link_id', 'role', 'declined'] |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
role = forms.CharField(widget=helper.widgets.ReadOnlyInput()) |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
user = forms.CharField( |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
62 |
label=soc.models.request.Request.link_id.verbose_name, |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
63 |
help_text=soc.models.request.Request.link_id.help_text, |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
64 |
widget=helper.widgets.ReadOnlyInput()) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
group = forms.CharField( |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
67 |
label=soc.models.request.Request.scope.verbose_name, |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
68 |
help_text=soc.models.request.Request.scope.help_text, |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
widget=helper.widgets.ReadOnlyInput()) |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
def clean_user(self): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
self.cleaned_data['requester'] = user_logic.logic.getForFields( |
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
507
diff
changeset
|
73 |
{'link_id': self.cleaned_data['user']}, unique=True) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
return self.cleaned_data['user'] |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
def clean_group(self): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
self.cleaned_data['to'] = sponsor_logic.logic.getFromFields( |
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
507
diff
changeset
|
78 |
link_id=self.cleaned_data['group']) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
return self.cleaned_data['group'] |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
|
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
495
diff
changeset
|
81 |
|
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
class EditForm(CreateForm): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
"""Django form displayed when Developer edits a Request. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
84 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
85 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
pass |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
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
|
90 |
"""View methods for the Docs model. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
|
507
3603fdafabf7
Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
504
diff
changeset
|
93 |
def __init__(self, original_params=None): |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
"""Defines the fields and methods required for the base View class |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
95 |
to provide the user with list, public, create, edit and delete views. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
Params: |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
98 |
original_params: a dict with params for this View |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
99 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
100 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
101 |
self._logic = soc.logic.models.request.logic |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
102 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
103 |
params = {} |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
105 |
params['name'] = "Request" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
106 |
params['name_short'] = "Request" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
params['name_plural'] = "Requests" |
502
e1e24c0a4e82
Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
108 |
params['url_name'] = "request" |
e1e24c0a4e82
Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
109 |
params['module_name'] = "request" |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
110 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
params['edit_form'] = EditForm |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
112 |
params['create_form'] = CreateForm |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
113 |
|
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
532
diff
changeset
|
114 |
params['sidebar_defaults'] = [('/%s/list', 'List %(name_plural)s')] |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
|
502
e1e24c0a4e82
Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
116 |
params['delete_redirect'] = '/' + params['url_name'] + '/list' |
504
25156c768e7f
Fix not working request creation.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
502
diff
changeset
|
117 |
params['create_redirect'] = '/' + params['url_name'] |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
params['save_message'] = [ugettext_lazy('Request saved.')] |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
|
507
3603fdafabf7
Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
504
diff
changeset
|
121 |
params = dicts.merge(original_params, params) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
|
507
3603fdafabf7
Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
504
diff
changeset
|
123 |
base.View.__init__(self, params=params) |
519
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
124 |
|
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
125 |
|
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
126 |
def listSelf(self, request, page_name=None, params=None, **kwargs): |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
127 |
"""Displays the unhandled requests for this user. |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
128 |
|
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
129 |
Args: |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
130 |
request: the standard Django HTTP request object |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
131 |
page_name: the page name displayed in templates as page and header title |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
132 |
params: a dict with params for this View |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
133 |
kwargs: not used |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
134 |
""" |
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
135 |
|
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
136 |
try: |
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
137 |
self.checkAccess('list', request) |
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
138 |
except out_of_band.Error, error: |
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
139 |
return error.response(request) |
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
140 |
|
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
141 |
params = dicts.merge(params, self._params) |
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
142 |
|
519
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
143 |
# get the current user |
521
07b2c382a4d6
Minor improvements to roles page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
519
diff
changeset
|
144 |
properties = {'account': users.get_current_user()} |
519
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
145 |
user_entity = user_logic.logic.getForFields(properties, unique=True) |
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
146 |
|
561
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
147 |
# construct the Unhandled Requests list |
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
148 |
|
519
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
149 |
# only select the requests for this user that haven't been handled yet |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
150 |
filter = {'link_id': user_entity.link_id, |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
151 |
'group_accepted' : True} |
561
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
152 |
|
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
153 |
uh_params = params.copy() |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
154 |
uh_params['list_action'] = (self.inviteAcceptedRedirect, None) |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
155 |
uh_params['list_description'] = ugettext_lazy( |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
156 |
"An overview of your unhandled requests") |
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
157 |
|
572
1b3e7280743a
Made list pagination part of Lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
569
diff
changeset
|
158 |
uh_list = helper.lists.getListContent(request, uh_params, self._logic, filter, 0) |
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
159 |
|
561
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
160 |
# construct the Open Requests list |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
161 |
|
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
162 |
# only select the requests for the user |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
163 |
# that haven't been accepted by an admin yet |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
164 |
filter = {'link_id' : user_entity.link_id, |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
165 |
'group_accepted' : False} |
561
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
166 |
|
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
167 |
ar_params = params.copy() |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
168 |
ar_params['list_description'] = ugettext_lazy( |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
169 |
"An overview of your requests, that haven't been handled by an admin yet") |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
170 |
|
572
1b3e7280743a
Made list pagination part of Lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
569
diff
changeset
|
171 |
ar_list = helper.lists.getListContent(request, ar_params, self._logic, filter, 1) |
561
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
172 |
|
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
173 |
# fill contents with all the needed lists |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
174 |
contents = [uh_list,ar_list] |
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
175 |
|
4db464032b25
Added a requests overview using the new multi-list page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
560
diff
changeset
|
176 |
# call the _list method from base to display the list |
556
6c22492b6349
Refactor requestSelf to be make use of the new split
Sverre Rabbelier <srabbelier@gmail.com>
parents:
554
diff
changeset
|
177 |
return self._list(request, params, contents, page_name) |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
178 |
|
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
179 |
def inviteAcceptedRedirect(self, entity, _): |
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
180 |
"""Returns the redirect for accepting a request |
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
181 |
""" |
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
182 |
|
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
183 |
return '/%s/create/%s/%s' % ( |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
184 |
entity.role, entity.scope_path, entity.link_id) |
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
558
diff
changeset
|
185 |
|
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
186 |
def _editSeed(self, request, seed): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
187 |
"""See base.View._editGet(). |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
188 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
190 |
# fill in the email field with the data from the entity |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
191 |
seed['user'] = seed['link_id'] |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
192 |
seed['group'] = seed['scope_path'] |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
193 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
194 |
def _editGet(self, request, entity, form): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
195 |
"""See base.View._editGet(). |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
196 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
197 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
198 |
# fill in the email field with the data from the entity |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
199 |
form.fields['user'].initial = entity.link_id |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
200 |
form.fields['group'].initial = entity.scope_path |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
201 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
202 |
def _editPost(self, request, entity, fields): |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
203 |
"""See base.View._editPost(). |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
204 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
205 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
206 |
# fill in the account field with the user created from email |
562
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
207 |
fields['link_id'] = fields['requester'].link_id |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
208 |
fields['scope_path'] = fields['to'].link_id |
1bf2beedda03
Made Request use the new link_id and scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
561
diff
changeset
|
209 |
fields['scope'] = fields['to'] |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
210 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
211 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
212 |
view = View() |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
213 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
214 |
create = view.create |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
215 |
edit = view.edit |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
216 |
delete = view.delete |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
217 |
list = view.list |
519
561a438115eb
Adds the user's role page. Currently this only has an overview of the user's unhandled requests.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
514
diff
changeset
|
218 |
list_self = view.listSelf |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
219 |
public = view.public |