def create_detail(self, object_list, bundle): if not bundle.request.user.is_authenticated(): return False if not 'namespace' in bundle.data: return False namespace = get_model_by_resource_url(bundle.data['namespace'], Namespace) if not namespace: return False if namespace.owner != bundle.request.user: return False return True
def get_namespace_by_resource_url(url): '''Returns a Namespace for a resource URL like /api/v0.1/peach/namespace/3/''' return get_model_by_resource_url(url, Namespace)