35 |
35 |
36 |
36 |
37 DEF_PUBLIC_TMPL = 'soc/base.html' |
37 DEF_PUBLIC_TMPL = 'soc/base.html' |
38 |
38 |
39 @decorators.view |
39 @decorators.view |
40 def public(request, page_name=None, template=DEF_PUBLIC_TMPL, link_name=None, |
40 def public(request, page_name=None, template=DEF_PUBLIC_TMPL, link_id=None, |
41 context=None): |
41 context=None): |
42 """A simple template view that expects a link_name extracted from the URL. |
42 """A simple template view that expects a link_id extracted from the URL. |
43 |
43 |
44 Args: |
44 Args: |
45 request: the standard Django HTTP request object |
45 request: the standard Django HTTP request object |
46 page_name: the page name displayed in templates as page and header title |
46 page_name: the page name displayed in templates as page and header title |
47 template: the template to use for rendering the view (or a search list |
47 template: the template to use for rendering the view (or a search list |
48 of templates) |
48 of templates) |
49 link_name: a site-unique "link_name" (usually extracted from the URL) |
49 link_id: a site-unique "link_id" (usually extracted from the URL) |
50 context: the context dict supplied to the template, which is modified |
50 context: the context dict supplied to the template, which is modified |
51 (so supply a copy if such modification is not acceptable) |
51 (so supply a copy if such modification is not acceptable) |
52 link_name: the link_name parameter is added to the context |
52 link_id: the link_id parameter is added to the context |
53 link_name_user: if the link_name exists for a User, that User |
53 link_id_user: if the link_id exists for a User, that User |
54 is added to the context |
54 is added to the context |
55 |
55 |
56 |
56 |
57 Returns: |
57 Returns: |
58 A subclass of django.http.HttpResponse containing the generated page. |
58 A subclass of django.http.HttpResponse containing the generated page. |
67 context = helper.responses.getUniversalContext(request) |
67 context = helper.responses.getUniversalContext(request) |
68 |
68 |
69 context['page_name'] = page_name |
69 context['page_name'] = page_name |
70 |
70 |
71 try: |
71 try: |
72 if link_name: |
72 if link_id: |
73 user = accounts.getUserFromLinkNameOr404(link_name) |
73 user = accounts.getUserFromLinkIdOr404(link_id) |
74 except out_of_band.ErrorResponse, error: |
74 except out_of_band.ErrorResponse, error: |
75 return errorResponse(request, page_name, error, template, context) |
75 return errorResponse(request, page_name, error, template, context) |
76 |
76 |
77 context['link_name'] = link_name |
77 context['link_id'] = link_id |
78 context['link_name_user'] = user |
78 context['link_id_user'] = user |
79 |
79 |
80 return helper.responses.respond(request, template, context) |
80 return helper.responses.respond(request, template, context) |
81 |
81 |
82 |
82 |
83 DEF_ERROR_TMPL = 'soc/error.html' |
83 DEF_ERROR_TMPL = 'soc/error.html' |