in order to autogenerate dotted path url pattern names. Updated a number of url reverses to use dotted path, and removed explicit url pattern names as needed. Changed some imports to prevent import of ietf.urls before django initialization was complete. Changed 3 cases of form classes being curried to functions; django 1.10 didn't accept that. Started converting old-style middleware classes to new-style middleware functions (incomplete). Tweaked a nomcom decorator to preserve function names and attributes, like a good decorator should. Replaced the removed django templatetag 'removetags' with our own version which uses bleach, and does sanitizing in addition to removing explicitly mentionied html tags. Rewrote the filename argument handling in a management command which had broken with the upgrade. - Legacy-Id: 12818
18 lines
739 B
Python
18 lines
739 B
Python
import functools
|
|
|
|
from django.core.urlresolvers import reverse
|
|
from django.http import HttpResponseRedirect
|
|
from django.utils.http import urlquote
|
|
|
|
|
|
def nomcom_private_key_required(view_func):
|
|
def inner(request, *args, **kwargs):
|
|
year = kwargs.get('year', None)
|
|
if not year:
|
|
raise Exception, 'View decorated with nomcom_private_key_required must receive a year argument'
|
|
if not 'NOMCOM_PRIVATE_KEY_%s' % year in request.session:
|
|
return HttpResponseRedirect('%s?back_to=%s' % (reverse('nomcom_private_key', None, args=(year, )), urlquote(request.get_full_path())))
|
|
else:
|
|
return view_func(request, *args, **kwargs)
|
|
return functools.update_wrapper(inner, view_func)
|