mixins.py 831 B

123456789101112131415161718192021222324
  1. from django.core.urlresolvers import reverse
  2. from django.shortcuts import redirect
  3. from misago.acl.exceptions import ACLError404
  4. class TypeMixin(object):
  5. type_prefix = 'private_thread'
  6. def check_permissions(self):
  7. try:
  8. if self.thread.pk:
  9. if not self.request.user in self.thread.participants.all():
  10. raise ACLError404()
  11. except AttributeError:
  12. pass
  13. def whitelist_mentions(self):
  14. participants = self.thread.participants.all()
  15. mentioned = self.post.mentions.all()
  16. for user in self.md.mentions:
  17. if user not in participants and user not in mentioned:
  18. self.post.mentioned.add(user)
  19. def threads_list_redirect(self):
  20. return redirect(reverse('private_threads'))