thread.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. from django.core.urlresolvers import reverse
  2. from misago.threads.threadtypes import ThreadTypeBase
  3. class Thread(ThreadTypeBase):
  4. type_name = 'thread'
  5. def get_category_name(self, category):
  6. return category.name
  7. def get_category_absolute_url(self, category):
  8. return reverse('misago:category', kwargs={
  9. 'category_id': category.id, 'category_slug': category.slug
  10. })
  11. def get_new_thread_url(self, category):
  12. return reverse('misago:thread_new', kwargs={
  13. 'category_id': category.id, 'category_slug': category.slug
  14. })
  15. def get_reply_url(self, thread):
  16. return reverse('misago:reply_thread', kwargs={
  17. 'category_id': thread.category.id,
  18. 'thread_id': thread.id,
  19. })
  20. def get_edit_post_url(self, post):
  21. return reverse('misago:edit_post', kwargs={
  22. 'category_id': post.category_id,
  23. 'thread_id': post.thread_id,
  24. 'post_id': post.id
  25. })
  26. def get_thread_absolute_url(self, thread):
  27. return reverse('misago:thread', kwargs={
  28. 'thread_slug': thread.slug,
  29. 'thread_id': thread.id
  30. })
  31. def get_thread_post_url(self, thread, post_id, page):
  32. kwargs = {
  33. 'thread_slug': thread.slug,
  34. 'thread_id': thread.id,
  35. }
  36. if page > 1:
  37. kwargs['page'] = page
  38. url = reverse('misago:thread', kwargs=kwargs)
  39. return '%s#post-%s' % (url, post_id)
  40. def get_thread_last_reply_url(self, thread):
  41. return reverse('misago:thread_last', kwargs={
  42. 'thread_slug': thread.slug,
  43. 'thread_id': thread.id
  44. })
  45. def get_thread_new_reply_url(self, thread):
  46. return reverse('misago:thread_new', kwargs={
  47. 'thread_slug': thread.slug,
  48. 'thread_id': thread.id
  49. })
  50. def get_thread_moderated_url(self, thread):
  51. return reverse('misago:thread_moderated', kwargs={
  52. 'thread_slug': thread.slug,
  53. 'thread_id': thread.id
  54. })
  55. def get_thread_reported_url(self, thread):
  56. return reverse('misago:thread_reported', kwargs={
  57. 'thread_slug': thread.slug,
  58. 'thread_id': thread.id
  59. })
  60. def get_post_absolute_url(self, post):
  61. return reverse('misago:thread_post', kwargs={
  62. 'thread_slug': post.thread.slug,
  63. 'thread_id': post.thread.id,
  64. 'post_id': post.id
  65. })
  66. def get_post_quote_url(self, post):
  67. return reverse('misago:quote_post', kwargs={
  68. 'post_id': post.id
  69. })
  70. def get_post_approve_url(self, post):
  71. return reverse('misago:approve_post', kwargs={
  72. 'post_id': post.id
  73. })
  74. def get_post_unhide_url(self, post):
  75. return reverse('misago:unhide_post', kwargs={
  76. 'post_id': post.id
  77. })
  78. def get_post_hide_url(self, post):
  79. return reverse('misago:hide_post', kwargs={
  80. 'post_id': post.id
  81. })
  82. def get_post_delete_url(self, post):
  83. return reverse('misago:delete_post', kwargs={
  84. 'post_id': post.id
  85. })
  86. def get_post_report_url(self, post):
  87. return reverse('misago:report_post', kwargs={
  88. 'post_id': post.id
  89. })
  90. def get_event_edit_url(self, event):
  91. return reverse('misago:edit_event', kwargs={
  92. 'event_id': event.id
  93. })