Commit 81ed5bd8 authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Merge branch 'qrcode' into dev

Merged qrcode branch into main dev branch.
parents 818b7d8b 4d4feb74
...@@ -6,6 +6,9 @@ Go is a drop-in URL shortening service. It aims to provide an easily ...@@ -6,6 +6,9 @@ Go is a drop-in URL shortening service. It aims to provide an easily
branded service for institutions that wish to widely disseminate branded service for institutions that wish to widely disseminate
information without unnecessarily outsourcing branding. information without unnecessarily outsourcing branding.
## To D0
* qr codes on links view-- need to save the pictures somewhere, render inline as well as in different formats and sizes for download, and be deleted along with the links
## Configuration ## Configuration
### settings.py ### settings.py
......
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils import timezone from django.utils import timezone
from django.conf import settings
import random, string import random, string
...@@ -25,6 +26,9 @@ class URL( models.Model ): ...@@ -25,6 +26,9 @@ class URL( models.Model ):
class Meta: class Meta:
ordering = ['short'] ordering = ['short']
def get_absolute_url(self):
return "%s/%s" % (settings.SERVERURL, self.short)
@staticmethod @staticmethod
def generate_valid_short(): def generate_valid_short():
selection = string.ascii_lowercase + string.digits selection = string.ascii_lowercase + string.digits
......
...@@ -54,7 +54,6 @@ def error_500(request): ...@@ -54,7 +54,6 @@ def error_500(request):
}, },
) )
############################################################################## ##############################################################################
""" """
Define user views here. Define user views here.
...@@ -137,6 +136,7 @@ def view(request, short): ...@@ -137,6 +136,7 @@ def view(request, short):
""" """
url = get_object_or_404(URL, short__iexact = short) url = get_object_or_404(URL, short__iexact = short)
return render(request, 'view.html', { return render(request, 'view.html', {
'url': url, 'url': url,
}, },
......
...@@ -7,3 +7,6 @@ DB_HOST = ...@@ -7,3 +7,6 @@ DB_HOST =
PIWIK_SITE_ID = PIWIK_SITE_ID =
PIWIK_URL = PIWIK_URL =
# Do not include a final slash!
SERVERURL =
...@@ -130,6 +130,7 @@ INSTALLED_APPS = ( ...@@ -130,6 +130,7 @@ INSTALLED_APPS = (
'piwik', 'piwik',
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
'django.contrib.admin', 'django.contrib.admin',
'qrcode',
# Uncomment the next line to enable admin documentation: # Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs', # 'django.contrib.admindocs',
) )
...@@ -219,3 +220,6 @@ AUTH_LDAP_ALWAYS_UPDATE_USER = True ...@@ -219,3 +220,6 @@ AUTH_LDAP_ALWAYS_UPDATE_USER = True
# Piwik settings. # Piwik settings.
PIWIK_SITE_ID = secret.PIWIK_SITE_ID PIWIK_SITE_ID = secret.PIWIK_SITE_ID
PIWIK_URL = secret.PIWIK_URL PIWIK_URL = secret.PIWIK_URL
SERVERURL = secret.SERVERURL
{% load go_extras %} {% load go_extras %}
{% load qr_tags %}
<div class="link-box"> <div class="link-box">
<p>
<p class="link">
<strong>Long:</strong> <a href="{{url.target}}">{{url.target}}</a> <strong>Long:</strong> <a href="{{url.target}}">{{url.target}}</a>
<br /> <br />
...@@ -23,4 +25,9 @@ ...@@ -23,4 +25,9 @@
</strong> </strong>
{% endif %} {% endif %}
</p> </p>
<p class="qr">
{% qr_from_text url.get_absolute_url 100 %}
</p>
</div> </div>
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