From 39deff37c950534d2a44e4bd040e49118b34a731 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Thu, 11 Jul 2013 17:18:25 +0200 Subject: Add the category on the threads list --- hyperkitty/static/css/hyperkitty-common.css | 23 ++++++++++++++++++++++ hyperkitty/static/css/hyperkitty-message.css | 15 ++------------ hyperkitty/static/css/hyperkitty-threadslist.css | 7 +++++++ hyperkitty/static/js/hyperkitty-thread.js | 14 +++++++------ hyperkitty/templates/thread.html | 2 +- hyperkitty/templates/thread_list.html | 1 + hyperkitty/templates/threads/category.html | 1 + .../templates/threads/summary_thread_large.html | 3 +++ hyperkitty/views/list.py | 6 +++++- hyperkitty/views/thread.py | 6 +++++- 10 files changed, 56 insertions(+), 22 deletions(-) diff --git a/hyperkitty/static/css/hyperkitty-common.css b/hyperkitty/static/css/hyperkitty-common.css index 7b3190b..419cb7f 100644 --- a/hyperkitty/static/css/hyperkitty-common.css +++ b/hyperkitty/static/css/hyperkitty-common.css @@ -295,3 +295,26 @@ a.thread-new strong { .ui-autocomplete-loading { background: white url('../img/ajax-loader.gif') right center no-repeat; } + + +/* + * Categories + */ + +.thread-category { + padding: 0; + padding-bottom: 10px; +} +.thread-category form { + margin: 0; + display: none; +} +.thread-category form select { + font-size: 90%; + width: 12em; +} +.thread-category form .errorlist { + display: none; /* Displayed manually */ +} + + diff --git a/hyperkitty/static/css/hyperkitty-message.css b/hyperkitty/static/css/hyperkitty-message.css index 1e74517..0f7ca20 100644 --- a/hyperkitty/static/css/hyperkitty-message.css +++ b/hyperkitty/static/css/hyperkitty-message.css @@ -150,25 +150,14 @@ /* Categories */ -#thread-category { - padding: 0; - padding-bottom: 10px; +.thread-header .thread-category { text-align: center; } -#thread-category form { - margin: 0; - display: none; -} -#thread-category form select { - font-size: 90%; - width: 12em; -} -#thread-category a.label { +.thread-header .thread-category a.label { font-size: 120%; line-height: 120%; } - /* Participants */ #participants { diff --git a/hyperkitty/static/css/hyperkitty-threadslist.css b/hyperkitty/static/css/hyperkitty-threadslist.css index 610d603..653d5d7 100644 --- a/hyperkitty/static/css/hyperkitty-threadslist.css +++ b/hyperkitty/static/css/hyperkitty-threadslist.css @@ -184,3 +184,10 @@ .type_test { background-color: rgb(200, 171, 55); } + + + +/* Category */ +.thread .thread-category { + float: right; +} diff --git a/hyperkitty/static/js/hyperkitty-thread.js b/hyperkitty/static/js/hyperkitty-thread.js index f2c3cd0..2ce664d 100644 --- a/hyperkitty/static/js/hyperkitty-thread.js +++ b/hyperkitty/static/js/hyperkitty-thread.js @@ -25,15 +25,16 @@ */ function setup_category() { - $("#thread-category form").submit(function (e) { + $(".thread-category form").submit(function (e) { e.preventDefault(); + var widget = $(this).parents(".thread-category").first(); $.ajax({ type: "POST", //dataType: "json", data : $(this).serialize(), url: $(this).attr("action"), success: function(data) { - $("#thread-category").html(data); + widget.html(data); setup_category(); }, error: function(jqXHR, textStatus, errorThrown) { @@ -42,12 +43,13 @@ function setup_category() { } }); }); - $("#thread-category a.label").click(function(e) { + $(".thread-category a.label").click(function(e) { e.preventDefault(); - $(this).hide(); - $("#thread-category form").show(); + $(this).hide() + .parents(".thread-category").first() + .find("form").show(); }); - $("#thread-category form select").change(function() { + $(".thread-category form select").change(function() { $(this).parents("form").first().submit(); }); } diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html index ad07d9f..04e9522 100644 --- a/hyperkitty/templates/thread.html +++ b/hyperkitty/templates/thread.html @@ -27,7 +27,7 @@ {% endif %} {% endfor %}

{{ subject }}

-
+
{% include 'threads/category.html' %}
diff --git a/hyperkitty/templates/thread_list.html b/hyperkitty/templates/thread_list.html index 32bbdfe..c6c70c7 100644 --- a/hyperkitty/templates/thread_list.html +++ b/hyperkitty/templates/thread_list.html @@ -68,6 +68,7 @@ $(document).ready(function() { $(this).addClass("collapsed"); } }); + setup_category(); }); {% endblock %} diff --git a/hyperkitty/templates/threads/category.html b/hyperkitty/templates/threads/category.html index ccacad5..e6e1f03 100644 --- a/hyperkitty/templates/threads/category.html +++ b/hyperkitty/templates/threads/category.html @@ -1,5 +1,6 @@ {% load url from future %} + {{ category_form.errors.category }} {% if category %} diff --git a/hyperkitty/templates/threads/summary_thread_large.html b/hyperkitty/templates/threads/summary_thread_large.html index 66bff39..f03bbbf 100644 --- a/hyperkitty/templates/threads/summary_thread_large.html +++ b/hyperkitty/templates/threads/summary_thread_large.html @@ -13,6 +13,9 @@ href="{% url 'thread' threadid=thread.thread_id mlist_fqdn=mlist.name %}" >{{ thread.starting_email.subject|strip_subject:mlist }} {{ thread|get_date|timesince }} + + {% include 'threads/category.html' with category=thread.category_hk category_form=thread.category_form threadid=thread.thread_id %} +
{% if thread.category_tag %} diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index 8b222c4..8a96fd2 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -33,7 +33,7 @@ from django.http import Http404 from hyperkitty.models import Tag, Favorite, LastView from hyperkitty.lib import get_months, get_store, get_display_dates, daterange -from hyperkitty.lib import FLASH_MESSAGES, paginate +from hyperkitty.lib import FLASH_MESSAGES, paginate, get_category_widget from hyperkitty.lib.voting import get_votes, set_message_votes, set_thread_votes @@ -107,6 +107,10 @@ def _thread_list(request, mlist, threads, template_name='thread_list.html', extr except Tag.DoesNotExist: thread.tags = [] + # Category + thread.category_hk, thread.category_form = \ + get_category_widget(request, thread.category) + # Unread status thread.unread = False if request.user.is_authenticated(): diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 365dca9..ecfd6eb 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -36,6 +36,7 @@ import robot_detection from hyperkitty.models import Tag, Favorite, LastView, ThreadCategory from hyperkitty.views.forms import AddTagForm, ReplyForm, CategoryForm from hyperkitty.lib import get_months, get_store, stripped_subject +from hyperkitty.lib import get_category_widget from hyperkitty.lib.voting import set_message_votes @@ -303,7 +304,10 @@ def set_category(request, mlist_fqdn, threadid): store = get_store(request) category, category_form = get_category_widget(request) thread = store.get_thread(mlist_fqdn, threadid) - if category.name != thread.category: + if not category and thread.category: + thread.category = None + store.commit() + elif category and category.name != thread.category: thread.category = category.name store.commit() -- cgit