Library working:

This commit is contained in:
Tris
2021-03-22 10:30:13 +11:00
parent 35555c3321
commit 1581f56b74
32 changed files with 511 additions and 211 deletions
@@ -1,27 +1,37 @@
{% extends "interface/project_base.html" %}
{% block admin %}
<a href="{% url 'playlist_manage' project.pk %}"><i class="fas fa-list"></i><span class="smhide admin">Change works</span></a>
<a href="{% url 'item_list_manage' project.pk %}"><i class="fas fa-list"></i><span class="smhide admin">Change items</span></a>
{% endblock %}
{% block page %}
<p>
This page lets you download a complete set of music for your part by selecting your instrument
and optionally a part (e.g. Flute 1 or 2).<br/>
You can also tweak which parts you get in the list or click on a piece for more download options.
You can also tweak which parts you get for each piece, or click on a piece for more download options.
</p>
<form action="" method="post" target="_blank" style="display: flex;">
{% csrf_token %}
<table style="max-width: 600px; margin: 10pt auto;" class="item-table">
<thead>
</thead>
<div style="margin: 0px 20px; text-align: right;">
<label for="instrument-select">Pick your instrument</label>
<select id="instrument-select" name="instrument" onchange="updateParts()">
{% for tag, instrument in instruments %}
<option value="{{ tag }}">{{ instrument }}</option>
{% endfor %}
</select><br/><br/>
<label for="part-preference">Part preference</label>
<input id="part-preference" name="part" type="number" value="0" min="0" max="4" onchange="updateParts()" size="1"/><br/><br/>
<button type="submit" style="height: 32px;"><i class="fas fa-copy"></i> Get My Parts!</button>
</div>
<table style="max-width: 600px; margin: 10pt auto;" class="">
<tbody>
{% for item in object_list %}
<tr>
<td>{{ forloop.counter }})</td>
<td>
<a href="{% url 'work_detail' item.work.pk %}">{{ item.work.name }}</a>
</td>
<td class="select-cell">
<td class="">
<input type="hidden" name="works" value="{{ item.work.pk }}"/>
<select name="instruments">
<option value='-'>None</option>
@@ -34,17 +44,6 @@
{% endfor %}
</tbody>
</table>
<div style="margin: 0px 20px; text-align: right;">
<label for="instrument-select">Pick your instrument</label>
<select id="instrument-select" name="instrument" onchange="updateParts()">
{% for tag, instrument in instruments %}
<option value="{{ tag }}">{{ instrument }}</option>
{% endfor %}
</select><br/><br/>
<label for="part-preference">Part preference</label>
<input id="part-preference" name="part" type="number" value="0" min="0" max="4" onchange="updateParts()" size="1"/><br/><br/>
<button type="submit" style="height: 32px;"><i class="fas fa-copy"></i> Get My Parts!</button>
</div>
</form>
{% endblock %}
@@ -2,28 +2,31 @@
{% block admin %}
<a href="#" onclick="save()"><i class="fas fa-save"></i><span class="smhide action">Save</span></a>
<a href="{% url 'playlist_append' project.pk %}"><i class="fas fa-plus-circle"></i><span class="smhide action">Add</a></a>
<a href="{% url 'item_list_append' project.pk %}"><i class="fas fa-plus-circle"></i><span class="smhide action">Add</a></a>
{% endblock %}
{% block page %}
<table style="max-width: 600px; margin: 10pt auto;" class="item-table">
<thead>
<tr>
<th>Piece</th>
<th>Part</th>
<th>Item</th>
<th>Time</th>
</tr>
</thead>
<tbody id="work-list">
{% for item in object_list %}
<tr data-pk="{{ item.pk }}" data-order="{{ forloop.counter }}">
<td>{{ item.work.name }}</td>
<td>{% firstof item.work.running_time '?' %}</td>
<td style="text-align: center;">
<i class="fas fa-arrow-up clickable" title="Move up" onclick="moveItem({{ item.pk }}, -1)"></i>
<i class="fas fa-arrow-down clickable" title="Move down" onclick="moveItem({{ item.pk }}, 1)"></i>
<i class="fas fa-trash clickable" title="Remove"></i>
<i class="fas fa-trash clickable" title="Remove" onClick="moveItem({{ item.pk }}, 0)"></i>
</td>
</tr>
{% empty %}
<tr><td colspan="2">No items</td></tr>
{% endfor %}
</tbody>
</table>
@@ -47,8 +50,13 @@ function moveItem(pk, dir) {
// check the direction is sensible
if (i + dir < 0 || i + dir >= items.length) return;
items[i].dataset.order = parseInt(items[i].dataset.order) + dir;
items[i+dir].dataset.order = parseInt(items[i+dir].dataset.order) - dir;
if (dir === 0) {
items[i].dataset.order = -1;
items[i].style = "display: none";
} else {
items[i].dataset.order = parseInt(items[i].dataset.order) + dir;
items[i+dir].dataset.order = parseInt(items[i+dir].dataset.order) - dir;
}
items.sort((a, b) => parseInt(a.dataset.order) - parseInt(b.dataset.order))
@@ -76,7 +84,7 @@ function save() {
}).then((response) => {
if (response.ok) {
dirty=false;
window.location = "{% url 'project_playlist' project=project.pk %}";
window.location = "{% url 'item_list' project=project.pk %}";
} else {
alert("Failed: " + response.statusText)
}
@@ -0,0 +1 @@
<p>Click the '<a href="{% url 'item_list' project=project.pk %}">My Music</a>' button below to access your parts...</p>
+6 -1
View File
@@ -1 +1,6 @@
<a href="{% url 'project_playlist' project=project.pk %}">My Music</a>
{% if project %}
<a href="{% url 'item_list' project=project.pk %}">My Music</a>
{% endif %}
{% if request.is_admin %}
<a href="{% url 'work_list' %}">Works</a>
{% endif %}
+6 -2
View File
@@ -1,4 +1,5 @@
{% extends 'interface/project_base.html' %}
{% load path_filters %}
{% block admin %}
<a href="{% url 'document_add' work.pk %}"><i class="fas fa-plus-circle"></i> Upload file</a>
@@ -13,14 +14,17 @@
<li><a href="{% url 'part_download' pk=part.pk filename=part.filename %}" target="part_{{ part.pk }}" rel="">{{ part.instrument }}</a></li>
{% endfor %}
</ul>
<a href="{% url 'work_partset' pk=work.pk %}"><i class="fas fa-print"></i> Print part set</a>
<h3>Original Documents</h3>
<ul>
{% for doc in work.docs.all %}
<li>
<a href="{% url 'document_download' pk=doc.pk %}" target="_blank">{{ doc.upload.name }}</a> [{{ doc.parts.count }} parts]
<a href="{% url 'document_download' pk=doc.pk %}" target="_blank">{{ doc.upload.name|basename }}</a>
&nbsp;
[{{ doc.parts.count }} parts]
{% if request.is_admin %}
<a href="{% url 'document_annotate' pk=doc.pk %}"><i class="fas fa-edit"></i></a>
<a href="{% url 'document_annotate' pk=doc.pk %}"><i class="fas fa-tags"></i></a>
{% endif %}
</li>
{% endfor %}
@@ -0,0 +1,31 @@
{% extends "interface/project_base.html" %}
{% block page %}
<h2><a href="{% url 'work_list' %}">Works</a> / <a href="{% url 'work_detail' pk=work.pk %}">{{ work.name }}</a></h2>
<form action="" method="post" target="_blank">
{% csrf_token %}
<table style="margin: 0px auto">
<thead>
<tr>
<th>Part</th>
<th>Copies</th>
</tr>
</thead>
<tbody>
{% for part in work.parts %}
<tr>
<td>{{ part.instrument }}</td>
<td>
<input name="parts" type="hidden" value="{{ part.tag }}">
<input name="copies" type="number" value="{% if part.tag == 'Score' %}0{% else %}1{% endif %}" size="1">
</td>
</tr>
{% endfor %}
<tr>
<td colspan="2" style="text-align: center;"><button type="submit"><i class="fas fa-print"></i> Print</button></td>
</tr>
</tbody>
</table>
</form>
{% endblock %}