Commit 975904b6 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Filter deleted entries when changes-since is used

Modify list_networks and list_servers to filter deleted entries when
if-modified-since HTTP header is used, because deleted entries can be
updated after deletion through the reconciliation mechanism.
parent 4943dc30
......@@ -116,15 +116,14 @@ def list_networks(request, detail=False):
log.debug('list_networks detail=%s', detail)
since = util.isoparse(request.GET.get('changes-since'))
user_networks = Network.objects.filter(
Q(userid=request.user_uniq) | Q(public=True))
user_networks = Network.objects.filter(Q(userid=request.user_uniq) |
if since:
user_networks = user_networks.filter(updated__gte=since)
if not user_networks:
return HttpResponse(status=304)
user_networks = user_networks.filter(deleted=False)
networks = [network_to_dict(network, request.user_uniq, detail)
for network in user_networks]
......@@ -161,15 +161,14 @@ def list_servers(request, detail=False):
# overLimit (413)
log.debug('list_servers detail=%s', detail)
user_vms = VirtualMachine.objects.filter(userid=request.user_uniq)
since = util.isoparse(request.GET.get('changes-since'))
user_vms = VirtualMachine.objects.filter(userid=request.user_uniq,
since = util.isoparse(request.GET.get('changes-since'))
if since:
user_vms = user_vms.filter(updated__gte=since)
if not user_vms:
return HttpResponse(status=304)
user_vms = user_vms.filter(deleted=False)
servers = [vm_to_dict(server, detail) for server in user_vms]
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