This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/src/attachments/views.py

16 lines
569 B
Python

from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from attachments.models import Attachment
def get_original(_request: WSGIRequest, pk: int) -> HttpResponse:
attachment = get_object_or_404(Attachment, pk=pk)
return HttpResponseRedirect(attachment.original_file.url)
def get_processed(_request: WSGIRequest, pk: int) -> HttpResponse:
attachment = get_object_or_404(Attachment, pk=pk)
return HttpResponseRedirect(attachment.processed_file.url)