Some hacks to make organizational user object creation possible by posting directly to the subcollection. This is a little complex due to the user (being a Django object) not having any FKs

to our objects.  This should be refactored later but is at least sufficiently operational for the two cases it is used here.
This commit is contained in:
Michael DeHaan
2013-04-29 10:36:16 -04:00
parent 69a9916423
commit 21f4e3a680
3 changed files with 60 additions and 5 deletions

View File

@@ -270,6 +270,15 @@ class OrganizationsTest(BaseTest):
users = self.get(url, expect=200, auth=self.get_normal_credentials())
self.assertEqual(users['count'], 1)
# post a completely new user to verify we can add users to the subcollection directly
new_user = dict(username='NewUser9000')
which_org = self.normal_django_user.admin_of_organizations.all()[0]
url = '/api/v1/organizations/%s/users/' % (which_org.pk)
posted = self.post(url, new_user, expect=201, auth=self.get_normal_credentials())
all_users = self.get(url, expect=200, auth=self.get_normal_credentials())
self.assertEqual(all_users['count'], 2)
def test_post_item_subobjects_admins(self):
url = '/api/v1/organizations/2/admins/'