Skip to content

Commit

Permalink
adds best_answer_accepted and best_answer_unaccepted signals
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfadeev committed Oct 10, 2024
1 parent 37ddfbb commit 0af5323
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion askbot/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def user_can_anonymize_account(self, user):
# non-admins cannot remove admins or moderators
if not self.is_administrator() and user.is_administrator_or_moderator():
return False

if perm == 'admins':
return self.is_administrator() and self.pk != user.pk
elif self.is_administrator_or_moderator():
Expand Down Expand Up @@ -1872,6 +1872,7 @@ def user_accept_best_answer(
auth.onAnswerAcceptCanceled(accepted_answer, self)

auth.onAnswerAccept(answer, self, timestamp=timestamp)
signals.best_answer_accepted.send(None, answer=answer, user=self, timestamp=timestamp)
award_badges_signal.send(None,
event='accept_best_answer',
actor=self,
Expand All @@ -1888,6 +1889,7 @@ def user_unaccept_best_answer(
self.assert_can_unaccept_best_answer(answer)
if not answer.endorsed:
return
signals.best_answer_unaccepted.send(None, answer=answer, user=self, timestamp=timestamp)
auth.onAnswerAcceptCanceled(answer, self)

@auto_now_timestamp
Expand Down
2 changes: 2 additions & 0 deletions askbot/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
new_comment_posted = django.dispatch.Signal()
answer_edited = django.dispatch.Signal()
question_visited = django.dispatch.Signal()
best_answer_accepted = django.dispatch.Signal()
best_answer_unaccepted = django.dispatch.Signal()

post_updated = django.dispatch.Signal()

Expand Down

0 comments on commit 0af5323

Please sign in to comment.