decorators.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ================
  2. Views Decorators
  3. ================
  4. Misago apps define plenty of decorators for you to wrap your views with.
  5. misago.core.decorators
  6. ======================
  7. require_POST
  8. ------------
  9. :py:func:`misago.core.decorators.require_POST`
  10. Function that checks if request made to access view is POST. If it's not, decorator renders ''wrong_way.html'' template and returns it in 405-coded response. This is its only difference to Django's counterpart.
  11. misago.core.errorpages
  12. ======================
  13. shared_403_exception_handler
  14. ----------------------------
  15. :py:func:`misago.core.errorpages.shared_403_exception_handler`
  16. If your project has different error handler for 403 errors defined, you can use this decorator to make your function shared handler between Misago and other views. This will make Misago handle 403 exceptions coming from under its path while leaving alone exceptions coming from your site.
  17. shared_404_exception_handler
  18. ----------------------------
  19. :py:func:`misago.core.errorpages.shared_404_exception_handler`
  20. Same as above but for custom 404 error handler.
  21. misago.users.decorators
  22. =======================
  23. deny_authenticated
  24. ------------------
  25. :py:func:`misago.users.decorators.deny_authenticated`
  26. This decorator will block requests made to view if user is authenticated, displaying page with error message or returning JSON/XML in its stead.
  27. deny_guests
  28. -----------
  29. :py:func:`misago.users.decorators.deny_guests`
  30. This decorator will block requests made to view if user is not authenticated, displaying page with error message or returning JSON/XML in its stead.
  31. deny_banned_ips
  32. ---------------
  33. :py:func:`misago.users.decorators.deny_banned_ips`
  34. This decorator will block requests made to view if user IP is banned, displaying page with error message or returning JSON/XML in its stead.
  35. deflect_authenticated
  36. ---------------------
  37. :py:func:`misago.users.decorators.deflect_authenticated`
  38. This decorator will return redirect to forum index if user is authenticated.
  39. deflect_guests
  40. --------------
  41. :py:func:`misago.users.decorators.deflect_guests`
  42. This decorator will return redirect to forum index if user is not authenticated.
  43. deflect_banned_ips
  44. ------------------
  45. :py:func:`misago.users.decorators.deflect_banned_ips`
  46. This decorator will return redirect to forum index if user IP is banned.