Commit 9661b18e by Chif Gergő

Fix field error in Q expression

parent 08480ef1
Pipeline #1067 failed with stage
in 1 minute 28 seconds
......@@ -178,7 +178,7 @@ class Instance(BaseMachineDescriptor):
@classmethod
def create(cls, lease, owner, flavor, template, remote_id, params):
params["password"] = cls.generate_password()
inst = cls(lease=lease, flavor=flavor, owner=owner, system_type=template.system_type,
inst = cls(lease=lease, flavor=flavor, created_by=owner, system_type=template.system_type,
distro=template.distro, access_protocol=template.access_protocol,
remote_id=remote_id, template=template, status="CREATING",
**params)
......
......@@ -72,7 +72,7 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
status=status.HTTP_401_UNAUTHORIZED)
params = request.data
template = ImageTemplate.objects.get(Q(pk=params["template"]) &
(Q(owned_by=request.user) | Q(type="SYSTEM")))
(Q(created_by=request.user) | Q(type="SYSTEM")))
if not template:
return Response({"error": "No permission to use this template."},
status=status.HTTP_401_UNAUTHORIZED)
......
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 sign in to comment