Feature: Built django-images into Pinry

This commit is contained in:
winkidney
2018-08-25 23:43:52 -07:00
parent f85a1e7301
commit a59f3cf9eb
16 changed files with 609 additions and 6 deletions

14
django_images/views.py Normal file
View File

@@ -0,0 +1,14 @@
from django.http import HttpResponseNotFound
from django.shortcuts import get_object_or_404, redirect
from . import models
from .settings import IMAGE_SIZES
def thumbnail(request, image_id, size):
image = get_object_or_404(models.Image, id=image_id)
if size not in IMAGE_SIZES:
return HttpResponseNotFound()
return redirect(models.Thumbnail.objects.get_or_create_at_size(image.id,
size))