Skip to content

Commit

Permalink
fix: avoid transforming empty variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna committed Feb 1, 2024
1 parent ba2bf64 commit d18dba0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bd_api/apps/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,13 @@ def get(self, request, *args, **kwargs):
url = request.build_absolute_uri()
domain = URL_MAPPING[urlparse(url).netloc]

dataset = request.GET.get("dataset")
dataset_slug = dataset.replace("-", "_")
if dataset := request.GET.get("dataset"):
dataset_slug = dataset.replace("-", "_")

if resource := CloudTable.objects.filter(gcp_dataset_id=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.table.dataset.id}")
if resource := CloudTable.objects.filter(gcp_dataset_id=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.table.dataset.id}")

if resource := Dataset.objects.filter(slug__icontains=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.id}")
if resource := Dataset.objects.filter(slug__icontains=dataset_slug).first():
return HttpResponseRedirect(f"{domain}/dataset/{resource.id}")

return HttpResponseRedirect(f"{domain}/404")

0 comments on commit d18dba0

Please sign in to comment.