Skip to content

Commit

Permalink
Merge pull request #230 from duncanpeacock/issue-216-sentry-dns
Browse files Browse the repository at this point in the history
Fix so that docker-compose.test.yml will pass.
  • Loading branch information
reskyner authored Dec 17, 2020
2 parents c6c292b + e40ad8b commit 77c5423
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions viewer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,27 @@ def get_template_protein(self, obj):
def get_zip_archive(self, obj):
request = self.context["request"]
# This is to map links to HTTPS to avoid Mixed Content warnings from Chrome browsers
# SECURE_PROXY_SSL_HEADER is referenced because it is used in redirecting URLs - if it is changed
# it make affect this code.
# Using relative links will probably also work, but This workaround allows both the 'download structures'
# button and the DRF API call to work.
# SECURE_PROXY_SSL_HEADER is referenced because it is used in redirecting URLs - if
# it is changed it may affect this code.
# Using relative links will probably also work, but This workaround allows both the
# 'download structures' button and the DRF API call to work.
# The if-check is because the filefield in target has null=True.
# Note that this link will not work on local
https_host = settings.SECURE_PROXY_SSL_HEADER[1]+'://'+request.get_host()
return urljoin(https_host, obj.zip_archive.url)
https_host = settings.SECURE_PROXY_SSL_HEADER[1] + '://' + request.get_host()
if hasattr(obj, 'zip_archive') and obj.zip_archive.name:
return urljoin(https_host, obj.zip_archive.url)
else:
return

def get_metadata(self, obj):
request = self.context["request"]
# This is to map links to HTTPS to avoid Mixed Content warnings from Chrome browsers
# Note that this link will not work on local - see above.
https_host = settings.SECURE_PROXY_SSL_HEADER[1]+'://'+request.get_host()
return urljoin(https_host, obj.metadata.url)
# See above for details.
https_host = settings.SECURE_PROXY_SSL_HEADER[1] + '://' + request.get_host()
if hasattr(obj, 'metadata') and obj.metadata.name:
return urljoin(https_host, obj.metadata.url)
else:
return

class Meta:
model = Target
Expand Down Expand Up @@ -458,4 +465,4 @@ def get_text_scores(self, obj):
# desc_dict = {}
# for desc in descriptions:
# desc_dict[desc.name] = desc.description
# return desc_dict
# return desc_dict

0 comments on commit 77c5423

Please sign in to comment.