Commit 249c3327 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Filter with GET params in project API

Pass GET options in project API calls as GET parameters rather than a json
body.
parent c7da4899
......@@ -825,11 +825,11 @@ class AstakosClient(object):
filters["owner"] = owner
if mode is not None:
filters["mode"] = mode
path = self.api_projects
if filters:
path += "?" + urllib.urlencode(filters)
req_headers = {'content-type': 'application/json'}
req_body = (parse_request({"filter": filters}, self.logger)
if filters else None)
return self._call_astakos(self.api_projects,
headers=req_headers, body=req_body)
return self._call_astakos(path, headers=req_headers)
# -----------------------------------------
# do a GET to ``API_PROJECTS``/<project_id>
......@@ -931,10 +931,13 @@ class AstakosClient(object):
In case of success, return a list of membership descriptions.
"""
req_headers = {'content-type': 'application/json'}
body = {"project": project} if project is not None else None
req_body = parse_request(body, self.logger) if body else None
return self._call_astakos(self.api_memberships,
headers=req_headers, body=req_body)
filters = {}
if project is not None:
filters["project"] = project
path = self.api_memberships
if filters:
path += '?' + urllib.urlencode(filters)
return self._call_astakos(path, headers=req_headers)
# -----------------------------------------
# do a GET to ``API_MEMBERSHIPS``/<memb_id>
......
......@@ -279,9 +279,12 @@ def projects(request):
@transaction.commit_on_success
def get_projects(request):
user = request.user
input_data = read_json_body(request, default={})
filters = input_data.get("filter", {})
mode = input_data.get("mode", "default")
filters = {}
for key in PROJECT_QUERY.keys():
value = request.GET.get(key)
if value is not None:
filters[key] = value
mode = request.GET.get("mode", "default")
query = make_project_query(filters)
projects = _get_projects(query, mode=mode, request_user=user)
data = get_projects_details(projects, request_user=user)
......@@ -619,8 +622,7 @@ def make_membership_query(input_data):
@transaction.commit_on_success
def get_memberships(request):
user = request.user
input_data = read_json_body(request, default={})
query = make_membership_query(input_data)
query = make_membership_query(request.GET)
memberships = _get_memberships(query, request_user=user)
data = get_memberships_details(memberships, user)
return json_response(data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment