Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Sapan Bhatia | 22e0ffe | 2013-10-02 01:12:10 -0400 | [diff] [blame] | 3 | import hashlib |
Tony Mack | ae7f30c | 2013-09-25 12:46:50 -0400 | [diff] [blame] | 4 | from django.db.models import F, Q |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 5 | from planetstack.config import Config |
Sapan Bhatia | 04c94ad | 2013-09-02 18:00:28 -0400 | [diff] [blame] | 6 | from observer.openstacksyncstep import OpenStackSyncStep |
Tony Mack | 91463d9 | 2014-06-19 20:42:03 -0400 | [diff] [blame] | 7 | from core.models.user import User |
| 8 | from core.models.userdeployments import UserDeployments |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 9 | |
| 10 | class SyncUsers(OpenStackSyncStep): |
Tony Mack | ce79de0 | 2013-09-24 10:12:33 -0400 | [diff] [blame] | 11 | provides=[User] |
| 12 | requested_interval=0 |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 13 | |
| 14 | def fetch_pending(self): |
| 15 | return User.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| 16 | |
Tony Mack | ce79de0 | 2013-09-24 10:12:33 -0400 | [diff] [blame] | 17 | def sync_record(self, user): |
Tony Mack | d4a6429 | 2014-04-16 19:53:21 -0400 | [diff] [blame] | 18 | for user_deployment in UserDeployments.objects.filter(user=user): |
| 19 | # bump the 'updated' field so user account are updated across |
| 20 | # deployments. |
| 21 | user_deployment.save() |