equal
deleted
inserted
replaced
27 from django import http |
27 from django import http |
28 from django import newforms as forms |
28 from django import newforms as forms |
29 from django.utils.translation import ugettext_lazy |
29 from django.utils.translation import ugettext_lazy |
30 |
30 |
31 from soc.logic import document |
31 from soc.logic import document |
32 from soc.logic import key_name |
|
33 from soc.logic import out_of_band |
32 from soc.logic import out_of_band |
|
33 from soc.logic import path_linkname |
34 from soc.logic.site import id_user |
34 from soc.logic.site import id_user |
35 from soc.views import simple |
35 from soc.views import simple |
36 from soc.views.helpers import custom_widgets |
36 from soc.views.helpers import custom_widgets |
37 from soc.views.helpers import forms_helpers |
37 from soc.views.helpers import forms_helpers |
38 from soc.views.helpers import request_helpers |
38 from soc.views.helpers import request_helpers |
74 template=DEF_SITE_DOCS_EDIT_TMPL): |
74 template=DEF_SITE_DOCS_EDIT_TMPL): |
75 """View for a Developer to modify the properties of a Document Model entity. |
75 """View for a Developer to modify the properties of a Document Model entity. |
76 |
76 |
77 Args: |
77 Args: |
78 request: the standard django request object |
78 request: the standard django request object |
79 path: the Document's site-unique "path" extracted from the URL |
79 partial_path: the Document's site-unique "path" extracted from the URL, |
|
80 minus the trailing link_name |
|
81 link_name: the last portion of the Document's site-unique "path" |
|
82 extracted from the URL |
80 template: the "sibling" template (or a search list of such templates) |
83 template: the "sibling" template (or a search list of such templates) |
81 from which to construct the public.html template name (or names) |
84 from which to construct the public.html template name (or names) |
82 |
85 |
83 Returns: |
86 Returns: |
84 A subclass of django.http.HttpResponse which either contains the form to |
87 A subclass of django.http.HttpResponse which either contains the form to |
113 if alt_response: |
116 if alt_response: |
114 return alt_response |
117 return alt_response |
115 |
118 |
116 doc = None # assume that no Document entity will be found |
119 doc = None # assume that no Document entity will be found |
117 |
120 |
118 path = key_name.combinePath([partial_path, linkname]) |
121 path = path_linkname.combinePath([partial_path, linkname]) |
119 |
122 |
120 # try to fetch Document entity corresponding to path if one exists |
123 # try to fetch Document entity corresponding to path if one exists |
121 try: |
124 try: |
122 doc = document.getDocumentIfPath(path) |
125 doc = document.getDocumentIfPath(path) |
123 except out_of_band.ErrorResponse, error: |
126 except out_of_band.ErrorResponse, error: |
143 content=content, user=id_user.getUserFromId(logged_in_id)) |
146 content=content, user=id_user.getUserFromId(logged_in_id)) |
144 |
147 |
145 if not doc: |
148 if not doc: |
146 return http.HttpResponseRedirect('/') |
149 return http.HttpResponseRedirect('/') |
147 |
150 |
148 new_path = key_name.combinePath([new_partial_path, new_linkname]) |
151 new_path = path_linkname.combinePath([new_partial_path, new_linkname]) |
149 |
152 |
150 # redirect to new /site/docs/edit/new_path?s=0 |
153 # redirect to new /site/docs/edit/new_path?s=0 |
151 # (causes 'Profile saved' message to be displayed) |
154 # (causes 'Profile saved' message to be displayed) |
152 return response_helpers.redirectToChangedSuffix( |
155 return response_helpers.redirectToChangedSuffix( |
153 request, path, new_path, |
156 request, path, new_path, |
261 content=content, user=id_user.getUserFromId(logged_in_id)) |
264 content=content, user=id_user.getUserFromId(logged_in_id)) |
262 |
265 |
263 if not doc: |
266 if not doc: |
264 return http.HttpResponseRedirect('/') |
267 return http.HttpResponseRedirect('/') |
265 |
268 |
266 new_path = key_name.combinePathAndLinkName( |
269 new_path = path_linkname.combinePath([new_partial_path, new_linkname]) |
267 new_partial_path, new_linkname) |
|
268 |
270 |
269 # redirect to new /site/docs/edit/new_path?s=0 |
271 # redirect to new /site/docs/edit/new_path?s=0 |
270 # (causes 'Profile saved' message to be displayed) |
272 # (causes 'Profile saved' message to be displayed) |
271 return response_helpers.redirectToChangedSuffix( |
273 return response_helpers.redirectToChangedSuffix( |
272 request, None, new_path, |
274 request, None, new_path, |