decorators.py 512 B

12345678910111213
  1. from django.utils.translation import ugettext as _
  2. from misago.views import error403
  3. def block_jammed(f):
  4. def decorator(*args, **kwargs):
  5. request = args[0]
  6. try:
  7. if not request.firewall.admin and request.jam.is_jammed():
  8. return error403(request, _("You have used up allowed attempts quota and we temporarily banned you from accessing this page."))
  9. except AttributeError:
  10. pass
  11. return f(*args, **kwargs)
  12. return decorator