From: Marek Stępniowski Date: Fri, 5 Sep 2008 08:54:06 +0000 (+0200) Subject: Changed sets to shelfs. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/77effa3964014b07dbdf73a9e67eb0b20749d50b?ds=inline Changed sets to shelfs. --- diff --git a/catalogue/forms.py b/catalogue/forms.py index 1c6ca83cd..583c9aed7 100644 --- a/catalogue/forms.py +++ b/catalogue/forms.py @@ -29,7 +29,7 @@ class BookSetsForm(forms.Form): def __init__(self, book, user, *args, **kwargs): super(BookSetsForm, self).__init__(*args, **kwargs) self.fields['set_ids'] = forms.MultipleChoiceField( - label=u'Zestawy', + label=u'Półki', required=False, choices=[(tag.id, tag.name) for tag in Tag.objects.filter(category='set', user=user)], initial=[tag.id for tag in book.tags.filter(category='set', user=user)], diff --git a/catalogue/urls.py b/catalogue/urls.py index 2fc293912..c253ba1b0 100644 --- a/catalogue/urls.py +++ b/catalogue/urls.py @@ -5,8 +5,8 @@ from django.conf.urls.defaults import * urlpatterns = patterns('catalogue.views', url(r'^$', 'main_page', name='main_page'), url(r'^lektury/', 'book_list'), - url(r'^lektura/(?P[a-zA-Z0-9-]+)/zestawy/', 'book_sets'), - url(r'^zestawy/nowy/$', 'new_set'), + url(r'^lektura/(?P[a-zA-Z0-9-]+)/polki/', 'book_sets'), + url(r'^polki/nowa/$', 'new_set'), url(r'^lektura/(?P[a-zA-Z0-9-]+)/$', 'book_detail'), url(r'^tags/$', 'tags_starting_with', name='hint'), url(r'^szukaj/$', 'search', name='search'), diff --git a/catalogue/views.py b/catalogue/views.py index 8feb63c22..de41e1518 100644 --- a/catalogue/views.py +++ b/catalogue/views.py @@ -165,19 +165,21 @@ def login(request): return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data)) -@login_required def book_sets(request, slug): book = get_object_or_404(models.Book, slug=slug) user_sets = models.Tag.objects.filter(category='set', user=request.user) book_sets = book.tags.filter(category='set', user=request.user) + if not request.user.is_authenticated(): + return HttpResponse('

Aby zarządzać swoimi półkami, musisz się zalogować.

') + if request.method == 'POST': form = forms.BookSetsForm(book, request.user, request.POST) if form.is_valid(): book.tags = ([models.Tag.objects.get(pk=id) for id in form.cleaned_data['set_ids']] + list(book.tags.filter(~Q(category='set') | ~Q(user=request.user)))) if request.is_ajax(): - return HttpResponse('

Zestawy zostały zapisane

') + return HttpResponse('

Półki zostały zapisane

') else: return HttpResponseRedirect('/') else: diff --git a/templates/base.html b/templates/base.html index 8accaee6a..aa0f01c9c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,7 @@ {% if user.is_authenticated %}

Zalogowany jako {{ user.username }} - | Zestawy + | Moje półki {% if user.is_staff %} | Administracja {% endif %} diff --git a/templates/catalogue/book_sets.html b/templates/catalogue/book_sets.html index 1ae34c3cd..c7394186a 100644 --- a/templates/catalogue/book_sets.html +++ b/templates/catalogue/book_sets.html @@ -1,17 +1,17 @@ -

Zestawy zawierające utwór {{ book.title }}

+

Półki zawierające utwór {{ book.title }}

{% if not user.tag_set.count %} -

Nie posiadasz żadnych zestawów. Jeśli chcesz, możesz utworzyć nowy zestaw poniżej.

+

Nie posiadasz żadnych półek. Jeśli chcesz, możesz utworzyć nową półkę poniżej.

{% else %}
  1. {{ form.set_ids }}
  2. -
  3. +
{% endif %}
    -
  1. {{ new_set_form.name }}
  2. +
  3. {{ new_set_form.name }}
\ No newline at end of file diff --git a/templates/catalogue/book_short.html b/templates/catalogue/book_short.html index eca279e20..019a7b8a6 100644 --- a/templates/catalogue/book_short.html +++ b/templates/catalogue/book_short.html @@ -1,7 +1,7 @@
{# {% if request.user.is_authenticated %} #} {# {% endif %} #}
diff --git a/templates/catalogue/main_page.html b/templates/catalogue/main_page.html index 221595fbf..0c58adac9 100644 --- a/templates/catalogue/main_page.html +++ b/templates/catalogue/main_page.html @@ -24,7 +24,7 @@
{% if categories.set %} -

Zestawy

+

Półki

    {% for set in categories.set %}
  • {{ set }} ({{ set.count }})
  • diff --git a/templates/catalogue/tagged_object_list.html b/templates/catalogue/tagged_object_list.html index 3aa9a36b4..de7d4f095 100644 --- a/templates/catalogue/tagged_object_list.html +++ b/templates/catalogue/tagged_object_list.html @@ -78,7 +78,7 @@
    {% if categories.set %} -

    Zestawy

    +

    Półki