def userkey_required():
 def _decorator(view):
  def wrapped_view(request, *args, **kwargs):
   try:
    uk = UserKey.objects.get(user=request.user)
   except UserKey.DoesNotExist:
    messages.warning(request, u"This operation requires an active user key, but you don't have one.")
    return redirect('users:userkey')
   if (not uk.is_active()):
    messages.warning(request, u'This operation is not available. Your user key has not been activated.')
    return redirect('users:userkey')
   return view(request, *args, **kwargs)
  return wrapped_view
 return _decorator

def userkey_required ( ) : def _decorator ( view ) : def wrapped_view ( request , * args , ** kwargs ) : try : uk = UserKey . objects . get ( user = request . user ) except UserKey . DoesNotExist : messages . warning ( request , u"This operation requires an active user key, but you don't have one." ) return redirect ( 'users:userkey' ) if ( not uk . is_active ( ) ) : messages . warning ( request , u'This operation is not available. Your user key has not been activated.' ) return redirect ( 'users:userkey' ) return view ( request , * args , ** kwargs ) return wrapped_view return _decorator
decorator for views which require that the user has an active userkey .