From: Marek Stępniowski Date: Fri, 5 Sep 2008 11:22:08 +0000 (+0200) Subject: Added 'user shelves' tool menu. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/6fe9513613b3d0dcfc934c41a5bfa9b71f341b06 Added 'user shelves' tool menu. --- diff --git a/catalogue/urls.py b/catalogue/urls.py index d454fd478..12eaa47a4 100644 --- a/catalogue/urls.py +++ b/catalogue/urls.py @@ -4,11 +4,13 @@ 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-]+)/polki/', 'book_sets'), - url(r'^fragment/(?P[0-9]+)/polki/', 'fragment_sets'), - url(r'^polki/nowa/$', 'new_set'), - url(r'^lektura/(?P[a-zA-Z0-9-]+)/$', 'book_detail'), + url(r'^polki/$', 'user_shelves', name='user_shelves'), + url(r'^polki/(?P[a-zA-Z0-9-]+)/usun/$', 'delete_shelf', name='delete_shelf'), + url(r'^lektury/', 'book_list', name='book_list'), + url(r'^lektura/(?P[a-zA-Z0-9-]+)/polki/', 'book_sets', name='book_shelves'), + url(r'^fragment/(?P[0-9]+)/polki/', 'fragment_sets', name='fragment_shelves'), + url(r'^polki/nowa/$', 'new_set', name='new_set'), + url(r'^lektura/(?P[a-zA-Z0-9-]+)/$', 'book_detail', name='book_detail'), url(r'^tags/$', 'tags_starting_with', name='hint'), url(r'^szukaj/$', 'search', name='search'), url(r'^(?P[a-zA-Z-/]+)/$', 'tagged_object_list', name='tagged_object_list'), diff --git a/catalogue/views.py b/catalogue/views.py index 2719884df..b3f2d5bfb 100644 --- a/catalogue/views.py +++ b/catalogue/views.py @@ -221,8 +221,24 @@ def new_set(request): new_set_form = forms.NewSetForm(request.POST) if new_set_form.is_valid(): new_set = new_set_form.save(request.user) - return HttpResponse('

Zestaw %s został utworzony

' % new_set) + return HttpResponse(u'

Zestaw %s został utworzony

' % new_set) return render_to_response('catalogue/book_sets.html', locals(), context_instance=RequestContext(request)) + +@login_required +@require_POST +def delete_shelf(request, slug): + user_set = get_object_or_404(models.Tag, slug=slug, category='set', user=request.user) + user_set.delete() + return HttpResponse(u'

Zestaw %s został usunięty

' % user_set.name) + + +@login_required +def user_shelves(request): + shelves = models.Tag.objects.filter(category='set', user=request.user) + new_set_form = forms.NewSetForm() + return render_to_response('catalogue/user_shelves.html', locals(), + context_instance=RequestContext(request)) + diff --git a/media/css/master.css b/media/css/master.css index da61511cb..a7b33e6a3 100644 --- a/media/css/master.css +++ b/media/css/master.css @@ -343,6 +343,8 @@ em { /* ================ */ /* = Modal Window = */ /* ================ */ +.jqmOverlay { background-color: #000; } + #set-window { position: absolute; display: none; @@ -366,9 +368,6 @@ em { padding: 1em; } -.jqmOverlay { background-color: #000; } - - #login-register-window { position: absolute; display: none; @@ -397,6 +396,44 @@ em { padding: 1em; } +#user-shelves-window { + position: absolute; + display: none; + width: 28em; + background-color: transparent; + margin-top: -0.5em; + margin-left: 1em; +} + +#user-shelves-window div.header { + background-color: #FFF; + border-right: 0.3em solid #DDD; + width: 4em; + right: 0; + left: auto; + padding: 0.5em 1em 0.5em 1em; + float: right; + text-align: center; +} + +#user-shelves-window div.target { + clear: both; + background-color: #FFF; + border-right: 0.3em solid #DDD; + border-bottom: 0.3em solid #DDD; + padding: 1em; +} + +#user-shelves-window ul { + list-style: none; + padding: 0; +} + +#user-shelves-window a.delete-shelf { + color: #900; + float: right; +} + /* ======================== */ /* = Alphabetic book list = */ /* ======================== */ diff --git a/media/js/catalogue.js b/media/js/catalogue.js index bdceb1a64..d403a702b 100644 --- a/media/js/catalogue.js +++ b/media/js/catalogue.js @@ -88,6 +88,40 @@ hash.w.show(); } }); - $('#login-register-window').labelify({labelledClass: 'blur'}); + + $('#user-shelves-window').jqm({ + ajax: '@href', + target: $('#user-shelves-window div.target')[0], + overlay: 60, + trigger: '#user-shelves-link', + onShow: function(hash) { + var offset = $(hash.t).offset(); + hash.w.css({position: 'absolute', left: offset.left - hash.w.width() + $(hash.t).width(), top: offset.top}); + $('div.header', hash.w).css({width: $(hash.t).width()}); + hash.w.show(); + }, + onLoad: function(hash) { + $('form', hash.w).ajaxForm({ + target: $('#user-shelves-window div.target'), + success: function() { setTimeout(function() { $('#user-shelves-window').jqmHide() }, 1000) } + }); + + $('ul.shelf-list li', hash.w).hover(function() { + $(this).css({background: '#EEE', cursor: 'pointer'}); + }, function() { + $(this).css({background: 'transparent'}); + }).click(function() { + location.href = $('a.visit-shelf', this).attr('href'); + }); + + $('.delete-shelf').click(function() { + $.post($(this).attr('href'), function(data, textStatus) { + $('#user-shelves-window div.target').html(data); + setTimeout(function() { $('#user-shelves-window').jqmHide() }, 1000); + }); + return false; + }); + } + }); }); })(jQuery) \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index aa0f01c9c..8c8f1c68b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,7 @@ {% if user.is_authenticated %}

Zalogowany jako {{ user.username }} - | Moje półki + | Moje półki {% if user.is_staff %} | Administracja {% endif %} @@ -89,5 +89,11 @@ +

+ +
+

* Ładowanie

+
+
diff --git a/templates/catalogue/user_shelves.html b/templates/catalogue/user_shelves.html new file mode 100644 index 000000000..44517c550 --- /dev/null +++ b/templates/catalogue/user_shelves.html @@ -0,0 +1,15 @@ +

Moje półki

+{% if shelves %} + +{% else %} +

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

+{% endif %} +
+
+
    +
  1. {{ new_set_form.name }}
  2. +