Add custom 404 error message with link to "Create a New User" which is displayed when linkname in User Profile Developer view URL (/site/user/profile/<linkname>) doesn't exist. Add default value (None) to new_suffix parameter of template_helpers replaceSuffix and redirectToChangedSuffix functions.
--- a/app/soc/templates/soc/error.html Sat Sep 20 17:39:07 2008 +0000
+++ b/app/soc/templates/soc/error.html Sat Sep 20 19:04:43 2008 +0000
@@ -15,5 +15,5 @@
{% block page_title %}Error{%if error_status %} {{ error_status }}{% endif %}{% endblock %}
{% block header_title %}Error{%if error_status %} {{ error_status }}{% endif %}{% endblock %}
{% block body %}
-<div class="error">{%if error_status %}Error {{ error_status }}: {% endif %}{{ error_message }}</div>
+<div class="error">{%if error_status %}Error {{ error_status }}: {% endif %}{{ error_message|safe }}</div>
{% endblock %}
\ No newline at end of file
--- a/app/soc/views/helpers/response_helpers.py Sat Sep 20 17:39:07 2008 +0000
+++ b/app/soc/views/helpers/response_helpers.py Sat Sep 20 19:04:43 2008 +0000
@@ -125,7 +125,7 @@
return context
-def replaceSuffix(path, old_suffix, new_suffix, params=None):
+def replaceSuffix(path, old_suffix, new_suffix=None, params=None):
"""Replace the last part of a URL path with something else.
Also appends an optional list of query parameters. Used for
@@ -166,7 +166,7 @@
def redirectToChangedSuffix(
- request, old_suffix, new_suffix, params=None):
+ request, old_suffix, new_suffix=None, params=None):
"""Changes suffix of URL path and returns an HTTP redirect response.
Args:
--- a/app/soc/views/site/user/profile.py Sat Sep 20 17:39:07 2008 +0000
+++ b/app/soc/views/site/user/profile.py Sat Sep 20 19:04:43 2008 +0000
@@ -212,6 +212,9 @@
DEF_SITE_USER_PROFILE_EDIT_TMPL = 'soc/site/user/profile/edit.html'
+DEF_CREATE_NEW_USER_MSG = ' You can create a new user by visiting' \
+ ' <a href="/site/user/profile">Create ' \
+ 'a New User</a> page.'
def edit(request, linkname=None, template=DEF_SITE_USER_PROFILE_EDIT_TMPL):
"""View for a Developer to modify the properties of a User Model entity.
@@ -241,6 +244,7 @@
user = id_user.getUserIfLinkName(linkname)
except out_of_band.ErrorResponse, error:
# show custom 404 page when link name doesn't exist in Datastore
+ error.message = error.message + DEF_CREATE_NEW_USER_MSG
return simple.errorResponse(request, error, template, context)
if request.method == 'POST':