Skip to content

Commit db93cf9

Browse files
committed
update logic
1 parent 585b213 commit db93cf9

File tree

3 files changed

+104
-10
lines changed

3 files changed

+104
-10
lines changed

assets/agenda/components/LocationFilter.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ export class LocationFilter extends React.Component<any, any> {
337337
</button>
338338
);
339339
} else if (item.type === LOCATION_TYPE.STATE) {
340-
if (!item.name){
341-
return null;
342-
}
343340
return (
344341
<button
345342
key={`state.${item.name}[${index}]`}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Feature: Agenda Search - Filter Locations Based on State
2+
3+
Background: Push content
4+
When we post json to "/push"
5+
"""
6+
{
7+
"guid": "event1", "type": "event", "state": "scheduled", "pubstatus": "usable",
8+
"slugline": "New Press Conference",
9+
"name": "Prime minister press conference",
10+
"dates": {
11+
"start": "2018-05-28T04:00:00+0000",
12+
"end": "2018-05-28T05:00:00+0000",
13+
"tz": "Australia/Sydney"
14+
},
15+
"calendars": [{"qcode": "cal1", "name": "Calendar1"}],
16+
"subject": [
17+
{"code": "d1", "scheme": "sttdepartment", "name": "Dep1"},
18+
{"code": "s1", "scheme": "sttsubj", "name": "Sub1"},
19+
{"code": "e1", "scheme": "event_type", "name": "Sports"}
20+
],
21+
"place": [
22+
{"code": "NSW", "name": "New South Wales"}
23+
],
24+
"anpa_category": [
25+
{"qcode": "e", "name": "Entertainment"},
26+
{"qcode": "f", "name": "Finance"}
27+
],
28+
"location": [{
29+
"name": "Sydney Harbour Bridge",
30+
"address": {
31+
"city": "Sydney",
32+
"state": "New South Wales",
33+
"country": "Australia",
34+
"line": ["Hickson Road"],
35+
"postal_code": "2000",
36+
"type": "attraction",
37+
"title": "Sydney Harbour Bridge",
38+
"area": "Council of the City of Sydney"
39+
}
40+
}]
41+
}
42+
"""
43+
And we post json to "/push"
44+
"""
45+
{
46+
"guid": "event4", "type": "event", "state": "killed", "pubstatus": "cancelled",
47+
"slugline": "Cancelled Melbourne Event",
48+
"name": "Cancelled Melbourne Event",
49+
"dates": {
50+
"start": "2018-05-28T04:00:00+0000",
51+
"end": "2018-05-28T05:00:00+0000",
52+
"tz": "Australia/Sydney"
53+
},
54+
"calendars": [{"qcode": "cal2", "name": "Calendar2"}],
55+
"subject": [
56+
{"code": "d2", "scheme": "sttdepartment", "name": "Dep2"},
57+
{"code": "s2", "scheme": "sttsubj", "name": "Sub2"},
58+
{"code": "e2", "scheme": "event_type", "name": "Music"}
59+
],
60+
"place": [
61+
{"code": "VIC", "name": "Victoria"}
62+
],
63+
"anpa_category": [
64+
{"qcode": "e", "name": "Entertainment"},
65+
{"qcode": "f", "name": "Finance"}
66+
],
67+
"location": [{
68+
"name": "Cancelled Melbourne Location",
69+
"address": {
70+
"city": "Melbourne",
71+
"state": "Victoria",
72+
"country": "Australia",
73+
"line": ["Cancelled Street"],
74+
"postal_code": "3000",
75+
"type": "stadium",
76+
"title": "Cancelled Melbourne Location",
77+
"area": "Yarra Park"
78+
}
79+
}]
80+
}
81+
"""
82+
83+
@auth @admin
84+
Scenario: Verify locations are filtered based on event state
85+
When we get "/agenda/search_locations"
86+
Then we get existing resource
87+
"""
88+
{
89+
"regions": [
90+
{"type": "city", "country": "Australia", "state": "New South Wales", "name": "Sydney"}
91+
],
92+
"places": [
93+
"Sydney Harbour Bridge"
94+
]
95+
}
96+
"""

newsroom/agenda/views.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,14 @@ def gen_agg_terms(field: str):
461461
]:
462462
country_name = country_bucket["key"]
463463
for state_bucket in country_bucket["states"]["buckets"]:
464-
regions.append(
465-
{
466-
"name": state_bucket["key"],
467-
"country": country_name,
468-
"type": "state",
469-
}
470-
)
464+
if state_bucket["key"]:
465+
regions.append(
466+
{
467+
"name": state_bucket["key"],
468+
"country": country_name,
469+
"type": "state",
470+
}
471+
)
471472

472473
if location_filter_options.get("country", True):
473474
for country_bucket in (aggs.get("countries") or aggs["country_search"]["countries"])["buckets"]:

0 commit comments

Comments
 (0)