Put the shortcuts for returning 40* responses into lemoncurry.utils

This commit is contained in:
Danielle McLean 2017-11-02 16:16:04 +11:00
parent 1e56d5a09a
commit 41d490ea80
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
2 changed files with 23 additions and 25 deletions

View file

@ -2,6 +2,7 @@ import json
from accept_types import get_best_match
from django.conf import settings
from django.http import HttpResponse
from django.http import HttpResponseForbidden, HttpResponseBadRequest
from os.path import join
from shorturls import default_converter as converter
from shorturls.templatetags.shorturl import ShortURL
@ -48,3 +49,11 @@ def shortlink(obj):
if hasattr(settings, 'SHORT_BASE_URL') and settings.SHORT_BASE_URL:
return urljoin(settings.SHORT_BASE_URL, prefix + tinyid)
return '/' + prefix + tinyid
def bad_req(message):
return HttpResponseBadRequest(message, content_type='text/plain')
def forbid(message):
return HttpResponseForbidden(message, content_type='text/plain')