Skip to content

Commit

Permalink
Réunion des vues d'organisation et d'affichage des carnets
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Jun 15, 2014
1 parent 3fe0e31 commit 0344bff
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 76 deletions.
2 changes: 1 addition & 1 deletion generator/templates/generator/current_songbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2 title="{{ current_songbook.title }}">
{{ current_songbook.title }}
</h2>
<small>
<a href="{% url "item_list" slug=current_songbook.slug id=current_songbook.id %}">
<a href="{% url "show_songbook" slug=current_songbook.slug id=current_songbook.id %}">
{% trans "Modifier l'ordre et les sections" %}
</a>
</small>
Expand Down
4 changes: 0 additions & 4 deletions generator/templates/generator/menu/songbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<a href="{{ url }}"{% if request.path == url %} class="active"{% endif %}>
&nbsp;{{ songbook.title|truncatechars:15 }}&nbsp;
</a>
{% url 'item_list' id=id slug=slug as url%}
<a href="{{ url }}"{% if request.path == url %} class="active"{% endif %}>
{% trans "Ordre des chansons" %}
</a>
{% url 'edit_songbook' id=id slug=slug as url%}
<a href="{{ url }}"{% if request.path == url %} class="active"{% endif %}>
{% trans "Paramètres" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{% extends "generator/layout/full_layout.html" %}
{% load i18n %}
{% load staticfiles %}

{% block title %} {{ songbook.title }} {% endblock %}

{% block appmenu %}
{% include "generator/menu/songbook.html" %}
{% endblock %}

{% block content %}
<a href="{% url "set_current_songbook" %}?songbook={{songbook.id}}" class="back">
{% trans "Ajouter des chants au carnet" %}
</a>
Expand All @@ -24,7 +16,7 @@
<form class="selection" method="post" action="{% url 'change_item_list' id=songbook.id slug=songbook.slug %}">
{% csrf_token %}
<input type="submit" value="{% trans "Enregistrer les changements" %}">
<input type="hidden" name="next" value="{% url "item_list" id=songbook.id slug=songbook.slug %}">
<input type="hidden" name="next" value="{% url "show_songbook" id=songbook.id slug=songbook.slug %}">
<ol class="selection ordering">
{% for item in items_list %}
<li class="{{ item.item_type.model}}">
Expand All @@ -48,9 +40,9 @@
{% endif %}
</li>
{% empty %}
<li>
<p>
{% trans "Ce carnet est vide" %}
</li>
</p>
{% endfor %}
</ol>
<p class="section">
Expand All @@ -61,5 +53,3 @@
</p>
<input type="submit" value="{% trans "Enregistrer les changements" %}">
</form>

{% endblock %}
37 changes: 37 additions & 0 deletions generator/templates/generator/show_items_in_songbook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% load i18n %}
<div id='sb_content'>
<ul class="selection">
{% for item in items_list %}
{% if item.item_type.model == "section" %}
</ul>
<h4 class="section">{{item.item.name}}</h4>
<ul class="selection">
{% elif item.item_type.model == "song" %}
{% with song=item.item %}
<li>
<label class="song" for="song_{{ song.id }}" title="{{ song.title }}">
{{ song.title }}
</label>
<a class="details artist" href="{% url "song_list_by_artist" artist=song.artist.slug %}" title="{{ song.artist.name }}">
{{ song.artist.name }}
</a>
<a class="details lyrics" href="{% url "show_song" slug=song.slug artist=song.artist.slug %}">
{% trans "Paroles" %}
</a>
</li>
{% endwith %}
{% endif %}
{% empty %}
<li>
<em>{% trans "Ce carnet est vide" %}</em>
</li>
{% endfor %}
</ul>
{% if can_edit %}
<div>
<a href="{% url "set_current_songbook" %}?songbook={{songbook.id}}">
{% trans "Ajouter des chants au carnet" %}
</a>
</div>
{% endif %}
</div>
45 changes: 11 additions & 34 deletions generator/templates/generator/show_songbook.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{% extends "generator/layout/full_layout.html" %} {% load i18n %}
{% extends "generator/layout/full_layout.html" %}
{% load i18n %}

{% block title %} {{ songbook.title }} {% endblock %}

