blob: 3422156b1bdb291a3c9b092df42e3a294a242ab3 [file] [log] [blame]
Scott Baker7b836b62014-06-11 14:37:48 -07001import os
2import datetime
3from collections import defaultdict
4from django.db import models
5from django.db.models import F, Q
6from core.models import PlCoreBase,Site,User,Deployment
7
8class 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