Repository: fossasia/open-event-server

Issue:
Event location in footer, but no events listed
![screenshot from 2016-07-09 11 46 21](https://cloud.githubusercontent.com/assets/1583873/16707375/db3c43a2-45ca-11e6-8210-b5112336df36.png)



Discussion:

Resolving patch:
diff --git a/open_event/api/events.py b/open_event/api/events.py
--- a/open_event/api/events.py
+++ b/open_event/api/events.py
@@ -55,6 +55,7 @@
     'background_url': fields.Upload(),
     'description': fields.String(),
     'location_name': fields.String(),
+    'searchable_location_name': fields.String(),
     'organizer_name': fields.String(),
     'organizer_description': fields.String(),
     'state': fields.String(),
diff --git a/open_event/api/helpers/query_filters.py b/open_event/api/helpers/query_filters.py
--- a/open_event/api/helpers/query_filters.py
+++ b/open_event/api/helpers/query_filters.py
@@ -55,6 +55,20 @@ def event_location(value, query):
     return query.filter(or_(*queries))
 
 
+def event_search_location(value, query):
+    """
+    Return all queries which contain either A or B or C
+    when location is A,B,C
+    TODO: Proper ordering of results a/c proximity
+    """
+    locations = list(value.split(','))
+    queries = []
+    print locations
+    for i in locations:
+        queries.append(func.lower(Event.searchable_location_name).contains(i.lower()))
+    return query.filter(or_(*queries))
+
+
 def event_start_time_gt(value, query):
     return query.filter(Event.start_time >= DateTime().from_str(value))
 
@@ -86,6 +100,7 @@ def event_time_period(value, query):
 FILTERS_LIST = {
     '__event_contains': event_contains,
     '__event_location': event_location,
+    '__event_search_location': event_search_location,
     '__event_start_time_gt': event_start_time_gt,
     '__event_start_time_lt': event_start_time_lt,
     '__event_end_time_gt': event_end_time_gt,
diff --git a/open_event/views/public/explore.py b/open_event/views/public/explore.py
--- a/open_event/views/public/explore.py
+++ b/open_event/views/public/explore.py
@@ -60,10 +60,11 @@ def explore_view(self, location):
         day_filter = request.args.get('period', None)
         sub_category = request.args.get('sub-category', None)
         category = request.args.get('category', None)
+        print location
         if day_filter:
             start, end = get_date_range(day_filter)
         if location:
-            filtering['__event_location'] = location
+            filtering['__event_search_location'] = location
         if word:
             filtering['__event_contains'] = word
         if category:


Test patch:
diff --git a/tests/views/guest/test_search.py b/tests/views/guest/test_search.py
--- a/tests/views/guest/test_search.py
+++ b/tests/views/guest/test_search.py
@@ -16,6 +16,7 @@ def get_event():
     event.start_time = datetime.now() + timedelta(days=5)
     event.end_time = event.start_time + timedelta(days=5)
     event.location_name = 'India'
+    event.searchable_location_name = 'India'
     event.state = 'Published'
     return event
 
@@ -48,6 +49,7 @@ def test_location_filter(self):
             save_to_db(event, "Event Saved")
             event = get_event_two()
             event.location_name = 'United States'
+            event.searchable_location_name = 'United States'
             save_to_db(event, "Event Saved")
             rv = self.app.get(url_for('explore.explore_view', location=slugify('India')), follow_redirects=True)
             self.assertTrue("Super Event" in rv.data, msg=rv.data)