Commit 48281229 authored by fred's avatar fred

add links to nonstop home, and handle permissions

parent 8001623b
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop - Artist: {{ object.name }}</h2> <h2>Nonstop - Artist: {{ object.name }}</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<h3>{% trans "Most recently played" %}</h3> <h3>{% trans "Most recently played" %}</h3>
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop - Artists</h2> <h2>Nonstop - Artists</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<ul class="artists-list"> <ul class="artists-list">
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop{% if zone %} — {{zone.title}} — {{count}} tracks{% endif %}</h2> <h2>Nonstop{% if zone %} — {{zone.title}} — {{count}} tracks{% endif %}</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<form id="track-search"> <form id="track-search">
{{ form.as_p }} {{ form.as_p }}
......
...@@ -5,14 +5,21 @@ ...@@ -5,14 +5,21 @@
<h2>Nonstop</h2> <h2>Nonstop</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<ul> <ul>
<li><a href="{% url 'nonstop-today' %}">Aujourd'hui</a> (avec des liens pour naviguer vers les autres jours)</li> <li><a href="{% url 'nonstop-today' %}">Aujourd'hui</a> (avec des liens pour naviguer vers les autres jours)</li>
<li><a href="{% url 'artist-list' %}">Artistes</a> présents (un jour ou l'autre) dans le nonstop</li> <li><a href="{% url 'artist-list' %}">Artistes</a> présents (un jour ou l'autre) dans le nonstop</li>
<li><a href="{% url 'nonstop-search' %}">Recherche</a> dans les pistes et artistes</li> <li><a href="{% url 'nonstop-search' %}">Recherche</a> dans les pistes et artistes</li>
{% if perms.nonstop.add_track %}
<li><a href="{% url 'nonstop-upload-tracks' %}">Ajout de nouveaux morceaux</a></li> <li><a href="{% url 'nonstop-upload-tracks' %}">Ajout de nouveaux morceaux</a></li>
<li><a href="{% url 'nonstop-recent-tracks' %}">Édition rapide de métadonnées de nouveaux morceaux</a> (langue, Instru, SABAM, CFWB)</li> <li><a href="{% url 'nonstop-recent-tracks' %}">Édition rapide de métadonnées de nouveaux morceaux</a> (langue, Instru, SABAM, CFWB)</li>
<li><a href="{% url 'nonstop-cleanup' %}">Nettoyage de vieux morceaux</a></li> <li><a href="{% url 'nonstop-cleanup' %}">Nettoyage de vieux morceaux</a></li>
{% endif %}
</ul> </ul>
{% endblock %} {% endblock %}
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop - {% trans "Recent Tracks" %}</h2> <h2>Nonstop - {% trans "Recent Tracks" %}</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop</h2> <h2>Nonstop</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<form id="track-search"> <form id="track-search">
{{ form.as_p }} {{ form.as_p }}
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
{% endblock %} {% endblock %}
{% block more-user-links %} {% block more-user-links %}
<a href="{% url 'nonstop-today' %}">Aujourd'hui</a> {{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
......
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
<a href="?from=-30d">during last month</a> <a href="?from=-30d">during last month</a>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<div class="nonstop-stats"> <div class="nonstop-stats">
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop - Track: {{ object.artist.name }} / {{ object.title }}</h2> <h2>Nonstop - Track: {{ object.artist.name }} / {{ object.title }}</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
{% if not object.file_exists %} {% if not object.file_exists %}
...@@ -31,6 +36,7 @@ ...@@ -31,6 +36,7 @@
<p>In nonstop since {{ object.added_to_nonstop_timestamp|date:"SHORT_DATE_FORMAT" }}.</p> <p>In nonstop since {{ object.added_to_nonstop_timestamp|date:"SHORT_DATE_FORMAT" }}.</p>
{% if perms.nonstop.add_track %}
<form method="POST"> <form method="POST">
{% csrf_token %} {% csrf_token %}
{{ metadata_form.as_p }} {{ metadata_form.as_p }}
...@@ -41,6 +47,8 @@ ...@@ -41,6 +47,8 @@
</div> </div>
{% endif %} {% endif %}
{% endif %}
<style> <style>
ul.soma-list { ul.soma-list {
float: left; float: left;
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<h2>Nonstop - {% trans "Upload" %}</h2> <h2>Nonstop - {% trans "Upload" %}</h2>
{% endblock %} {% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
{% endblock %}
{% block content %} {% block content %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
...@@ -14,7 +19,7 @@ ...@@ -14,7 +19,7 @@
{{ form.as_p }} {{ form.as_p }}
<div class="buttons"> <div class="buttons">
<button class="submit-button">{% trans "Upload" %}</button> <button class="submit-button">{% trans "Upload" %}</button>
<a class="cancel" href="...">{% trans "Cancel" %}</a> <a class="cancel" href="{% url 'nonstop-quick-links' %}">{% trans "Cancel" %}</a>
</div> </div>
</form> </form>
......
...@@ -69,6 +69,7 @@ class TrackDetailView(DetailView): ...@@ -69,6 +69,7 @@ class TrackDetailView(DetailView):
return ctx return ctx
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
assert self.request.user.has_perm('nonstop.add_tracks')
instance = self.get_object() instance = self.get_object()
old_nonstop_zones = copy.copy(instance.nonstop_zones.all()) old_nonstop_zones = copy.copy(instance.nonstop_zones.all())
form = TrackMetaForm(request.POST, instance=instance) form = TrackMetaForm(request.POST, instance=instance)
...@@ -171,6 +172,7 @@ class UploadTracksView(FormView): ...@@ -171,6 +172,7 @@ class UploadTracksView(FormView):
success_url = '.' success_url = '.'
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
assert self.request.user.has_perm('nonstop.add_tracks')
form_class = self.get_form_class() form_class = self.get_form_class()
form = self.get_form(form_class) form = self.get_form(form_class)
tracks = request.FILES.getlist('tracks') tracks = request.FILES.getlist('tracks')
...@@ -228,6 +230,7 @@ class RecentTracksView(ListView): ...@@ -228,6 +230,7 @@ class RecentTracksView(ListView):
return Track.objects.exclude(creation_timestamp__isnull=True).order_by('-creation_timestamp')[:50] return Track.objects.exclude(creation_timestamp__isnull=True).order_by('-creation_timestamp')[:50]
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
assert self.request.user.has_perm('nonstop.add_tracks')
for track_id in request.POST.getlist('track'): for track_id in request.POST.getlist('track'):
track = Track.objects.get(id=track_id) track = Track.objects.get(id=track_id)
track.language = request.POST.get('lang-%s' % track_id, '') track.language = request.POST.get('lang-%s' % track_id, '')
...@@ -302,6 +305,7 @@ class CleanupView(TemplateView): ...@@ -302,6 +305,7 @@ class CleanupView(TemplateView):
return ctx return ctx
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
assert self.request.user.has_perm('nonstop.add_tracks')
count = 0 count = 0
for track_id in request.POST.getlist('track'): for track_id in request.POST.getlist('track'):
if request.POST.get('remove-%s' % track_id): if request.POST.get('remove-%s' % track_id):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment