Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
add search to apps review queues (bug 741594)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Ngo authored and cvan committed Nov 27, 2012
1 parent f12e95c commit 37f5374
Show file tree
Hide file tree
Showing 6 changed files with 407 additions and 69 deletions.
91 changes: 55 additions & 36 deletions media/css/mkt/reviewers.less
Expand Up @@ -411,6 +411,15 @@ table.data-grid .addon-version-notes a {
}
&.selected {
z-index: 2;
a {
.box-shadow(0 -2px 0 fadeOut(@taupe, 80%) inset,
0 0 1px rgba(0, 0, 0, 0.1));
background-color: @white;
border-color: @taupe;
}
a, a:hover {
color: @dark-gray;
}
}
}
}
Expand All @@ -427,16 +436,6 @@ table.data-grid .addon-version-notes a {
display: inline-block;
padding: 10px 15px 20px;
text-decoration: none;
li.selected a {
.box-shadow(0 -2px 0 fadeOut(@taupe, 80%) inset,
0 0 1px rgba(0, 0, 0, 0.1));
background-color: @white;
border-color: @taupe;
color: @dark-gray;
&:hover {
color: @dark-gray;
}
}
}

/* Home */
Expand Down Expand Up @@ -702,43 +701,63 @@ div.editor-stats-table > div.editor-stats-dark {
}
}

