Skip to content

Commit

Permalink
Revert "Print various helpers to help debug on Travis"
Browse files Browse the repository at this point in the history
This reverts commit fbb0847.
  • Loading branch information
josokinas committed Nov 3, 2018
1 parent bb8cedf commit 3f0b4d1
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions geokey_sapelli/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,12 @@ def get(self, request, project_id):
try: # Try getting previously generated link/token:
qr_link = SAPDownloadQRLink.objects.filter(access_token__user=request.user, sapelli_project=sapelli_project).latest('access_token__expires')
except BaseException, e:
print 'No QA link', e
pass
if qr_link is None or qr_link.access_token.is_expired():
if (qr_link is not None):
qr_link.access_token.delete() # qr_link will be deleted as well
# Generate new access token (valid for 1 day):
qr_link = SAPDownloadQRLink.create(user=request.user, sapelli_project=sapelli_project, days_valid=1)
print 'QR Link', qr_link
# Generate download url:
sap_download_url = (
request.build_absolute_uri(reverse('geokey_sapelli:sap_download_api', kwargs={'project_id': project_id})) +
Expand All @@ -772,25 +770,20 @@ def get(self, request, project_id):
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=5,
border=0)
print 'QR', qr
qr.add_data(sap_download_url)
qr.make(fit=True)
img_buffer = StringIO()
qr.make_image().save(img_buffer, "PNG")
print 'Made image'
# Grab img file from in-memory, make response with correct MIME-type
response = HttpResponse(img_buffer.getvalue(), content_type='image/png')
# ..and correct content-disposition
print 'Have response'
response['Content-Disposition'] = 'attachment; filename=%s' % request.path[request.path.rfind('/') + 1:]
# Add additional info as response headers:
response['X-QR-URL'] = sap_download_url
response['X-QR-Access-Token'] = qr_link.access_token.token
response['X-QR-Access-Token-Expires'] = qr_link.access_token.expires.isoformat()
print response
return response
except BaseException, e:
print e
return Response({'error': str(e)})

@handle_exceptions_for_ajax
Expand Down

0 comments on commit 3f0b4d1

Please sign in to comment.