22 __authors__ = [ |
22 __authors__ = [ |
23 '"Todd Larsen" <tlarsen@google.com>', |
23 '"Todd Larsen" <tlarsen@google.com>', |
24 ] |
24 ] |
25 |
25 |
26 |
26 |
27 from google.appengine.api import users |
|
28 |
|
29 from soc.logic import document |
|
30 from soc.logic import out_of_band |
27 from soc.logic import out_of_band |
|
28 from soc.logic import path_link_name |
|
29 from soc.logic.models import document |
31 from soc.views import helper |
30 from soc.views import helper |
32 from soc.views import simple |
31 from soc.views import simple |
33 |
32 |
34 import soc.views.helper.responses |
33 import soc.views.helper.responses |
35 import soc.views.helper.templates |
34 import soc.views.helper.templates |
61 # implements some sort of access controls, based on the currently |
60 # implements some sort of access controls, based on the currently |
62 # logged-in User's Roles, etc. |
61 # logged-in User's Roles, etc. |
63 |
62 |
64 # TODO: based on the User's Roles, Documents that the User can edit |
63 # TODO: based on the User's Roles, Documents that the User can edit |
65 # should display a link to a document edit form |
64 # should display a link to a document edit form |
|
65 |
|
66 doc = None |
66 |
67 |
67 # try to fetch User entity corresponding to link_name if one exists |
68 # try to fetch User entity corresponding to link_name if one exists |
|
69 path = path_link_name.combinePath([partial_path, link_name]) |
|
70 |
|
71 # try to fetch Document entity corresponding to path if one exists |
68 try: |
72 try: |
69 doc = document.getDocumentIfPath(partial_path, link_name=link_name) |
73 if path: |
|
74 doc = document.logic.getFromFields(partial_path=partial_path, |
|
75 link_name=link_name) |
70 except out_of_band.ErrorResponse, error: |
76 except out_of_band.ErrorResponse, error: |
71 # show custom 404 page when Document path doesn't exist in Datastore |
77 # show custom 404 page when Document path doesn't exist in Datastore |
72 return simple.errorResponse(request, error, template, context) |
78 return simple.errorResponse(request, error, template, context) |
73 |
79 |
74 doc.content = helper.templates.unescape(doc.content) |
80 doc.content = helper.templates.unescape(doc.content) |