diff --git a/polyphonic/library/templates/library/item_list_manage.html b/polyphonic/library/templates/library/item_list_manage.html index 60169ca..f6bd10b 100644 --- a/polyphonic/library/templates/library/item_list_manage.html +++ b/polyphonic/library/templates/library/item_list_manage.html @@ -2,7 +2,7 @@ {% load polyphonic %} {% block admin %} - + {% icon "add_circle" %} Add @@ -15,15 +15,6 @@ {% block page %}
-
-

Add from collection

-
- {% for access in project.ensemble.allowed_collections.all %} - {{ access.collection.name }} - {% endfor %} -
-
-
@@ -39,7 +30,7 @@ {% if not collection and not project %}{% endif %} - {% if project %} + {% endif %} {% empty %} @@ -102,3 +114,24 @@ Query="{{ meta.query }}" {% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/polyphonic/library/views/__init__.py b/polyphonic/library/views/__init__.py index d1cad3b..adf4007 100644 --- a/polyphonic/library/views/__init__.py +++ b/polyphonic/library/views/__init__.py @@ -1,5 +1,5 @@ from django.shortcuts import get_object_or_404, redirect, resolve_url -from django.http import HttpRequest +from django.http import HttpRequest, HttpResponse from django.views.generic import TemplateView from django.views.generic.detail import DetailView, SingleObjectMixin, View from django.views.generic.list import ListView @@ -11,6 +11,7 @@ from django.utils.timezone import now from django.template.loader import render_to_string from django.core.exceptions import SuspiciousOperation from django.core.paginator import Paginator + from django.http import Http404, HttpResponseRedirect import json @@ -301,9 +302,21 @@ class CollectionWorkListView(WorkListView): class ProjectWorkListView(WorkListView, ProjectMixin): + http_method_names = ["get", "post"] + def is_authorized(self): return ProjectMixin.is_authorized(self) + def post(self, request, project): + work = request.POST.get("work") + print("WORK", work) + + self.project.items.create( + work_id=work, checkout=now(), approved_by=request.user, order=100 + ) + + return HttpResponse(status=201) + def get_works(self): collections = self.get_collections() or [] print(collections) @@ -317,6 +330,7 @@ class ProjectWorkListView(WorkListView, ProjectMixin): def get_context_data(self, *args, **kwargs): data = super(ProjectWorkListView, self).get_context_data(*args, **kwargs) data["title"] = f"Library for {self.project.ensemble}" + data["current"] = set(self.project.items.values_list("work_id", flat=True)) return data
{{ item.work.name }} {% firstof item.work.duration '-:--' %} - + {% icon "delete" %} @@ -109,6 +100,7 @@ workList.addEventListener('dragstart', function(e) { if (!dragSrc) return; dragSrcNext = dragSrc.nextElementSibling; dragSrc.classList.add('dragging'); + e.dataTransfer.setDragImage(e.target, 0, 0); e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', dragSrc.dataset.pk); }); diff --git a/polyphonic/library/templates/library/work_list.html b/polyphonic/library/templates/library/work_list.html index 1e6993b..447eb2c 100644 --- a/polyphonic/library/templates/library/work_list.html +++ b/polyphonic/library/templates/library/work_list.html @@ -9,6 +9,12 @@ Add a work {% endif %} +{% if project %} + + {% icon "add_notes" %} + Back + +{% endif %} {% endblock %} {% block page %} @@ -54,7 +60,13 @@ {{ work.composer|truncatewords:3 }} {{ work.edition|truncatewords:2 }}{{ work.collection.name }}Add{% endif %} + {% if project %} + + +
No works found