Revision bdedfd9d snf-cyclades-app/synnefo/logic/subnets.py

b/snf-cyclades-app/synnefo/logic/subnets.py
117 117
                                   "name is too long")
118 118
    sub = Subnet.objects.create(name=name, network=network, cidr=cidr,
119 119
                                ipversion=ipversion, gateway=gateway,
120
                                userid=network.userid, public=network.public,
120 121
                                dhcp=dhcp, host_routes=host_routes,
121 122
                                dns_nameservers=dns_nameservers)
122 123

  
......
155 156
    try:
156 157
        objects = Subnet.objects
157 158
        subnet_id = int(subnet_id)
158
        subnet = objects.get(id=subnet_id)
159
        if (subnet.network.userid != user_id) and (subnet.network.public is
160
                                                   False):
161
            raise api.faults.Unauthorized("You're not allowed to view this "
162
                                          "subnet")
163
        return subnet
159
        return objects.get(Q(userid=user_id) | Q(public=True),
160
                           id=subnet_id)
164 161
    except (ValueError, TypeError):
165 162
        raise faults.BadRequest("Invalid subnet ID '%s'" % subnet_id)
166 163
    except Subnet.DoesNotExist:

Also available in: Unified diff