36 |
36 |
37 |
37 |
38 DEF_DOCS_PUBLIC_TMPL = 'soc/document/public.html' |
38 DEF_DOCS_PUBLIC_TMPL = 'soc/document/public.html' |
39 |
39 |
40 @decorators.view |
40 @decorators.view |
41 def public(request, page_name=None, partial_path=None, link_name=None, |
41 def public(request, page_name=None, partial_path=None, link_id=None, |
42 template=DEF_DOCS_PUBLIC_TMPL): |
42 template=DEF_DOCS_PUBLIC_TMPL): |
43 """How the "general public" sees a Document. |
43 """How the "general public" sees a Document. |
44 |
44 |
45 Args: |
45 Args: |
46 request: the standard django request object |
46 request: the standard django request object |
47 page_name: the page name displayed in templates as page and header title |
47 page_name: the page name displayed in templates as page and header title |
48 partial_path: the Document's site-unique "path" extracted from the URL, |
48 partial_path: the Document's site-unique "path" extracted from the URL, |
49 minus the trailing link_name |
49 minus the trailing link_id |
50 link_name: the last portion of the Document's site-unique "path" |
50 link_id: the last portion of the Document's site-unique "path" |
51 extracted from the URL |
51 extracted from the URL |
52 template: the "sibling" template (or a search list of such templates) |
52 template: the "sibling" template (or a search list of such templates) |
53 from which to construct the public.html template name (or names) |
53 from which to construct the public.html template name (or names) |
54 |
54 |
55 Returns: |
55 Returns: |
66 # TODO: based on the User's Roles, Documents that the User can edit |
66 # TODO: based on the User's Roles, Documents that the User can edit |
67 # should display a link to a document edit form |
67 # should display a link to a document edit form |
68 |
68 |
69 doc = None |
69 doc = None |
70 |
70 |
71 # try to fetch User entity corresponding to link_name if one exists |
71 # try to fetch User entity corresponding to link_id if one exists |
72 path = path_link_name.combinePath([partial_path, link_name]) |
72 path = path_link_name.combinePath([partial_path, link_id]) |
73 |
73 |
74 # try to fetch Document entity corresponding to path if one exists |
74 # try to fetch Document entity corresponding to path if one exists |
75 try: |
75 try: |
76 if path: |
76 if path: |
77 doc = document.logic.getFromFields(partial_path=partial_path, |
77 doc = document.logic.getFromFields(partial_path=partial_path, |
78 link_name=link_name) |
78 link_id=link_id) |
79 except out_of_band.ErrorResponse, error: |
79 except out_of_band.ErrorResponse, error: |
80 # show custom 404 page when Document path doesn't exist in Datastore |
80 # show custom 404 page when Document path doesn't exist in Datastore |
81 return simple.errorResponse(request, page_name, error, template, context) |
81 return simple.errorResponse(request, page_name, error, template, context) |
82 |
82 |
83 doc.content = helper.templates.unescape(doc.content) |
83 doc.content = helper.templates.unescape(doc.content) |