Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit ecd7736

Browse files
committed
Merge pull request #255 from sparkica/country_less
Added support to search by all countries
2 parents d0e6b62 + 29434d4 commit ecd7736

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

api/models/events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class Event(models.Model):
3838
('PENDING', 'Pending'),
3939
('REJECTED', 'Rejected'),
4040
)
41+
42+
CUSTOM_COUNTRY_ENTRIES = (
43+
('00',' All countries'),
44+
('01','---------------'),
45+
)
46+
4147
status = models.CharField(max_length=50, choices=STATUS_CHOICES, default='PENDING')
4248
title = models.CharField(max_length=255, default=None)
4349
slug = models.SlugField(max_length=255, null=True, blank=True)

api/processors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_filtered_events(search_filter=None, country_filter=None, theme_filter=No
8989
filter_args = (Q(title__icontains=search_filter) | Q(description__icontains=search_filter) | Q(tags__name__icontains=search_filter)
9090
| Q(organizer__icontains=search_filter) | Q(location__icontains=search_filter),)
9191

92-
if country_filter:
92+
if country_filter and country_filter not in [ custom_country[0] for custom_country in Event.CUSTOM_COUNTRY_ENTRIES ]:
9393
filter_kwargs['country'] = country_filter
9494

9595
if theme_filter:

web/forms/event_form.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ def __init__(self, *args, **kwargs):
155155

156156
class SearchEventForm(forms.Form):
157157

158+
countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[0])
159+
countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[1])
160+
158161
search = forms.CharField(
159162
required=False,
160-
widget=forms.TextInput(attrs={'placeholder': 'Search some serious events', 'class': 'form-control'})
163+
widget=forms.TextInput(attrs={'placeholder': 'Search for event name or tag', 'class': 'form-control'})
161164
)
162165
country = forms.ChoiceField(
163166
label='Select country',

0 commit comments

Comments
 (0)