Minor UI Tweaks

This commit is contained in:
Tris Forster
2024-06-21 15:42:09 +10:00
parent 04bf1ab1f3
commit 78789c02ed
10 changed files with 128 additions and 51 deletions
+21 -4
View File
@@ -1,4 +1,5 @@
from django.shortcuts import get_object_or_404, redirect, resolve_url
from django.views.generic import TemplateView
from django.views.generic.detail import DetailView, SingleObjectMixin, View
from django.views.generic.list import ListView, MultipleObjectMixin
from django.views.generic.edit import CreateView, FormView, UpdateView, DeleteView
@@ -18,6 +19,7 @@ import re
from interface.views import EnsembleMixin, ProjectMixin, AuthorizedResourceMixin
from interface.models import Project
from interface.utils import signed_url
from library.models import Collection, Work, Document, Section
from library.music_tags import MUSIC_TAGS, MusicTag, auto_tag
from library import forms, models
@@ -416,9 +418,11 @@ class DocumentDownloadView(DocumentMixin, SingleObjectMixin, View):
self.args = args
self.object = self.get_object()
#response = FileResponse(self.object.upload, content_type="application/pdf")
#return response
return redirect(self.object.upload.url)
if request.GET.get('method') == 'direct':
return redirect(self.object.upload.url)
response = FileResponse(self.object.upload.open('rb'), content_type="application/pdf")
return response
class DocumentAnnotateView(DocumentMixin, DetailView):
template_name = 'library/document_annotate.html'
@@ -446,6 +450,8 @@ class DocumentAnnotateView(DocumentMixin, DetailView):
for part in data['document'].sections.all():
pages.append((part.tag, part.start, part.end))
data['url'] = signed_url('document_download', collection=data['collection'].pk, pk=data['document'].pk)
data['json_data'] = {'pageTags': pages, 'instruments': dict(MUSIC_TAGS)}
return data
@@ -479,4 +485,15 @@ class PartDownloadView(CollectionMixin, SingleObjectMixin, View):
def get_object(self):
return Section.objects.filter(doc__work__collection=self.collection).select_related('doc', 'doc__work').get(pk=self.kwargs['section'])
return Section.objects.filter(doc__work__collection=self.collection).select_related('doc', 'doc__work').get(pk=self.kwargs['section'])
class StorageBrowserView(CollectionMixin, TemplateView):
template_name = "library/storage_browser.html"
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
folder = self.kwargs.get('folder') or data['collection'].prefix
data['folders'], data['files'] = data['collection'].storage.instance().listdir(folder)
return data