From 630f2e30d5e72045fdf9345e348193c2d10c9685 Mon Sep 17 00:00:00 2001 From: David Fischer Date: Wed, 9 Oct 2024 10:19:14 -0700 Subject: [PATCH] Remove simple history change reason This is a temporary fix until the underlying issue is fixed. --- adserver/forms.py | 4 ++-- adserver/staff/forms.py | 35 ++++++++++++++++++++++------------- adserver/tasks.py | 8 ++++---- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/adserver/forms.py b/adserver/forms.py index bf7ee1af..829cc3c5 100644 --- a/adserver/forms.py +++ b/adserver/forms.py @@ -28,7 +28,6 @@ from django.utils.text import slugify from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ -from simple_history.utils import update_change_reason from .models import Advertisement from .models import Campaign @@ -1358,7 +1357,8 @@ def save(self, commit=True): user.invite_user() # Track who added this user - update_change_reason(user, "Invited via authorized users view") + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(user, "Invited via authorized users view") # You will need to add the user to the publisher/advertiser in the view return user diff --git a/adserver/staff/forms.py b/adserver/staff/forms.py index d8c60571..e942348f 100644 --- a/adserver/staff/forms.py +++ b/adserver/staff/forms.py @@ -17,7 +17,6 @@ from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ from djstripe.models import Customer -from simple_history.utils import update_change_reason from ..constants import EMAILED from ..constants import PUBLISHER_HOUSE_CAMPAIGN @@ -110,7 +109,10 @@ def create_user(self): user_email = self.cleaned_data["user_email"] user = User.objects.create_user(name=user_name, email=user_email, password="") - update_change_reason(user, self.message) + + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(user, self.message) + if hasattr(user, "invite_user"): user.invite_user() return user @@ -134,7 +136,7 @@ def create_advertiser(self): campaign.publisher_groups.add(pub_group) flight_name = f"{advertiser_name} Initial Flight" - flight = Flight.objects.create( + Flight.objects.create( campaign=campaign, name=flight_name, slug=slugify(flight_name), @@ -145,9 +147,10 @@ def create_advertiser(self): }, ) - update_change_reason(advertiser, self.message) - update_change_reason(campaign, self.message) - update_change_reason(flight, self.message) + # See https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(advertiser, self.message) + # update_change_reason(campaign, self.message) + # update_change_reason(flight, self.message) return advertiser @@ -256,7 +259,10 @@ def create_user(self): user_email = self.cleaned_data["user_email"] user = User.objects.create_user(name=user_name, email=user_email, password="") - update_change_reason(user, self.message) + + # See https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(user, self.message) + if hasattr(user, "invite_user"): user.invite_user() return user @@ -277,7 +283,8 @@ def create_publisher(self): if group_obj: group_obj.publishers.add(publisher) - update_change_reason(publisher, self.message) + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(publisher, self.message) # Create this publisher's advertiser account self.create_publisher_advertiser_account(publisher) @@ -305,7 +312,7 @@ def create_publisher_advertiser_account(self, publisher): campaign.publisher_groups.add(pub_group) flight_name = f"{publisher.name} House Ads" - flight = Flight.objects.create( + Flight.objects.create( campaign=campaign, name=flight_name, slug=slugify(flight_name), @@ -316,9 +323,10 @@ def create_publisher_advertiser_account(self, publisher): }, ) - update_change_reason(advertiser, self.message) - update_change_reason(campaign, self.message) - update_change_reason(flight, self.message) + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(advertiser, self.message) + # update_change_reason(campaign, self.message) + # update_change_reason(flight, self.message) def save(self): """Create the publisher and associated objects. Send the invitation to the user account.""" @@ -408,6 +416,7 @@ def save(self): status=EMAILED, ) - update_change_reason(payout, "Payout via staff interface") + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason(payout, "Payout via staff interface") return payout diff --git a/adserver/tasks.py b/adserver/tasks.py index 5356959e..ead9638d 100644 --- a/adserver/tasks.py +++ b/adserver/tasks.py @@ -18,7 +18,6 @@ from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ from django_slack import slack_message -from simple_history.utils import update_change_reason from config.celery_app import app @@ -886,9 +885,10 @@ def notify_of_completed_flights(): flight.save() # Store the change reason in the history - update_change_reason( - flight, f"Hard stopped with ${value_remaining} value remaining." - ) + # See: https://github.com/jazzband/django-simple-history/issues/1181 + # update_change_reason( + # flight, f"Hard stopped with ${value_remaining} value remaining." + # ) completed_flights_by_advertiser[flight.campaign.advertiser.slug].append( flight