From 1dbfb7c34e3a70c1c62879df88decdc30bbf236a Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Sun, 13 Oct 2024 15:53:30 +0330 Subject: [PATCH 1/7] added autocomplete fields for admin panel --- authentication/admin.py | 6 ++++++ prizetap/admin.py | 7 +++++-- tokenTap/admin.py | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/authentication/admin.py b/authentication/admin.py index f6d1871b..45463db0 100644 --- a/authentication/admin.py +++ b/authentication/admin.py @@ -23,6 +23,7 @@ class ProfileAdmin(admin.ModelAdmin): class WalletAdmin(admin.ModelAdmin): list_display = ["pk", "wallet_type", "user_profile"] + autocomplete_fields = ["user_profile"] search_fields = [ "user_profile__initial_context_id", "wallet_type", @@ -34,6 +35,7 @@ class WalletAdmin(admin.ModelAdmin): class BrightIDConnectionAdmin(admin.ModelAdmin): list_display = ["pk", "user_profile", "context_id", "age"] + autocomplete_fields = ["user_profile"] search_fields = [ "context_id", ] @@ -42,21 +44,25 @@ class BrightIDConnectionAdmin(admin.ModelAdmin): class GitcoinPassportConnectionAdmin(admin.ModelAdmin): list_display = ["pk", "user_profile", "user_wallet_address"] search_fields = ["user_wallet_address", "user_profile__username"] + autocomplete_fields = ["user_profile"] class TwitterConnectionAdmin(admin.ModelAdmin): list_display = ["pk", "user_profile", "oauth_token"] search_fields = ["user_profile__username", "oauth_token"] + autocomplete_fields = ["user_profile"] class EnsConnectionAdmin(admin.ModelAdmin): list_display = ["pk", "user_profile", "user_wallet_address"] search_fields = ["user_profile__username", "user_wallet_address"] + autocomplete_fields = ["user_profile"] class FarcasterConnectionAdmin(admin.ModelAdmin): list_display = ["pk", "user_profile", "user_wallet_address"] search_fields = ["user_profile__username", "user_wallet_address"] + autocomplete_fields = ["user_profile"] admin.site.register(Wallet, WalletAdmin) diff --git a/prizetap/admin.py b/prizetap/admin.py index f32a74d3..8aa37546 100644 --- a/prizetap/admin.py +++ b/prizetap/admin.py @@ -7,9 +7,10 @@ class RaffleAdmin(admin.ModelAdmin): list_display = ["pk", "name", "creator_name", "status"] readonly_fields = ["vrf_tx_hash"] + autocomplete_fields = ["creator_profile"] -class RaffleٍEntryAdmin(admin.ModelAdmin): +class RaffleEntryAdmin(admin.ModelAdmin): list_display = [ "pk", "raffle", @@ -17,13 +18,15 @@ class RaffleٍEntryAdmin(admin.ModelAdmin): "tx_hash", "age", ] + autocomplete_fields = ["wallet_address"] class LineaRaffleEntriesAdmin(admin.ModelAdmin): list_display = ["pk", "wallet_address", "is_winner"] + autocomplete_fields = ["wallet_address"] admin.site.register(Raffle, RaffleAdmin) -admin.site.register(RaffleEntry, RaffleٍEntryAdmin) +admin.site.register(RaffleEntry, RaffleEntryAdmin) admin.site.register(Constraint, UserConstraintBaseAdmin) admin.site.register(LineaRaffleEntries, LineaRaffleEntriesAdmin) diff --git a/tokenTap/admin.py b/tokenTap/admin.py index b43bed54..803d1761 100644 --- a/tokenTap/admin.py +++ b/tokenTap/admin.py @@ -36,6 +36,7 @@ class TokenDistributionClaimAdmin(admin.ModelAdmin): ] search_fields = ["user_wallet_address"] list_filter = ["token_distribution", "status"] + autocomplete_fields = ["user_profile"] class GlobalSettingsAdmin(admin.ModelAdmin): From 73cfdbeafd61c86ab0689fa6958be9352c424dc3 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Tue, 15 Oct 2024 09:34:05 +0330 Subject: [PATCH 2/7] removed extra autocomplete field --- prizetap/admin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/prizetap/admin.py b/prizetap/admin.py index 8aa37546..f19c5400 100644 --- a/prizetap/admin.py +++ b/prizetap/admin.py @@ -23,7 +23,6 @@ class RaffleEntryAdmin(admin.ModelAdmin): class LineaRaffleEntriesAdmin(admin.ModelAdmin): list_display = ["pk", "wallet_address", "is_winner"] - autocomplete_fields = ["wallet_address"] admin.site.register(Raffle, RaffleAdmin) From d6ffc3b38297ef99ed42597873910c7bbc83d303 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Tue, 15 Oct 2024 10:35:34 +0330 Subject: [PATCH 3/7] fixed errors --- prizetap/admin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/prizetap/admin.py b/prizetap/admin.py index f19c5400..c8579c00 100644 --- a/prizetap/admin.py +++ b/prizetap/admin.py @@ -18,7 +18,6 @@ class RaffleEntryAdmin(admin.ModelAdmin): "tx_hash", "age", ] - autocomplete_fields = ["wallet_address"] class LineaRaffleEntriesAdmin(admin.ModelAdmin): From a4da9d4222e166c12b982517f830c9080bfe6c25 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Sat, 19 Oct 2024 12:23:46 +0330 Subject: [PATCH 4/7] mocked passport receive signal --- authentication/tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/authentication/tests.py b/authentication/tests.py index f5e5779b..cc8208a1 100644 --- a/authentication/tests.py +++ b/authentication/tests.py @@ -69,6 +69,11 @@ def create_verified_user() -> UserProfile: return user +@patch("authentication.models.submit_passport") +def mock_submit_passport(sender, instance: GitcoinPassportConnection, **kwargs): + return None + + def create_new_wallet(user_profile, _address, wallet_type) -> Wallet: wallet, is_create = Wallet.objects.get_or_create( user_profile=user_profile, address=_address, wallet_type=wallet_type From 16b5724e0af2cb43ba3f225e48e935c7690f0cc2 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Sat, 19 Oct 2024 12:41:19 +0330 Subject: [PATCH 5/7] fixed patching mock gitcoin passport decorator --- authentication/tests.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/authentication/tests.py b/authentication/tests.py index cc8208a1..f300e43b 100644 --- a/authentication/tests.py +++ b/authentication/tests.py @@ -69,11 +69,6 @@ def create_verified_user() -> UserProfile: return user -@patch("authentication.models.submit_passport") -def mock_submit_passport(sender, instance: GitcoinPassportConnection, **kwargs): - return None - - def create_new_wallet(user_profile, _address, wallet_type) -> Wallet: wallet, is_create = Wallet.objects.get_or_create( user_profile=user_profile, address=_address, wallet_type=wallet_type @@ -688,6 +683,7 @@ def setUp(self) -> None: user_profile=self.user_profile, _address=self.address, wallet_type="EVM" ) + @patch("authentication.models.submit_passport", lambda a, b: True) def test_gitcoin_passport_connection_successful(self): self.client.force_authenticate(user=self.user_profile.user) response = self.client.post( @@ -702,6 +698,7 @@ def test_gitcoin_passport_connection_successful(self): 1, ) + @patch("authentication.models.submit_passport", lambda a, b: True) def test_gitcoin_passport_not_exists(self): address_does_not_have_gitcoin_passport = ( "0x0cE49AF5d8c5A70Edacd7115084B2b3041fE4fF5" @@ -718,6 +715,7 @@ def test_gitcoin_passport_not_exists(self): ) self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST) + @patch("authentication.models.submit_passport", lambda a, b: True) def test_address_not_owned_by_user(self): self.client.force_authenticate(user=self.user_profile.user) response = self.client.post( From 21baa4d883662a235a6532fa5b4656f37a7ddae8 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Wed, 23 Oct 2024 11:50:52 +0330 Subject: [PATCH 6/7] changed gitcoin test address --- authentication/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentication/tests.py b/authentication/tests.py index f300e43b..35db4e4a 100644 --- a/authentication/tests.py +++ b/authentication/tests.py @@ -677,7 +677,7 @@ def test_api_verify_login_signature_with_deleted_wallet(self): class TestGitcoinPassportThirdPartyConnection(APITestCase): def setUp(self) -> None: - self.address = "0x0cE49AF5d8c5A70Edacd7115084B2b3041fE4fF6" + self.address = "0x05204E317D25eb172115546297b056965bE2C74d" self.user_profile = create_new_user() create_new_wallet( user_profile=self.user_profile, _address=self.address, wallet_type="EVM" From 3d9862ef88b5c66f3c1d29df0a932cc8af1df4b0 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Wed, 23 Oct 2024 11:55:12 +0330 Subject: [PATCH 7/7] fixed gitcoin passport test address fixed loading tokentap params --- core/tests.py | 2 +- tokenTap/validators.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tests.py b/core/tests.py index 79c94471..3d2d8e44 100644 --- a/core/tests.py +++ b/core/tests.py @@ -316,7 +316,7 @@ def test_EAS_attest_constraints(self): class TestGitcoinPassportConstraint(BaseTestCase): def setUp(self): super().setUp() - self.address = "0x0cE49AF5d8c5A70Edacd7115084B2b3041fE4fF6" + self.address = "0x05204E317D25eb172115546297b056965bE2C74d" self.user_profile = self.user_profile create_new_wallet( user_profile=self.user_profile, _address=self.address, wallet_type="EVM" diff --git a/tokenTap/validators.py b/tokenTap/validators.py index 88708800..7d4d10dc 100644 --- a/tokenTap/validators.py +++ b/tokenTap/validators.py @@ -52,7 +52,7 @@ def __init__( def check_user_permissions(self, raise_exception=True): try: - param_values = json.loads(self.td.constraint_params) + param_values = json.loads(self.td.constraint_params or "{}") except Exception as e: logging.error("Error parsing constraint params", e) param_values = {}