Revision d3406fbc
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
53 | 53 |
from django.template.loader import render_to_string |
54 | 54 |
from django.utils import simplejson as json |
55 | 55 |
from django.utils.cache import add_never_cache_headers |
56 |
from django.db.models import Q |
|
56 | 57 |
|
57 | 58 |
from synnefo.api.faults import (Fault, BadRequest, BuildInProgress, |
58 | 59 |
ItemNotFound, ServiceUnavailable, Unauthorized, |
... | ... | |
205 | 206 |
|
206 | 207 |
try: |
207 | 208 |
network_id = int(network_id) |
209 |
objects = Network.objects |
|
208 | 210 |
if for_update: |
209 |
return Network.objects.select_for_update().get(id=network_id, userid=user_id) |
|
210 |
else: |
|
211 |
return Network.objects.get(id=network_id, userid=user_id) |
|
211 |
objects = objects.select_for_update() |
|
212 |
return objects.get(Q(userid=user_id) | Q(public=True), id=network_id) |
|
212 | 213 |
except (ValueError, Network.DoesNotExist): |
213 | 214 |
raise ItemNotFound('Network not found.') |
214 | 215 |
|
Also available in: Unified diff