{% block appmenu %}
{% if user.profile == songbook.user %}
{% if can_edit %}
{% include "generator/menu/songbook.html" %}
{% endif %}
{% endblock %}

{% block content %}
{% if user.profile == songbook.user %}
{% if can_edit %}
<a href="{% url "songbook_private_list" %}" class="back">
{% trans "Mes carnets" %}
</a>
Expand All @@ -18,37 +19,13 @@
{% trans "Carnets publics" %}
</a>
{% endif %}
<div id='sb_content'>
<ul class="selection">
{% for item in item_list %}
{% if item.item_type.model == "section" %}
</ul>
<h4 class="section">{{item.item.name}}</h4>
<ul class="selection">
{% elif item.item_type.model == "song" %}
{% with song=item.item %}
<li>
<label class="song" for="song_{{ song.id }}" title="{{ song.title }}">
{{ song.title }}
</label>
<a class="details artist" href="{% url "song_list_by_artist" artist=song.artist.slug %}" title="{{ song.artist.name }}">{{ song.artist.name }}</a>
<a class="details lyrics" href="{% url "show_song" slug=song.slug artist=song.artist.slug %}">{% trans "Paroles" %}</a>
</li>
{% endwith %}
{% endif %}
{% empty %}
<li>
<em>{% trans "Ce carnet est vide" %}</em>
</li>
{% endfor %}
</ul>
{% if can_edit %}
<div>
<a href="{% url "set_current_songbook" %}?songbook={{songbook.id}}">
{% trans "Ajouter des chants au carnet" %}</a>
</div>
{% endif %}
</div>

{% if can_edit %}
{% include "generator/order_items_in_songbook.html" %}
{% else %}
{% include "generator/show_items_in_songbook.html" %}
{% endif %}

<aside class="playlist">
<h3>{{songbook.title}}</h3>
<p>{{ songbook.description }}</p>
Expand Down
5 changes: 1 addition & 4 deletions generator/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
NewSongbook, ShowSongbook, SongbookPublicList, SongbookPrivateList, \
UpdateSongbook, DeleteSongbook, \
reset_password, reset_password_confirm, password_reset_done, \
password_reset_complete, ItemsListInSongbook, move_or_delete_items, \
password_reset_complete, move_or_delete_items, \
FlatPage
from django.views.generic.base import TemplateView

Expand Down Expand Up @@ -58,9 +58,6 @@
url(r'^songbooks/(?P<id>\d+)-(?P<slug>[\w-]+)/$',
ShowSongbook.as_view(),
name="show_songbook"),
url(r'^songbooks/(?P<id>\d+)-(?P<slug>[\w-]+)/songs$',
ItemsListInSongbook.as_view(),
name="item_list"),
url(r'^songbooks/(?P<id>\d+)-(?P<slug>[\w-]+)/change$',
move_or_delete_items,
name="change_item_list"),
Expand Down
22 changes: 2 additions & 20 deletions generator/views/songbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def get_queryset(self):

def get_context_data(self, **kwargs):
context = super(ShowSongbook, self).get_context_data(**kwargs)
item_list = ItemsInSongbook.objects.filter(songbook=self.object)
context['item_list'] = item_list
items_list = ItemsInSongbook.objects.filter(songbook=self.object)
context['items_list'] = items_list
if self.request.user == self.object.user.user:
context['can_edit'] = True
else:
Expand All @@ -104,24 +104,6 @@ def form_valid(self, form):
return super(UpdateSongbook, self).form_valid(form)


class ItemsListInSongbook(OwnerRequiredMixin, ListView):
model = ItemsInSongbook
context_object_name = "items_list"
template_name = "generator/items_in_songbook.html"
songbook = None

def get_queryset(self):
songbook_id = self.kwargs.get('id', None)
slug = self.kwargs.get('slug', None)
self.songbook = get_object_or_404(Songbook, id=songbook_id, slug=slug)
return ItemsInSongbook.objects.filter(songbook=self.songbook)

def get_context_data(self, **kwargs):
context = super(ItemsListInSongbook, self).get_context_data(**kwargs)
context['songbook'] = self.songbook
return context


@login_required
def set_current_songbook(request):
"""Set a songbook for edition with sessions
Expand Down

0 comments on commit 0344bff

Please sign in to comment.