From 63db25bb5e1a2605c7a2fdaabcba32422191f70b Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Thu, 18 Jul 2013 13:46:46 +0200 Subject: Add a page to reattach a broken thread --- hyperkitty/lib/view_helpers.py | 1 + .../static/hyperkitty/css/hyperkitty-message.css | 34 +++++++++ .../static/hyperkitty/js/hyperkitty-thread.js | 30 ++++++++ hyperkitty/templates/ajax/reattach_suggest.html | 11 +++ hyperkitty/templates/messages/message.html | 5 +- hyperkitty/templates/reattach.html | 69 +++++++++++++++++ hyperkitty/templates/threads/right_col.html | 6 ++ hyperkitty/urls.py | 4 + hyperkitty/views/thread.py | 87 +++++++++++++++++++++- 9 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 hyperkitty/templates/ajax/reattach_suggest.html create mode 100644 hyperkitty/templates/reattach.html diff --git a/hyperkitty/lib/view_helpers.py b/hyperkitty/lib/view_helpers.py index a27baaf..1187335 100644 --- a/hyperkitty/lib/view_helpers.py +++ b/hyperkitty/lib/view_helpers.py @@ -32,6 +32,7 @@ from hyperkitty.views.forms import CategoryForm FLASH_MESSAGES = { "updated-ok": ("success", "The profile was successfully updated."), "sent-ok": ("success", "The message has been sent successfully."), + "attached-ok": ("success", "Thread successfully re-attached."), } diff --git a/hyperkitty/static/hyperkitty/css/hyperkitty-message.css b/hyperkitty/static/hyperkitty/css/hyperkitty-message.css index 2668f3a..769dc02 100644 --- a/hyperkitty/static/hyperkitty/css/hyperkitty-message.css +++ b/hyperkitty/static/hyperkitty/css/hyperkitty-message.css @@ -317,3 +317,37 @@ border-bottom: none; background-color: #eee; } + + +/* + * Re-attach threads + */ +.reattach-thread form { + margin-bottom: 0; +} +.reattach-thread form.search p { + line-height: 22px; +} +.reattach-thread form.search input { + margin-left: 3em; +} +.reattach-thread form.search input, +.reattach-thread form.search button { + font-size: 12px; + padding: 2px 8px; +} +.reattach-thread form img.ajaxloader { + margin-left: 1em; +} +.reattach-thread li.manual label { + display: inline; +} +.reattach-thread li.manual input { + margin-bottom: 0; +} +.reattach-thread li.manual input[type='text'] { + width: 22em; +} +.reattach-thread p.buttons { + margin-top: 2em; +} diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js b/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js index 069c4e9..e6c726f 100644 --- a/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-thread.js @@ -331,3 +331,33 @@ function update_thread_replies(url) { } load_more(url); } + + +/* + * Re-attach threads + */ +function setup_reattach() { + $(".reattach-thread li.manual input[type='text']").focus( function() { + $(this).parents("li").first() + .find("input[type='radio']") + .prop("checked", true); + }); + $(".reattach-thread form.search").submit(function (e) { + e.preventDefault(); + var results_elem = $(this).parent().find("ul.suggestions"); + var url = $(this).attr("action") + "?" + $(this).serialize(); + results_elem.find("img.ajaxloader").show(); + $.ajax({ + url: url, + success: function(data) { + results_elem.html(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert(jqXHR.responseText); + }, + complete: function(jqXHR, textStatus) { + results_elem.find("img.ajaxloader").hide(); + } + }); + }).submit(); +} diff --git a/hyperkitty/templates/ajax/reattach_suggest.html b/hyperkitty/templates/ajax/reattach_suggest.html new file mode 100644 index 0000000..7b94075 --- /dev/null +++ b/hyperkitty/templates/ajax/reattach_suggest.html @@ -0,0 +1,11 @@ +{% load hk_generic %} + + {% for s_thread in suggested_threads %} +
  • +
  • + {% empty %} +
  • (no suggestions)
  • + {% endfor %} diff --git a/hyperkitty/templates/messages/message.html b/hyperkitty/templates/messages/message.html index 2cfcdf8..453e248 100644 --- a/hyperkitty/templates/messages/message.html +++ b/hyperkitty/templates/messages/message.html @@ -27,7 +27,10 @@ {% gravatar email.sender_email 40 %}
    - {{email.sender_name|escapeemail}} + {{email.sender_name|escapeemail}} {% if use_mockups %}
    diff --git a/hyperkitty/templates/reattach.html b/hyperkitty/templates/reattach.html new file mode 100644 index 0000000..b2419c9 --- /dev/null +++ b/hyperkitty/templates/reattach.html @@ -0,0 +1,69 @@ +{% extends "base.html" %} +{% load url from future %} +{% load hk_generic %} +{% load storm %} + + +{% block title %} +Reattach a thread - {{ mlist.display_name|default:mlist.name|escapeemail }} - {{ app_name|title }} +{% endblock %} + +{% block content %} + +
    + +{% include 'threads/month_list.html' %} + +
    + +

    Re-attach a thread to another

    + +
    +

    Thread to re-attach: + {{ thread.subject }} + (started {{ thread.starting_email|get_date }}, last active: {{ thread|get_date }}) +

    + +
    + {% csrf_token %} +
      + Loading... +
    +
      +
    • + + +
    • +
    +

    + (there's no undoing!), or + go back to the thread. +

    +
    +
    + +
    + +
    + +{% endblock %} + +{% block additionaljs %} + +{% endblock %} diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html index 5384d03..c6d6d30 100644 --- a/hyperkitty/templates/threads/right_col.html +++ b/hyperkitty/templates/threads/right_col.html @@ -50,6 +50,12 @@ {{ addtag_form.as_p }}
    + {% if user.is_staff %} +

    + Reattach this thread +

    + {% endif %}
    participants ({{participants|length}})