From 38cc0ad87d5ecb5dbee6155ee74a217460856370 Mon Sep 17 00:00:00 2001 From: Tahiru Abdullai Date: Thu, 6 Jun 2024 09:08:46 +0000 Subject: [PATCH 1/3] Fix: Add error check for existing campaign follower Added error handling to prevent duplicate campaign followers. This is achieved by returning an error if a 'get_or_create' operation yields an existent campaign follower. This will minimize potential conflicts in the CampaignFollow objects. --- src/api/store/campaign.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/store/campaign.py b/src/api/store/campaign.py index 6c5890c9a..b0bf53bdd 100644 --- a/src/api/store/campaign.py +++ b/src/api/store/campaign.py @@ -922,6 +922,8 @@ def add_campaign_follower(self, context, args): args["community"] = community follower, _ = CampaignFollow.objects.get_or_create(campaign=campaign, **args) + if not _: + return None, CustomMassenergizeError("Follower already exists!") return follower, None except Exception as e: From 3f4bc79d86fedf0bc953fa74a930252fc0639a12 Mon Sep 17 00:00:00 2001 From: Tahiru Abdullai Date: Mon, 22 Jul 2024 14:26:32 +0000 Subject: [PATCH 2/3] test: Update test_campaigns to include email in payload Modified the test_campaigns integration test to include email within the payload for the "campaigns.follow" endpoint. The changes were made for both community admin and user test scenarios. --- src/api/tests/integration/test_campaigns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/tests/integration/test_campaigns.py b/src/api/tests/integration/test_campaigns.py index 8f2078ca1..ed078e60b 100644 --- a/src/api/tests/integration/test_campaigns.py +++ b/src/api/tests/integration/test_campaigns.py @@ -729,13 +729,13 @@ def test_add_campaign_follower(self): Console.header("Testing the campaigns.follow endpoint as a community admin.") signinAs(self.client, self.CADMIN) - response = self.make_request("campaigns.follow", payload) + response = self.make_request("campaigns.follow", {**payload, "email": "admin@me.com"}) self.assertEqual(response['success'], True) Console.header("Testing the campaigns.follow endpoint as a user.") signinAs(self.client, self.USER) - response = self.make_request("campaigns.follow", payload) + response = self.make_request("campaigns.follow", {**payload, "email": "new.user@gamil.com"}) self.assertEqual(response['success'], True) From 4c892159407e3f7b47cd151b89cd2aabf4e46f1b Mon Sep 17 00:00:00 2001 From: Tahiru Abdullai Date: Mon, 22 Jul 2024 14:30:21 +0000 Subject: [PATCH 3/3] feat: Add python-bidi library to requirements.txt The python-bidi library has been added to the project's dependencies in the requirements.txt file. --- src/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/requirements.txt b/src/requirements.txt index b4fdf4f92..71291e271 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -38,4 +38,5 @@ python-slugify==8.0.1 better-profanity==0.7.0 django-cid==2.3 watchtower==3.1.0 -coverage==7.5.0 \ No newline at end of file +coverage==7.5.0 +python-bidi==0.4.2 \ No newline at end of file