update user account across deployments when user record is updated
diff --git a/planetstack/observer/steps/sync_user_deployments.py b/planetstack/observer/steps/sync_user_deployments.py
index cbbcb17..7110a0b 100644
--- a/planetstack/observer/steps/sync_user_deployments.py
+++ b/planetstack/observer/steps/sync_user_deployments.py
@@ -29,7 +29,6 @@
for user_deployment in UserDeployments.objects.all():
user_deploy_lookup[user_deployment.user].append(user_deployment.deployment)
- user_deployments = []
all_deployments = Deployment.objects.filter()
for user in User.objects.all():
if user.is_admin:
@@ -45,13 +44,14 @@
expected_deployment not in user_deploy_lookup[user]:
# add new record
ud = UserDeployments(user=user, deployment=expected_deployment)
- user_deployments.append(ud)
+ ud.save()
+ #user_deployments.append(ud)
#else:
# # update existing record
# ud = UserDeployments.objects.get(user=user, deployment=expected_deployment)
# user_deployments.append(ud)
- return user_deployments
+ return UserDeployments.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
def sync_record(self, user_deployment):
logger.info("sync'ing user %s at deployment %s" % (user_deployment.user, user_deployment.deployment.name))