123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- def announce_thread(user, thread):
- if thread.weight < 2:
- thread.weight = 2
- thread.save(update_fields=['weight'])
- return True
- else:
- return False
- def pin_thread(user, thread):
- if thread.weight < 1:
- thread.weight = 1
- thread.save(update_fields=['weight'])
- return True
- else:
- return False
- def default_thread(user, thread):
- if thread.weight > 0:
- thread.weight = 0
- thread.save(update_fields=['weight'])
- return True
- else:
- return False
- def move_thread(user, thread, new_forum):
- if thread.forum_id != new_forum.pk:
- thread.move(new_forum)
- thread.save(update_fields=['forum'])
- return True
- else:
- return False
- def merge_thread(user, thread, other_thread):
- thread.merge(other_thread)
- thread.synchornize()
- thread.save()
- other_thread.delete()
- return True
- def approve_thread(user, thread):
- if thread.is_moderated:
- thread.is_closed = False
- thread.first_post.is_moderated = False
- thread.first_post.save(update_fields=['is_moderated'])
- thread.synchornize()
- thread.save()
- return True
- else:
- return False
- def open_thread(user, thread):
- if thread.is_closed:
- thread.is_closed = False
- thread.save(update_fields=['is_closed'])
- return True
- else:
- return False
- def close_thread(user, thread):
- if not thread.is_closed:
- thread.is_closed = True
- thread.save(update_fields=['is_closed'])
- return True
- else:
- return False
- def show_thread(user, thread):
- if thread.is_hidden:
- thread.first_post.is_hidden = False
- thread.first_post.save(update_fields=['is_hidden'])
- thread.is_hidden = False
- thread.save(update_fields=['is_hidden'])
- thread.synchornize()
- thread.save()
- return True
- else:
- return False
- def hide_thread(user, thread):
- if not thread.is_hidden:
- thread.is_hidden = True
- thread.save(update_fields=['is_hidden'])
- return True
- else:
- return False
- def delete_thread(user, thread):
- thread.delete()
- return True
|