Redo our URL scheme to use {% url %} tags
Review Request #359 — Created April 16, 2008 and submitted — Latest diff uploaded
We've been using the old get_absolute_url() function in our templates, which works for the most part but has limitations. Using it on a User object doesn't work so well when installed in a subdirectory, requiring that we prepend SITE_ROOT and then slice the first "/". This gets ugly fast. We've also been hard-coding other paths ("/account/login/", "/dashboard/", etc.), requiring prepending SITE_ROOT again. Django's {% url %} tag provides a cleaner solution, allowing us to give certain pages names that we can refer to. Now something like {{SITE_ROOT}}{{submitter.get_absolute_url|slice:"1"}} turns into {% url user submitter %}. This in theory could also give extensions in the future the ability to override certain pages if they wanted. The result of this change is that we use get_absolute_url() a lot less for some things and never for users. We could move the rest of the get_absolute_url() calls in the future if we choose, though what we have works for now. We've also eliminated most references to SITE_ROOT in the templates. There's some misc. fixes and cleanups in here too, such as using djblets's new user_displayname filter.
Made sure every page I tested worked properly in subdirectory installs. All the user links I could find now point to the correct location.
Diff Revision 1 (Latest)
/trunk/reviewboard/urls.py |
---|
/trunk/reviewboard/accounts/decorators.py |
---|
/trunk/reviewboard/accounts/views.py |
---|
/trunk/reviewboard/iphone/urls.py |
---|
/trunk/reviewboard/reviews/datagrids.py |
---|
/trunk/reviewboard/reviews/urls.py |
---|
/trunk/reviewboard/reviews/views.py |
---|
/trunk/reviewboard/reviews/templatetags/reviewtags.py |
---|
/trunk/reviewboard/templates/base.html |
---|
/trunk/reviewboard/templates/base_feeds.html |
---|
/trunk/reviewboard/templates/accounts/login.html |
---|
/trunk/reviewboard/templates/diffviewer/view_diff.html |
---|
/trunk/reviewboard/templates/iphone/base.html |
---|
/trunk/reviewboard/templates/iphone/dashboard.html |
---|
/trunk/reviewboard/templates/iphone/diff_files.html |
---|
/trunk/reviewboard/templates/iphone/group_list.html |
---|
/trunk/reviewboard/templates/iphone/login.html |
---|
/trunk/reviewboard/templates/iphone/review_request_detail.html |
---|
/trunk/reviewboard/templates/iphone/review_request_list.html |
---|
/trunk/reviewboard/templates/iphone/submitter_list.html |
---|
/trunk/reviewboard/templates/reviews/dashboard_entry.html |
---|
/trunk/reviewboard/templates/reviews/review_detail.html |
---|
/trunk/reviewboard/templates/reviews/review_reply.html |
---|
/trunk/reviewboard/templates/reviews/review_request_box.html |
---|
/trunk/reviewboard/templates/reviews/search.html |
---|