Commit 5fac4d54 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

began adding qrcode to link page

parent c015691f
...@@ -29,6 +29,10 @@ def error_500(request): ...@@ -29,6 +29,10 @@ def error_500(request):
}, },
) )
def qrcode(url):
img = qrcode.make(url)
return img
# Homepage view. # Homepage view.
@login_required @login_required
def index(request): def index(request):
...@@ -75,8 +79,12 @@ def index(request): ...@@ -75,8 +79,12 @@ def index(request):
# Preview a link. # Preview a link.
def view(request, short): def view(request, short):
url = get_object_or_404(URL, short__iexact = short) url = get_object_or_404(URL, short__iexact = short)
qrcode = qrcode(url)
return render(request, 'view.html', { return render(request, 'view.html', {
'url': url, 'url': url,
'qrcode' : qrcode,
}, },
) )
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<strong>Expires:</strong> {{url.expires|default_if_none:"Never"}} <strong>Expires:</strong> {{url.expires|default_if_none:"Never"}}
<br /> <br />
<strong>QR Code:</strong> {{qrcode}}
<br />
<strong> <strong>
<a href="{%url 'delete' url.short%}" <a href="{%url 'delete' url.short%}"
onclick="return confirm('Are you sure you want to delete this link?');"> onclick="return confirm('Are you sure you want to delete this link?');">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment