From 4aed4f640575296d33d0a1f1d43b36245b1e0431 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 26 Mar 2013 18:26:40 -0400 Subject: [PATCH] Add more 'auto-associate by posting new object' end points. --- lib/main/tests/users.py | 4 ++++ lib/main/views.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/main/tests/users.py b/lib/main/tests/users.py index d0deb59a81..37696e12ab 100644 --- a/lib/main/tests/users.py +++ b/lib/main/tests/users.py @@ -207,4 +207,8 @@ class UsersTest(BaseTest): data = self.get(url, expect=200, auth=self.get_normal_credentials()) self.assertEquals(data['count'], 0) + # FIXME: add test that shows posting a user w/o id to /organizations/2/users/ can create a new one & associate + # FIXME: add test that shows posting a user w/o id to /organizations/2/admins/ can create a new one & associate + # FIXME: add test that shows posting a projects w/o id to /organizations/2/projects/ can create a new one & associate + diff --git a/lib/main/views.py b/lib/main/views.py index f93d9a1e1a..4d73ef208c 100644 --- a/lib/main/views.py +++ b/lib/main/views.py @@ -85,6 +85,7 @@ class OrganizationsUsersList(BaseSubList): parent_model = Organization relationship = 'users' postable = True + inject_primary_key_on_post_as = 'organization' def _get_queryset(self): ''' to list users in the organization, I must be a superuser or org admin ''' @@ -101,6 +102,7 @@ class OrganizationsAdminsList(BaseSubList): parent_model = Organization relationship = 'admins' postable = True + inject_primary_key_on_post_as = 'organization' def _get_queryset(self): ''' to list admins in the organization, I must be a superuser or org admin ''' @@ -117,6 +119,7 @@ class OrganizationsProjectsList(BaseSubList): parent_model = Organization # for sub list relationship = 'projects' # " " postable = True + inject_primary_key_on_post_as = 'organization' def _get_queryset(self): ''' to list projects in the organization, I must be a superuser or org admin ''' @@ -133,6 +136,7 @@ class OrganizationsTagsList(BaseSubList): parent_model = Organization # for sub list relationship = 'tags' # " " postable = True + inject_primary_key_on_post_as = 'organization' def _get_queryset(self): ''' to list tags in the organization, I must be a superuser or org admin '''