.queue-outer #queue-search table {
margin: 0;
padding: 0;
}
.queue-outer #queue-search,
.date_range {
#queue-search {
padding: 1em;
margin-bottom: 1em;
#clear-queue-search {
text-transform: lowercase;
}
.date_range {
padding: 1em;
}
label[for="id_text_query"] {
margin-right: .5em;
}
button {
margin: 0 .5em;
}
}
#advanced-search {
display: none;
margin-top: 1em;
.column1 {
float: left;
width: 375px;
margin-top: 1.5em;
&.hidden {
display: none;
}
.column1 label {
display: block;
float: left;
width: 13em;
label {
margin-bottom: .5em;
}
ul label {
font-weight: normal;
}
.form-elem {
margin-bottom: 0.5em;
}
.column2,
.column3 {
float: left;
width: 250px;
}
.column2 label,
.column3 label {
display: block;
}
.form-row {
clear: both;
padding-bottom: 1em;
}
.column3:after {
.inline-dropdown {
float: left;
position: relative;
top: 8px;
width: 375px;
select, input {
position: relative;
bottom: .5em;
}
label {
display: block;
float: left;
width: 13em;
}
}
.block-dropdown, {
float: left;
width: 250px;
label {
display: block;
}
}
.premium-type-select:after {
content: ".";
display: block;
clear: both;
Expand All @@ -748,7 +767,7 @@ div.editor-stats-table > div.editor-stats-dark {
}
#id_text_query {
width: 25em;
height: 1.5em;
height: 2em;
}

/* Add-on Review Log */
Expand Down
27 changes: 27 additions & 0 deletions mkt/reviewers/forms.py
Expand Up @@ -87,6 +87,33 @@ def __init__(self, *args, **kwargs):
'size': 30}


class AppQueueSearchForm(happyforms.Form):
text_query = forms.CharField(required=False,
label=_lazy(u'Search by app name or author'
' email'))
admin_review = forms.BooleanField(required=False,
label=_lazy(u'Admin Flag'))
has_editor_comment = forms.BooleanField(required=False,
label=_lazy(u'Has Editor Comment'))
has_info_request = forms.BooleanField(required=False,
label=_lazy(u'Information Requested'))
waiting_time_days = forms.TypedChoiceField(required=False, coerce=int,
label=_lazy(u'Days Since Submission'),
choices=([('', '')] + [(i, i) for i in range(1, 10)] + [(10, '10+')]))
device_type_ids = forms.MultipleChoiceField(required=False,
widget=forms.CheckboxSelectMultiple,
label=_lazy(u'Device Type'),
choices=[(d.id, d.name) for d in amo.DEVICE_TYPES.values()])

# Changes wording from "I'll use my own system..." to fit context of queue.
premium_types = dict(amo.ADDON_PREMIUM_TYPES)
premium_types[amo.ADDON_OTHER_INAPP] = _(u'Other system')
premium_type_ids = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
required=False, label=_lazy(u'Premium Type'),
choices=premium_types.items())


class ThemeReviewForm(happyforms.Form):
theme = forms.ModelChoiceField(queryset=Persona.objects.all(),
widget=forms.HiddenInput())
Expand Down
37 changes: 37 additions & 0 deletions mkt/reviewers/templates/reviewers/queue.html
Expand Up @@ -76,6 +76,43 @@ <h3>
</form>
</div>
{% else %}
{% if search_form %}
<div id="queue-search">
<form>
<label for="{{ search_form.text_query.auto_id }}">{{ search_form.text_query.label }}</label>
{{ search_form.text_query }}
<button class="button" type="submit">{{ _('Search') }}</button>
<a id="toggle-queue-search" href="#">{{ _('Advanced Search') }}</a>
{% if searching %}
(<a id="clear-queue-search" href="{{ url('reviewers.apps.queue_%s' % tab) }}">{{ _('Clear Search') }}</a>)
{% endif %}

<div id="advanced-search"{% if not adv_searching %} class="hidden"{% endif %}>
{% macro form_element(search_form, elems) -%}
<div class="form-row">
{% for elem in elems %}
{{ search_form[elem].label_tag() }}
<div class="form-elem">{{ search_form[elem] }}</div>
{% endfor %}
</div>
{%- endmacro %}

<div class="inline-dropdown">
{{ form_element(search_form, ('admin_review', 'has_editor_comment',
'has_info_request', 'waiting_time_days')) }}
</div>
<div class="device-type-select block-dropdown">
{{ form_element(search_form, ('device_type_ids',)) }}
</div>
<div class="premium-type-select block-dropdown">
{{ form_element(search_form, ('premium_type_ids',)) }}
</div>
</div>

</form>
</div>
{% endif %}

<table id="addon-queue" class="data-grid items"
data-url="{{ url('editors.queue_viewing') }}">
<thead>
Expand Down
73 changes: 73 additions & 0 deletions mkt/reviewers/tests/test_forms.py
@@ -0,0 +1,73 @@
from nose.tools import eq_

import amo
import amo.tests
from mkt.reviewers.forms import AppQueueSearchForm


class TestAppQueueSearchForm(amo.tests.TestCase):

def setUp(self):
self.data = {
'text_query': 'as you think, so shall you become',
'admin_review': False,
'has_editor_comment': False,
'has_info_request': False,
'waiting_time_days': '10',
'device_type_ids': ['1'],
'premium_type_ids': ['2'],
}

def test_basic(self):
"""Test the form doesn't crap out."""
self.check_valid(True)

def test_has_admin_review(self):
self.data['admin_review'] = True
self.check_valid(True)

def test_has_editor_comment(self):
self.data['has_editor_comment'] = True
self.check_valid(True)

def test_has_info_request(self):
self.data['has_info_request'] = True
self.check_valid(True)

def test_waiting_time_days(self):
"""Test waiting_time_days only takes numbers."""
for choice in (999, 'real living is living for others'):
self.data['waiting_time_days'] = choice
self.check_valid(False)

for choice in ('', '5'):
self.data['waiting_time_days'] = choice
self.check_valid(True)

def test_device_type(self):
"""Test only accept amo.DEVICE_TYPES"""
# Put in out-of-range numbers and check form not valid.
for choice in ([45], [1, 999]):
self.data['device_type_ids'] = choice
self.check_valid(False)

for choice in ([amo.DEVICE_DESKTOP.id, amo.DEVICE_MOBILE.id],
[amo.DEVICE_TABLET.id]):
self.data['device_type_ids'] = choice
self.check_valid(True)

def test_premium(self):
"""Test only accept amo.PREMIUM"""
# Put in out-of-range numbers and check form not valid.
for choice in ([45], [1, 32]):
self.data['premium_type_ids'] = choice
self.check_valid(False)

for choice in ([amo.ADDON_FREE, amo.ADDON_PREMIUM],
[amo.ADDON_FREE_INAPP]):
self.data['premium_type_ids'] = choice
self.check_valid(True)

def check_valid(self, valid):
form = AppQueueSearchForm(self.data)
eq_(form.is_valid(), valid)

0 comments on commit 37f5374

Please sign in to comment.