blob: 5685668a220499fad6412508be48d19dea3cfc53 [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
Sapan Bhatiad0c61c52014-09-22 15:08:44 -04007from core.models import Deployment,DeploymentLinkManager,DeploymentLinkDeletionManager
Scott Baker7b836b62014-06-11 14:37:48 -07008
9class UserDeployments(PlCoreBase):
Sapan Bhatiad0c61c52014-09-22 15:08:44 -040010 objects = DeploymentLinkManager()
11 deleted_objects = DeploymentLinkDeletionManager()
12
Scott Baker7b836b62014-06-11 14:37:48 -070013 user = models.ForeignKey(User)
14 deployment = models.ForeignKey(Deployment)
15 kuser_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone user id")
16
17 def __unicode__(self): return u'%s %s' % (self.user, self.deployment.name)
18
19 @staticmethod
20 def select_by_user(user):
21 if user.is_admin:
22 qs = UserDeployments.objects.all()
23 else:
24 users = Users.select_by_user(user)
25 qs = Usereployments.objects.filter(user__in=slices)
26 return qs