Skip to content

Commit

Permalink
Use URL param to determine whether to include sub-departments in API …
Browse files Browse the repository at this point in the history
…search
  • Loading branch information
ahaith committed Mar 13, 2015
1 parent 7ac5684 commit ee0e03f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion talks/api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ def events_search(request):
if to_date:
queries.append(Q(start__lt=to_date))

include_sub_departments = True
subdepartments = request.GET.get("subdepartments")
print subdepartments
if subdepartments and subdepartments == 'false':
print "no subdepartments"
include_sub_departments = False

print include_sub_departments
# map between URL query parameters and their corresponding django ORM query
list_parameters = {
'speaker': lambda speakers: Q(personevent__role=ROLES_SPEAKER, personevent__person__slug__in=speakers),
'venue': lambda venues: Q(location__in=venues),
'organising_department': lambda depts: Q(department_organiser__in=get_all_department_ids(depts, True)),
'organising_department': lambda depts: Q(department_organiser__in=get_all_department_ids(depts, include_sub_departments)),
'topic': lambda topics: Q(topics__uri__in=topics)
}

Expand Down

0 comments on commit ee0e03f

Please sign in to comment.