thread_types.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. ============
  2. Thread Types
  3. ============
  4. All user-published content in Misago follows basic hierarchy: Forums have threads which have (optionally) polls and posts that have attachments. In addition forums and threads have labels.
  5. Whenever user creates new discussion on forums, sends private message to other user, or reports offensive post, mechanics behind UI are largery the same and result in thread of certain kind being posted in destined section of site.
  6. This system was designed to be extensible to enable developers using Misago as foundation for their community sites to add new content types such as blogs, articles or galleries.
  7. Writing custom thread type
  8. ==========================
  9. Thread type is basically UI for users to interact with and Python code implementing features behind it, plus helper object for enabling your models to point to custom views.
  10. Thread type is decided by value of `special_role` attribute of forum model instance that content (thread, post, attachment, etc. ect.) belongs to. Using this value model is able to call `misago.threads.threadtypes.get(thread_type)` in order to obtain its helper object.
  11. Helper classes
  12. ==============
  13. Paths to helper classess definitions are specified in `MISAGO_THREAD_TYPES` settings. Each helper class is expected to define `type_name` attribute corresponding to forum its forum `special_role` attribute.
  14. .. note::
  15. If `special_role` is not defined, Misago falls back to `role` attribute.
  16. Once helper class is defined, it's available as "thread_type" attribute on forum, thread, post, event, poll and attachment models.
  17. Depending on features used by thread type, its helper is expected to define different of the following methods:
  18. get_forum_name
  19. --------------
  20. .. function:: get_forum_name(forum)
  21. Used to obtain forum name. Useful when thread type uses single forum with predefined name. Should return string.
  22. get_forum_absolute_url
  23. ----------------------
  24. .. function:: get_forum_absolute_url(forum)
  25. Used to obtain forum absolute url.
  26. get_new_thread_url
  27. ------------------
  28. .. function:: get_new_thread_url(forum)
  29. Used to obtain "post new thread" url for forum.
  30. get_reply_url
  31. -------------
  32. .. function:: get_reply_url(thread)
  33. Used to obtain "post reply" url for thread.
  34. get_edit_post_url
  35. -----------------
  36. .. function:: get_edit_post_url(post)
  37. Used to obtain edit url for post.
  38. get_thread_absolute_url
  39. -----------------------
  40. .. function:: get_thread_absolute_url(thread)
  41. Used to obtain thread absolute url.
  42. get_thread_post_url
  43. -------------------
  44. .. function:: get_thread_post_url(thread, post_id, page)
  45. Used by "go to post" views to build links pointing user to posts. Should return URL to specified thread page with fragment containing specified post.
  46. get_thread_last_reply_url
  47. -------------------------
  48. .. function:: get_thread_last_reply_url(thread)
  49. Should return url to view redirecting to last post in thread.
  50. get_thread_new_reply_url
  51. ------------------------
  52. .. function:: get_thread_new_reply_url(thread)
  53. Should return url to view redirecting to first unread post in thread.
  54. get_thread_moderated_url
  55. ------------------------
  56. .. function:: get_thread_moderated_url(thread)
  57. Should return url to view returning list of posts in thread that are pending moderator review.
  58. get_thread_reported_url
  59. -----------------------
  60. .. function:: get_thread_reported_url(thread)
  61. Should return url to view returning list of reported posts in thread.
  62. get_post_absolute_url
  63. ---------------------
  64. .. function:: get_post_absolute_url(post)
  65. Used to obtain post absolute url.
  66. get_post_approve_url
  67. --------------------
  68. .. function:: get_post_approve_url(post)
  69. Used to obtain url that moderator should follow to approve post.
  70. get_post_unhide_url
  71. -------------------
  72. .. function:: get_post_unhide_url(post)
  73. Used to obtain url that will make hidden post visible.
  74. get_post_hide_url
  75. -----------------
  76. .. function:: get_post_hide_url(post)
  77. Used to obtain url that will make visible post hidden.
  78. get_post_delete_url
  79. -------------------
  80. .. function:: get_post_delete_url(post)
  81. Used to obtain url that will delete post.
  82. get_event_edit_url
  83. ------------------
  84. .. function:: get_event_edit_url(event)
  85. Used to obtain url that will handle API calls for hiding/unhiding and deleting thread events.