From 08a2c133ab6937dd9cc50dd22644f0393cf4a303 Mon Sep 17 00:00:00 2001 From: Adrian Gaudebert Date: Wed, 3 Jul 2013 14:24:58 +0200 Subject: [PATCH] Fixes bug 888792 - Ensured backwards compatibility for plugin_type and hang_type in search. --- .../crashstats/templates/crashstats/query.html | 2 +- crashstats/crashstats/tests/test_views.py | 12 ++++++++++++ crashstats/crashstats/views.py | 11 +++++------ crashstats/settings/base.py | 12 +++++++----- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/crashstats/crashstats/templates/crashstats/query.html b/crashstats/crashstats/templates/crashstats/query.html index faa0ef7..f76605e 100644 --- a/crashstats/crashstats/templates/crashstats/query.html +++ b/crashstats/crashstats/templates/crashstats/query.html @@ -94,7 +94,7 @@

Uh oh! Something went wrong...

Report Process: diff --git a/crashstats/crashstats/tests/test_views.py b/crashstats/crashstats/tests/test_views.py index 4686f4f..aa6c77a 100644 --- a/crashstats/crashstats/tests/test_views.py +++ b/crashstats/crashstats/tests/test_views.py @@ -1488,6 +1488,7 @@ def mocked_get(url, **options): ok_('nsASDOMWindowEnumerator::GetNext()' in response.content) # Test that old query types are changed + # Test that plugin data is displayed response = self.client.get(url, { 'do_query': 1, 'product': 'SeaMonkey', @@ -1503,6 +1504,17 @@ def mocked_get(url, **options): ok_('addon.dll' in response.content) ok_('superAddOn 1.2.3' in response.content) + # Test 'all' is an accepted value for report_type and hang_type + response = self.client.get(url, { + 'do_query': 1, + 'product': 'Firefox', + 'hang_type': 'all', + 'process_type': 'all', + }) + eq_(response.status_code, 200) + ok_('table id="signatureList"' in response.content) + ok_('value="any" checked' in response.content) + # Test defaut date expected = datetime.datetime.utcnow() response = self.client.get(url) diff --git a/crashstats/crashstats/views.py b/crashstats/crashstats/views.py index aecace6..dfedcfd 100644 --- a/crashstats/crashstats/views.py +++ b/crashstats/crashstats/views.py @@ -1263,14 +1263,13 @@ def query(request, default_context=None): else: range_unit = settings.RANGE_UNITS[0] - if form.cleaned_data['process_type']: - process_type = form.cleaned_data['process_type'] - else: + # 'all' is here for backwards compatibility, it's an alias of 'any' + process_type = form.cleaned_data['process_type'] + if not process_type or process_type == 'all': process_type = settings.PROCESS_TYPES[0] - if form.cleaned_data['hang_type']: - hang_type = form.cleaned_data['hang_type'] - else: + hang_type = form.cleaned_data['hang_type'] + if not hang_type or hang_type == 'all': hang_type = settings.HANG_TYPES[0] if form.cleaned_data['plugin_field']: diff --git a/crashstats/settings/base.py b/crashstats/settings/base.py index f134b52..7ad5fab 100644 --- a/crashstats/settings/base.py +++ b/crashstats/settings/base.py @@ -194,7 +194,7 @@ # This is for backward compatibility with the PHP app. QUERY_TYPES_MAP = { 'exact': 'is_exactly', - 'startswith': 'starts_with' + 'startswith': 'starts_with', } # Maximum and default range of query that can be run in search @@ -205,7 +205,7 @@ RANGE_UNITS = ( 'weeks', 'days', - 'hours' + 'hours', ) # process types to allow in queries @@ -213,20 +213,22 @@ 'any', 'browser', 'plugin', - 'content' + 'content', + 'all', # alias for 'any' ) # hang types to allow in queries HANG_TYPES = ( 'any', 'crash', - 'hang-p' + 'hang-p', + 'all', # alias for 'any' ) # plugin fields to allow in queries PLUGIN_FIELDS = ( 'filename', - 'name' + 'name', ) # this is the max length of signatures in forms