-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from localcontexts/develop
Update to fix NDL and some misc GIS errors
- Loading branch information
Showing
21 changed files
with
811 additions
and
87 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
from urllib.parse import urlparse | ||
from urllib.parse import urljoin | ||
|
||
from django import template | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def external_api(external_url: str) -> str: | ||
""" | ||
Tag converts an external_url into an internal_url | ||
so the response can be mocked with a fixture. | ||
Args: | ||
external_url: Url to an external API resource. | ||
Returns: | ||
When TEST_LIVE_SERVER_DOMAIN is available, the url is transformed so | ||
the external domain is swapped with the TEST_LIVE_SERVER_DOMAIN. | ||
""" | ||
test_live_server_domain = os.environ.get('TEST_LIVE_SERVER_DOMAIN') | ||
if not test_live_server_domain: | ||
return external_url | ||
url_components = urlparse(external_url) | ||
|
||
try: | ||
# return the internal_url formed by the domain and url_components.path | ||
return urljoin(test_live_server_domain, url_components.path) | ||
except Exception: | ||
return external_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.