1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2008 the Melange authors. |
|
4 # |
|
5 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 # you may not use this file except in compliance with the License. |
|
7 # You may obtain a copy of the License at |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
11 # Unless required by applicable law or agreed to in writing, software |
|
12 # distributed under the License is distributed on an "AS IS" BASIS, |
|
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 # See the License for the specific language governing permissions and |
|
15 # limitations under the License. |
|
16 |
|
17 """Views of a User's various Roles on the site. |
|
18 |
|
19 dashboard: dashboard view of all of a User's Roles on the site |
|
20 |
|
21 public: a public view of the User's Roles on the site |
|
22 """ |
|
23 |
|
24 __authors__ = [ |
|
25 '"Todd Larsen" <tlarsen@google.com>', |
|
26 ] |
|
27 |
|
28 |
|
29 from soc.views.helper import decorators |
|
30 from soc.views.helper import responses |
|
31 |
|
32 |
|
33 @decorators.view |
|
34 def dashboard(request, page_name=None, link_id=None, |
|
35 template='soc/user/roles/dashboard.html'): |
|
36 """A per-User dashboard of that User's Roles on the site. |
|
37 |
|
38 Args: |
|
39 request: the standard django request object |
|
40 page_name: the page name displayed in templates as page and header title |
|
41 link_id: the User's site-unique "link_id" extracted from the URL |
|
42 template: the template path to use for rendering the template |
|
43 |
|
44 Returns: |
|
45 A subclass of django.http.HttpResponse with generated template. |
|
46 """ |
|
47 #TODO(tlarsen): this module is currently a placeholder for future work |
|
48 |
|
49 # TODO: check that user is logged in and "owns" the link_id; |
|
50 # if not, call public() view instead |
|
51 # This might be tricky, since we want to use the same style |
|
52 # of template that was passed to us, but how do we figure out |
|
53 # what the equivalent public.html template is? Perhaps this |
|
54 # view needs to require that, for a foo/bar/dashboard.html |
|
55 # template, a corresponding foo/bar/public.html template must |
|
56 # also exist... |
|
57 |
|
58 return responses.respond(request, |
|
59 template, {'template': template}) |
|
60 |
|
61 |
|
62 @decorators.view |
|
63 def public(request, page_name=None, link_id=None, |
|
64 template='soc/user/roles/public.html'): |
|
65 """A "general public" view of a User's Roles on the site. |
|
66 |
|
67 Args: |
|
68 request: the standard django request object |
|
69 page_name: the page name displayed in templates as page and header title |
|
70 link_id: the User's site-unique "link_id" extracted from the URL |
|
71 template: the template path to use for rendering the template |
|
72 |
|
73 Returns: |
|
74 A subclass of django.http.HttpResponse with generated template. |
|
75 """ |
|
76 #TODO(tlarsen): this module is currently a placeholder for future work |
|
77 |
|
78 # TODO: if link_id is empty or not a valid link_id on the site, display |
|
79 # some sort of "user does not exist" page (a custom 404 page, maybe?). |
|
80 |
|
81 return responses.respond(request, |
|
82 template, {'template': template}) |
|