From 201c627a39a6ee704b6303813ae8effdf09ed921 Mon Sep 17 00:00:00 2001 From: Ashish Dubey Date: Thu, 27 Jun 2013 14:29:20 -0700 Subject: [PATCH] create thread/notes from reviewer tools (Bug 879532) --- media/css/devreg/reviewers.styl | 2 +- media/js/zamboni/editors.js | 17 ++++++ migrations/628-waffle-comm-dashboard.sql | 2 + mkt/reviewers/forms.py | 22 +++++++ mkt/reviewers/templates/reviewers/review.html | 9 ++- mkt/reviewers/tests/test_views.py | 32 ++++++++++ mkt/reviewers/utils.py | 60 +++++++++++++++++++ mkt/reviewers/views.py | 4 +- 8 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 migrations/628-waffle-comm-dashboard.sql diff --git a/media/css/devreg/reviewers.styl b/media/css/devreg/reviewers.styl index 0dbfd8300e..7e7e073021 100644 --- a/media/css/devreg/reviewers.styl +++ b/media/css/devreg/reviewers.styl @@ -861,7 +861,7 @@ button.search, .log-filter-outside button { } } } - .review-actions-features-override ul { + .review-actions-options ul { columns(2, 1em); } } diff --git a/media/js/zamboni/editors.js b/media/js/zamboni/editors.js index d794e3f38b..acb9f72b21 100644 --- a/media/js/zamboni/editors.js +++ b/media/js/zamboni/editors.js @@ -79,6 +79,7 @@ function initReviewActions() { $data_toggle.filter('[data-value*="' + value + '"]').show(); toggle_input(); + togglePermissions(value); /* Fade out canned responses */ var label = $element.text().trim(); @@ -107,6 +108,22 @@ function initReviewActions() { $files_input.after($('', {'type': 'checkbox', 'checked': true, 'disabled': true})); } + function togglePermissions(action) { + // Check/Uncheck/Disable default permissions associated with the action. + var $reviewerActions = $('.review-actions-visibility'); + var $permissions = $('input[name="action_visibility"]'); + $permissions.prop('checked', true).prop('disabled', false); + + var disable_list = $reviewerActions.data('default-visibility')[action]; + if (disable_list) { + _.each(disable_list.disabled, function(v) { + $permissions.filter('[value="' + v + '"]') + .prop('disabled', true) + .prop('checked', false); + }); + } + } + function toggle_input(){ var $files_input = $('#review-actions .review-actions-files').find('input:enabled'), $files_checked = $files_input.filter(':checked'), diff --git a/migrations/628-waffle-comm-dashboard.sql b/migrations/628-waffle-comm-dashboard.sql new file mode 100644 index 0000000000..a10f4cf88f --- /dev/null +++ b/migrations/628-waffle-comm-dashboard.sql @@ -0,0 +1,2 @@ +INSERT INTO waffle_switch_mkt (name, active, created, modified, note) + VALUES ('comm-dashboard', 0, NOW(), NOW(), 'Communication dashboard for reviewer tools.'); diff --git a/mkt/reviewers/forms.py b/mkt/reviewers/forms.py index f1c7c806e1..2633fced59 100644 --- a/mkt/reviewers/forms.py +++ b/mkt/reviewers/forms.py @@ -29,6 +29,17 @@ class ReviewAppAttachmentForm(happyforms.Form): AttachmentFormSet = forms.formsets.formset_factory(ReviewAppAttachmentForm, extra=1) +# This contains default values for action visibility. +# `disabled` will be disabled (not allowed to check). +DEFAULT_ACTION_VISIBILITY = { + 'escalate': { + 'disabled': ['developer'] + }, + 'comment': { + 'disabled': ['developer'] + }, +} + class ReviewAppForm(happyforms.Form): @@ -44,6 +55,17 @@ class ReviewAppForm(happyforms.Form): choices=[(k, v.name) for k, v in amo.DEVICE_TYPES.items()], coerce=int, label=_lazy(u'Device Type Override:'), widget=forms.CheckboxSelectMultiple, required=False) + + thread_perms = [('developer', _lazy('Developers')), + ('reviewer', _lazy('Reviewers')), + ('senior_reviewer', _lazy('Senior Reviewers')), + ('staff', _lazy('Staff')), + ('mozilla_contact', _lazy('Mozilla Contact'))] + action_visibility = forms.TypedMultipleChoiceField( + choices=thread_perms, + coerce=unicode, label=_lazy('Action Visibility to Users:'), + widget=forms.CheckboxSelectMultiple, required=False) + notify = forms.BooleanField( required=False, label=_lazy(u'Notify me the next time the manifest is ' u'updated. (Subsequent updates will not ' diff --git a/mkt/reviewers/templates/reviewers/review.html b/mkt/reviewers/templates/reviewers/review.html index b6c827a9cf..28b5b2011c 100644 --- a/mkt/reviewers/templates/reviewers/review.html +++ b/mkt/reviewers/templates/reviewers/review.html @@ -254,7 +254,7 @@ {{ form.device_override.errors}} {% if waffle.switch('buchets') %} -
+
{{ _('Minimum Requirements Override:') }}
    {% for field in appfeatures_form.required_api_fields() %} @@ -263,6 +263,13 @@
{% endif %} + {% if waffle.switch('comm-dashboard') %} +
+ {{ _('Make this action visible to') }} + {{ form.action_visibility }} + {{ form.action_visibility.errors }} +
+ {% endif %}
{{ form.notify }}