Scott Baker | 7b836b6 | 2014-06-11 14:37:48 -0700 | [diff] [blame] | 1 | import os |
| 2 | import datetime |
| 3 | from collections import defaultdict |
| 4 | from django.db import models |
| 5 | from django.db.models import F, Q |
| 6 | from core.models import PlCoreBase,Site,User,Deployment |
| 7 | |
| 8 | class UserDeployments(PlCoreBase): |
| 9 | user = models.ForeignKey(User) |
| 10 | deployment = models.ForeignKey(Deployment) |
| 11 | kuser_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone user id") |
| 12 | |
| 13 | def __unicode__(self): return u'%s %s' % (self.user, self.deployment.name) |
| 14 | |
| 15 | @staticmethod |
| 16 | def select_by_user(user): |
| 17 | if user.is_admin: |
| 18 | qs = UserDeployments.objects.all() |
| 19 | else: |
| 20 | users = Users.select_by_user(user) |
| 21 | qs = Usereployments.objects.filter(user__in=slices) |
| 22 | return qs |