Esempio n. 1
0
 def get_file(self, request, filename, *args, **kwargs):
     """ Download a media file.
     """
     attachment = self.filter_queryset(self.get_queryset())\
         .filter(filename=filename)\
         .first()
     if not attachment:
         raise Http404()
     return view_attachment(attachment)
Esempio n. 2
0
 def get(self, request, filename, *args, **kwargs):
     try:
         if self.work.publication_document.filename == filename:
             if self.work.publication_document.trusted_url:
                 return redirect(self.work.publication_document.trusted_url)
             return view_attachment(self.work.publication_document)
     except PublicationDocument.DoesNotExist:
         pass
     raise Http404()
Esempio n. 3
0
    def get_publication_document(self, request, filename, *args, **kwargs):
        """ Download the media publication file for a work.
        """
        work = self.get_document().work

        if work.publication_document and work.publication_document.filename == filename:
            if work.publication_document.trusted_url:
                return redirect(work.publication_document.trusted_url)
            return view_attachment(work.publication_document)

        raise Http404()
Esempio n. 4
0
 def get(self, request, filename, *args, **kwargs):
     if self.work.publication_document and self.work.publication_document.filename == filename:
         if self.work.publication_document.trusted_url:
             return redirect(self.work.publication_document.trusted_url)
         return view_attachment(self.work.publication_document)
     return Http404()
Esempio n. 5
0
 def get(self, request, filename, *args, **kwargs):
     if self.work.publication_document and self.work.publication_document.filename == filename:
         return view_attachment(self.work.publication_document)
     else:
         return Http404()