Remove django-shorturls with my own implementation, since it's incompatible with Django 2 and unmaintained

This commit is contained in:
Danielle McLean 2018-03-21 21:50:40 +11:00
parent 27e0cb9a34
commit 098284a617
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
18 changed files with 252 additions and 184 deletions

16
lemonshort/short_url.py Normal file
View file

@ -0,0 +1,16 @@
from django.apps import apps
from django.conf import settings
from .convert import id_to_abc
prefixes = {}
def short_url(entity):
if not prefixes:
for k, m in settings.SHORTEN_MODELS.items():
prefixes[apps.get_model(m)] = k
base = '/'
if hasattr(settings, 'SHORT_BASE_URL'):
base = settings.SHORT_BASE_URL
return base + prefixes[type(entity)] + id_to_abc(entity.id)