def dehydrate(self, bundle): # get ALL the users projects (including those discovered through teams), and set the projects to the uri's for those. bundle.data['projects'] = map( lambda p: reverse("api_dispatch_detail", kwargs={ 'resource_name': "project", 'pk': p.id, "api_name": self._meta.api_name }), ProjectMember.getProjectsForUser( User.objects.get(username=bundle.data["username"]))) return bundle
def read(self, request, slug=None, user=False, org=False): """ returns a single project if slug is specified, the users projects if user is True, an organization's projects if org_slug is specified else all projects authenticated user has access to. """ if slug and (not org): p = Project.objects.get(slug=slug) if p.hasReadAccess(request.user): return p else: return rc.FORBIDDEN elif user: return Project.objects.filter(creator=request.user) elif org: return Project.objects.filter(organization__slug = slug) else: return ProjectMember.getProjectsForUser(request.user)
def read(self, request, slug=None, user=False, org=False): """ returns a single project if slug is specified, the users projects if user is True, an organization's projects if org_slug is specified else all projects authenticated user has access to. """ if slug and (not org): p = Project.objects.get(slug=slug) if p.hasReadAccess(request.user): return p else: return rc.FORBIDDEN elif user: return Project.objects.filter(creator=request.user) elif org: return Project.objects.filter(organization__slug=slug) else: return ProjectMember.getProjectsForUser(request.user)
def dehydrate(self, bundle): # get ALL the users projects (including those discovered through teams), and set the projects to the uri's for those. bundle.data['projects'] = map(lambda p: reverse("api_dispatch_detail", kwargs={'resource_name':"project", 'pk': p.id, "api_name": self._meta.api_name}), ProjectMember.getProjectsForUser(User.objects.get(username=bundle.data["username"]))) return bundle