Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect grants old urls to /explorer #8748

Merged
merged 3 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down
4 changes: 3 additions & 1 deletion app/grants/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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('<slug:grant_type>/', grants_type_redirect, name='grants_type_redirect'),
path('<slug:grant_type>', grants_type_redirect, name='grants_type_redirect2'),
path('explorer/<slug:grant_type>', grants_by_grant_type, name='grants_by_category2'),
path('explorer/<slug:grant_type>/', grants_by_grant_type, name='grants_by_category'),
path('v1/api/grants', grants_info, name='grants_info'),
Expand Down
9 changes: 9 additions & 0 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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')
Expand Down