Add app url namespacing to the common and main apps, fix missing namespace in the registration app, remove explict reverse_lazy for the LOGIN_URL and LOGIN_REDIRECT_URL these are expected to be views or URLs (failover)

This commit is contained in:
Roberto Rosario
2014-09-09 03:51:23 -04:00
parent 7dfacc624c
commit f5bef4b52d
11 changed files with 26 additions and 27 deletions
+2 -2
View File
@@ -24,8 +24,8 @@ from .utils import validate_path
logger = logging.getLogger(__name__)
register_links(['current_user_details', 'current_user_edit', 'password_change_view'], [link_current_user_details, link_current_user_edit, link_password_change], menu_name='secondary_menu')
register_links(['about_view', 'license_view', 'form_view'], [link_about, link_license], menu_name='secondary_menu')
register_links(['common:current_user_details', 'common:current_user_edit', 'common:password_change_view'], [link_current_user_details, link_current_user_edit, link_password_change], menu_name='secondary_menu')
register_links(['common:about_view', 'common:license_view', 'registration:form_view'], [link_about, link_license], menu_name='secondary_menu')
register_top_menu('about', link_about, position=-1)
+5 -5
View File
@@ -7,9 +7,9 @@ def has_usable_password(context):
return context['request'].user.has_usable_password
link_password_change = {'text': _(u'change password'), 'view': 'password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password}
link_current_user_details = {'text': _(u'user details'), 'view': 'current_user_details', 'famfam': 'vcard'}
link_current_user_edit = {'text': _(u'edit details'), 'view': 'current_user_edit', 'famfam': 'vcard_edit'}
link_password_change = {'text': _(u'change password'), 'view': 'common:password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password}
link_current_user_details = {'text': _(u'user details'), 'view': 'common:current_user_details', 'famfam': 'vcard'}
link_current_user_edit = {'text': _(u'edit details'), 'view': 'common:current_user_edit', 'famfam': 'vcard_edit'}
link_about = {'text': _(u'about'), 'view': 'about_view', 'famfam': 'information'}
link_license = {'text': _(u'license'), 'view': 'license_view', 'famfam': 'script'}
link_about = {'text': _(u'about'), 'view': 'common:about_view', 'famfam': 'information'}
link_license = {'text': _(u'license'), 'view': 'common:license_view', 'famfam': 'script'}
@@ -4,10 +4,11 @@ import re
from django.http import HttpResponseRedirect
from django.conf import settings
from django.core.urlresolvers import reverse
from ..conf.settings import ALLOW_ANONYMOUS_ACCESS
EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip('/'))]
EXEMPT_URLS = [re.compile(reverse(settings.LOGIN_URL).lstrip('/'))]
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
EXEMPT_URLS += [re.compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
@@ -34,4 +35,4 @@ class LoginRequiredMiddleware:
if not request.user.is_authenticated():
path = request.path_info.lstrip('/')
if not any(m.match(path) for m in EXEMPT_URLS):
return HttpResponseRedirect(settings.LOGIN_URL)
return HttpResponseRedirect(reverse(settings.LOGIN_URL))
+2 -2
View File
@@ -181,7 +181,7 @@ def current_user_edit(request):
Allow an user to edit his own details
"""
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', reverse('current_user_details'))))
next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', reverse('common:current_user_details'))))
if request.method == 'POST':
form = UserForm(instance=request.user, data=request.POST)
@@ -245,7 +245,7 @@ def password_change_view(request):
request,
extra_context=context,
template_name='main/password_change_form.html',
post_change_redirect=reverse('password_change_done'),
post_change_redirect=reverse('common:password_change_done'),
)