示例#1
0
 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
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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