Rework management commands to handle deployment assignment

We now ensure `create_realm` adds you to a default deployment and that
`create_deployment` removes the old deployment association when
performed.

(imported from commit 5b94fb07b8e11332765b057dc640a5ed873ec99e)
This commit is contained in:
Luke Faraone
2013-10-25 17:24:26 -04:00
parent 3551b211f2
commit ab9b1be82c
2 changed files with 28 additions and 0 deletions

View File

@@ -41,6 +41,10 @@ class Command(BaseCommand):
dep = Deployment()
dep.api_key = random_api_key()
dep.save()
old_dep = realm.deployment
if old_dep is not None:
old_dep.realms.remove(realm)
old_dep.save()
dep.realms = [realm]
dep.save()
print "Deployment created."