Skip to content

Commit

Permalink
Merge pull request #18 from praekelt/feature/move-radius-filter-to-or…
Browse files Browse the repository at this point in the history
…g-results-view

Feature/move radius filter to org results view
  • Loading branch information
moh-moola committed Sep 17, 2018
2 parents 2482716 + 0f76db0 commit 8bfcd06
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@
<input type="text" name="location" value="{{ location_term }}"/>
</fieldset>

{% if SERVICE_DIRECTORY_RADIUS %}
<fieldset>
<label class="service-dir-hero-label">Show me results within __ KMs away</label>
<select name="radius" value="{{ radius }}" >
{% for value, label in SERVICE_DIRECTORY_RADIUS_OPTIONS %}
<option {% ifequal value SERVICE_DIRECTORY_RADIUS %}selected="selected"{% endifequal %} value="{{ value }}">
{{ label }}
</option>
{% endfor %}
</select>
<fieldset>
{% endif %}


{% if SERVICE_DIRECTORY_MULTI_CATEGORY_SELECT %}
{% for category in categories %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
<input type="hidden" name="location" value="{{ location_term }}" />
<input type="hidden" name="place_id" value="{{ place_id }}" />

{% if SERVICE_DIRECTORY_RADIUS %}
<fieldset>
<label class="service-dir-hero-label">Show me results within __ KMs away</label>
<select name="radius" value="{{ SERVICE_DIRECTORY_RADIUS }}" >
{% for value, label in SERVICE_DIRECTORY_RADIUS_OPTIONS %}
<option {% ifequal value SERVICE_DIRECTORY_RADIUS %}selected="selected"{% endifequal %} value="{{ value }}">
{{ label }}
</option>
{% endfor %}
</select>
<fieldset>
{% endif %}

{% if SERVICE_DIRECTORY_MULTI_CATEGORY_SELECT %}
{% for category in categories %}
<input type="hidden" name="categories[]" value="{{ category }}">
Expand Down
11 changes: 10 additions & 1 deletion molo/servicedirectory/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def test_location_results_view(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(context['categories'], [1, 2])
self.assertEqual(context['keywords'], ['key1', 'key2'])
self.assertEqual(
response.context['SERVICE_DIRECTORY_RADIUS'], 25)

self.assertContains(
response, 'type="hidden" name="categories[]" value="1"')
Expand All @@ -160,16 +162,23 @@ def test_location_results_view(self):
response, 'servicedirectory/location_results.html')

def test_organisation_results_view(self):
data = {'categories[]': [1, 2], 'keywords[]': ['key1', 'key2']}
data = {
'radius': 5,
'categories[]': [1, 2],
'keywords[]': ['key1', 'key2']
}
response = self.client.get(
reverse('molo.servicedirectory:organisation-results'),
data=data
)

context = response.context_data
self.assertEqual(response.status_code, 200)

self.assertEqual(context['categories'], [1, 2])
self.assertEqual(context['keywords'], ['key1', 'key2'])
self.assertEqual(
response.context['SERVICE_DIRECTORY_RADIUS'], 5)

self.assertContains(
response, 'type="hidden" name="categories[]" value="1"')
Expand Down

0 comments on commit 8bfcd06

Please sign in to comment.