From b28371b3e68aa2d6fa2d3ef7ccf9cc08b3114525 Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 6 Apr 2021 12:16:39 -0600 Subject: [PATCH 1/2] typo --- app/grants/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/grants/models.py b/app/grants/models.py index a5ad146ce4c..6bf1334b8eb 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -1736,7 +1736,7 @@ def blockexplorer_url_helper(self, tx_id): if self.checkout_type == 'eth_zksync': return f'https://zkscan.io/explorer/transactions/{tx_id.replace("sync-tx:", "")}' if self.checkout_type == 'eth_std': - network_sub = f"{{self.subscription.network}}." if self.subscription and self.subscription.network != 'mainnet' else '' + network_sub = f"{self.subscription.network}." if self.subscription and self.subscription.network != 'mainnet' else '' return f'https://{network_sub}etherscan.io/tx/{tx_id}' # TODO: support all block explorers for diff chains return '' From 7b0288c49718621b2ccf1cab8a3f9053a27937a9 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 6 Apr 2021 18:00:21 -0300 Subject: [PATCH 2/2] redirect grants urls to explorer --- app/grants/urls.py | 4 +++- app/grants/views.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/grants/urls.py b/app/grants/urls.py index b99c215e801..fde9c75ac6e 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -28,7 +28,7 @@ get_interrupted_contributions, get_replaced_tx, grant_activity, grant_categories, grant_details, grant_details_api, grant_details_contributions, grant_details_contributors, grant_edit, grant_fund, grant_new, grant_new_whitelabel, grants, grants_addr_as_json, grants_bulk_add, grants_by_grant_type, grants_cart_view, grants_info, grants_landing, - ingest_contributions, ingest_contributions_view, invoice, leaderboard, manage_ethereum_cart_data, + grants_type_redirect, ingest_contributions, ingest_contributions_view, invoice, leaderboard, manage_ethereum_cart_data, new_matching_partner, profile, quickstart, remove_grant_from_collection, save_collection, subscription_cancel, toggle_grant_favorite, verify_grant, ) @@ -92,6 +92,8 @@ path('cart', grants_cart_view, name='cart'), path('add-missing-contributions', ingest_contributions_view, name='ingest_contributions_view'), path('get-interrupted-contributions', get_interrupted_contributions, name='get_interrupted_contributions'), + path('/', grants_type_redirect, name='grants_type_redirect'), + path('', grants_type_redirect, name='grants_type_redirect2'), path('explorer/', grants_by_grant_type, name='grants_by_category2'), path('explorer//', grants_by_grant_type, name='grants_by_category'), path('v1/api/grants', grants_info, name='grants_info'), diff --git a/app/grants/views.py b/app/grants/views.py index dec89bb0a4b..b09ac9fab68 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -91,6 +91,7 @@ from retail.helpers import get_ip from townsquare.models import Announcement, Comment, Favorite, PinnedPost from townsquare.utils import can_pin +from urllib.parse import urlencode from web3 import HTTPProvider, Web3 logger = logging.getLogger(__name__) @@ -1072,6 +1073,14 @@ def grants_by_grant_type(request, grant_type): return response +def grants_type_redirect(request, grant_type): + """Redirect old grant url with search params to /explorer keeping query params.""" + base_url = reverse('grants:grants_by_category', kwargs={"grant_type":grant_type}) + query_string = urlencode(request.GET) + url = '{}?{}'.format(base_url, query_string) + return redirect(url) + + def grants_by_grant_clr(request, clr_round): """Handle grants explorer.""" grant_type = request.GET.get('type', 'all')