Moved service enable/disable functions to the update_access() function on the user profile

This will remove the need for the cronjob, but not totally, best still to run the cronjob to catch situations where the permission changes can be missed.
This commit is contained in:
2010-03-24 14:52:08 +00:00
parent 337036247e
commit 07450ca5dd
4 changed files with 41 additions and 35 deletions

View File

@@ -23,30 +23,4 @@ class RemoveInvalidUsers():
# For each user, update access list based on Corp details
user.get_profile().update_access()
# Check each service account and disable access if they're not allowed
for servacc in ServiceAccount.objects.filter(user=user):
if not (set(user.groups.all()) & set(servacc.service.groups.all())):
if servacc.active:
self._logger.info("User %s is not in allowed group for %s, deleting account" % (user.username, servacc.service))
servacc.active = 0
servacc.save()
servacc.user.message_set.create(message="Your %s account has been disabled due to lack of permissions. If this is incorrect, check your API keys." % (servacc.service))
pass
else:
if not servacc.active:
self._logger.info("User %s is now in a allowed group for %s, enabling account" % (user.username, servacc.service))
servacc.active = 1
servacc.save()
servacc.user.message_set.create(message="Your %s account has been re-enabled, you may need to reset your password to access this service again." % (servacc.service))
pass
# For users set to not active, delete all accounts
if not user.is_active:
print "User %s is inactive, disabling related service accounts" % user.username
for servacc in ServiceAccount.objects.filter(user=user):
servacc.active = 0
servacc.save()
pass