author | Todd Larsen <tlarsen@google.com> |
Sat, 15 Nov 2008 03:12:33 +0000 | |
changeset 481 | 94834a1e6c01 |
parent 365 | 74dec172944e |
child 482 | 839740b061ad |
permissions | -rw-r--r-- |
82
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2 |
# |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
4 |
# |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
8 |
# |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
10 |
# |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
16 |
|
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
17 |
"""Views of a User's various Roles on the site. |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
18 |
|
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
19 |
dashboard: dashboard view of all of a User's Roles on the site |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
20 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
21 |
public: a public view of the User's Roles on the site |
82
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
22 |
""" |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
23 |
|
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
24 |
__authors__ = [ |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
25 |
'"Todd Larsen" <tlarsen@google.com>', |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
26 |
] |
1456e633bf8a
Create placeholders for User Roles prototype.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
27 |
|
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
28 |
|
365
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
29 |
from soc.views.helper import decorators |
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
30 |
from soc.views.helper import responses |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
31 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
32 |
|
365
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
33 |
@decorators.view |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
34 |
def dashboard(request, page=None, link_name=None, |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
35 |
template='soc/user/roles/dashboard.html'): |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
36 |
"""A per-User dashboard of that User's Roles on the site. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
37 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
38 |
Args: |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
39 |
request: the standard django request object. |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
40 |
page: a soc.logic.site.page.Page object which is abstraction that combines |
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
41 |
a Django view with sidebar menu info |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
99
diff
changeset
|
42 |
link_name: the User's site-unique "link_name" extracted from the URL |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
43 |
template: the template path to use for rendering the template. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
44 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
45 |
Returns: |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
46 |
A subclass of django.http.HttpResponse with generated template. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
47 |
""" |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
48 |
#TODO(tlarsen): this module is currently a placeholder for future work |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
49 |
|
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
99
diff
changeset
|
50 |
# TODO: check that user is logged in and "owns" the link_name; |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
51 |
# if not, call public() view instead |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
52 |
# This might be tricky, since we want to use the same style |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
53 |
# of template that was passed to us, but how do we figure out |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
54 |
# what the equivalent public.html template is? Perhaps this |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
55 |
# view needs to require that, for a foo/bar/dashboard.html |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
56 |
# template, a corresponding foo/bar/public.html template must |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
57 |
# also exist... |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
58 |
|
365
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
59 |
return responses.respond(request, |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
60 |
template, {'template': template}) |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
61 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
62 |
|
365
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
63 |
@decorators.view |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
64 |
def public(request, page=None, link_name=None, |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
65 |
template='soc/user/roles/public.html'): |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
66 |
"""A "general public" view of a User's Roles on the site. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
67 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
68 |
Args: |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
69 |
request: the standard django request object. |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
70 |
page: a soc.logic.site.page.Page object which is abstraction that combines |
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
71 |
a Django view with sidebar menu info |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
99
diff
changeset
|
72 |
link_name: the User's site-unique "link_name" extracted from the URL |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
73 |
template: the template path to use for rendering the template. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
74 |
|
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
75 |
Returns: |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
76 |
A subclass of django.http.HttpResponse with generated template. |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
77 |
""" |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
78 |
#TODO(tlarsen): this module is currently a placeholder for future work |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
79 |
|
299
a1cc853a56e5
Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents:
298
diff
changeset
|
80 |
# TODO: if link_name is empty or not a valid link_name on the site, display |
84
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
81 |
# some sort of "user does not exist" page (a custom 404 page, maybe?). |
1b31d238ba39
Flesh out the user/roles placeholders a little bit more.
Todd Larsen <tlarsen@google.com>
parents:
82
diff
changeset
|
82 |
|
365
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
83 |
return responses.respond(request, |
74dec172944e
Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
358
diff
changeset
|
84 |
template, {'template': template}) |