From 448b122b6e4522d66b6b71f4822ad1caf9f9c3f3 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 14 Jul 2014 15:23:23 -0300 Subject: bugfixes in premoderation and allowed loading more moderation messages when few are left --- askbot/media/js/user.js | 27 +++++++++++++++++++++++++-- askbot/media/style/style.css | 6 +++++- askbot/media/style/style.less | 9 +++++---- askbot/models/question.py | 19 +++++++++++++++++-- askbot/templates/moderation/queue.html | 4 ++-- askbot/templates/question/question_card.html | 2 +- 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/askbot/media/js/user.js b/askbot/media/js/user.js index d79a3986..11457803 100644 --- a/askbot/media/js/user.js +++ b/askbot/media/js/user.js @@ -129,6 +129,10 @@ PostModerationControls.prototype.setEntryCount = function(count) { this._entryCount.html(count); }; +PostModerationControls.prototype.getEntryCount = function() { + return this.getCheckBoxes().length; +}; + PostModerationControls.prototype.getCheckBoxes = function() { return this._element.find('.messages input[type="checkbox"]'); }; @@ -180,8 +184,27 @@ PostModerationControls.prototype.getModHandler = function(action, items, optReas me.removeEntries(response_data['memo_ids']); me.setEntryCount(response_data['memo_count']); } - if (response_data['message']) { - me.showMessage(response_data['message']); + + var message = response_data['message'] || ''; + if (me.getEntryCount() < 10 && response_data['memo_count'] > 9) { + if (message) { + message += '. ' + } + var junk = $('#junk-mod'); + if (junk.length == 0) { + junk = me.makeElement('div'); + junk.attr('id', 'junk-mod'); + junk.hide(); + $(document).append(junk); + } + var a = me.makeElement('a'); + a.attr('href', window.location.href); + a.text(gettext('Load more items.')); + junk.append(a); + message += a[0].outerHTML; + } + if (message) { + me.showMessage(message); } } }); diff --git a/askbot/media/style/style.css b/askbot/media/style/style.css index ab5e12a6..b9bb6643 100644 --- a/askbot/media/style/style.css +++ b/askbot/media/style/style.css @@ -2052,8 +2052,9 @@ ul#related-tags li { /* ----- Question template ----- */ .answer .moderated, .question .moderated { - background: url(../images/dialog-warning.png) 2px 0 no-repeat; font-weight: bold; + background: url(../images/dialog-warning.png) 2px 0 no-repeat; + text-decoration: underline; line-height: 16px !important; margin-bottom: -2px !important; padding-left: 24px !important; @@ -3753,6 +3754,9 @@ button::-moz-focus-inner { font-size: 12px; padding: 0; } +.action-status a { + font-weight: bold; +} .inbox-flags .action-status { line-height: 38px; height: 24px; diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less index 8c69e6e8..d508420c 100644 --- a/askbot/media/style/style.less +++ b/askbot/media/style/style.less @@ -2160,13 +2160,11 @@ ul#related-tags li { /* ----- Question template ----- */ -.moderated { -} - .answer, .question { .moderated { - background: url(../images/dialog-warning.png) 2px 0 no-repeat; font-weight: bold; + background: url(../images/dialog-warning.png) 2px 0 no-repeat; + text-decoration: underline; line-height: 16px !important; margin-bottom: -2px !important; padding-left: 24px !important; @@ -3990,6 +3988,9 @@ button::-moz-focus-inner { line-height: 10px; font-size: 12px; padding: 0; + a { + font-weight: bold; + } } .inbox-flags .action-status { diff --git a/askbot/models/question.py b/askbot/models/question.py index 399066b3..b6754e79 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -1108,12 +1108,26 @@ class Thread(models.Model): post_to_author[post_id] = rev.author_id post.set_runtime_needs_moderation() + def post_type_ord(p): + """need to sort by post type""" + if p.is_question(): + return 0 + elif p.is_answer(): + return 1 + return 2 + + def cmp_post_types(a, b): + """need to sort by post type""" + at = post_type_ord(a) + bt = post_type_ord(b) + return cmp(at, bt) + if len(post_id_set): #brand new suggested posts from askbot.models import Post #order by insures that - posts = Post.objects.filter(id__in=post_id_set).order_by('post_type') - for post in posts: + posts = list(Post.objects.filter(id__in=post_id_set)) + for post in sorted(posts, cmp=cmp_post_types): rev = rev_map[post.id] post.text = rev.text post.html = post.parse_post_text()['html'] @@ -1127,6 +1141,7 @@ class Thread(models.Model): all_posts.append(post)#add b/c there may be self-comments if post.is_question(): post_data[0] = post + all_posts.append(post) return post_data diff --git a/askbot/templates/moderation/queue.html b/askbot/templates/moderation/queue.html index 772aa48c..ae9ea880 100644 --- a/askbot/templates/moderation/queue.html +++ b/askbot/templates/moderation/queue.html @@ -5,11 +5,11 @@ {% endblock %} {% block inbox_content %}
-
+ {#
{% trans %}Select:{% endtrans %} {% trans %}all{% endtrans %} | {% trans %}none{% endtrans %} -
+
#} {% trans %}approve posts{% endtrans %} {% trans %}approve posts and users{% endtrans %} {% if question.needs_moderation() %} -

{% trans %}This post awaiting moderation{% endtrans %}

+

{% trans %}This post is awaiting moderation{% endtrans %}

{% endif %} {{ question.summary }}
-- cgit v1.2.3-1-g7c22