blob: 5a3568af03fd4853ccc1b9179fa667b592aada25 [file] [log] [blame]
Tony Mack06c8e472014-11-30 15:53:08 -05001import os
2import datetime
3from collections import defaultdict
4from django.db import models
5from django.db.models import F, Q
6from core.models import PlCoreBase,User,Controller
7from core.models import Controller,ControllerLinkManager,ControllerLinkDeletionManager
8
9class ControllerUsers(PlCoreBase):
10 objects = ControllerLinkManager()
11 deleted_objects = ControllerLinkDeletionManager()
12
13 user = models.ForeignKey(User,related_name='controllerusers')
14 controller = models.ForeignKey(Controller,related_name='controllersusers')
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.controller, self.user)
18
19 @staticmethod
20 def select_by_user(user):
21 if user.is_admin:
22 qs = ControllerUsers.objects.all()
23 else:
24 users = Users.select_by_user(user)
25 qs = ControllerUsers.objects.filter(user__in=users)
26 return qs