Skip to content

Commit

Permalink
Merge pull request #263 from mtueng/main
Browse files Browse the repository at this point in the history
Fix #262 - Disable pre_save receivers during loaddata of fixtures
  • Loading branch information
ellmetha authored Jan 30, 2022
2 parents 53ad340 + f79b159 commit 7585fc1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions machina/apps/forum_member/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def increase_posts_count(sender, instance, **kwargs):
forum post being created or updated.
"""

if kwargs.get('raw'):
# do nothing, when loading data (fixtures)
return

if instance.poster is None:
# An anonymous post is considered. No profile can be updated in
# that case.
Expand Down Expand Up @@ -61,6 +65,11 @@ def decrease_posts_count_after_post_unaproval(sender, instance, **kwargs):
This receiver handles the unaproval of a forum post: the posts count associated with the post's
author is decreased.
"""

if kwargs.get('raw'):
# do nothing, when loading data (fixtures)
return

if not instance.pk or not instance.poster:
# Do not consider posts being created or posts of anonymous users
return
Expand Down

0 comments on commit 7585fc1

Please sign in to comment.