blob: fd2984883567384f334d7a8ba2e3287d769928c7 [file] [log] [blame]
Siobhan Tully4bc09f22013-04-10 21:15:21 -04001import os
2import datetime
3from django.db import models
Siobhan Tully30fd4292013-05-10 08:59:56 -04004from core.models import PlCoreBase
Siobhan Tully4bc09f22013-04-10 21:15:21 -04005
6class Role(PlCoreBase):
7
Siobhan Tully5d7dc8d2013-07-02 13:17:33 -04008 ROLE_CHOICES = (('admin', 'Admin'), ('pi', 'Principle Investigator'), ('tech', 'Technician'), ('user','User'))
9 role = models.CharField(null=True, blank=True,max_length=256, unique=True, choices=ROLE_CHOICES)
Tony Mackfd24d0d2013-04-14 00:59:17 -040010 role_type = models.CharField(max_length=80, unique=True)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040011
12 def __unicode__(self): return u'%s' % (self.role_type)
13
Tony Mackfd24d0d2013-04-14 00:59:17 -040014
15 def save(self, *args, **kwds):
Siobhan Tully73291342013-05-10 10:50:08 -040016 if not hasattr(self, 'os_manager'):
Tony Mack89f70f12013-05-10 20:20:03 -040017 from openstack.manager import OpenStackManager
Siobhan Tully73291342013-05-10 10:50:08 -040018 setattr(self, 'os_manager', OpenStackManager())
Tony Mack89f70f12013-05-10 20:20:03 -040019 self.os_manager.save_role(self)
Tony Mackfd24d0d2013-04-14 00:59:17 -040020 super(Role, self).save(*args, **kwds)
21
22 def delete(self, *args, **kwds):
Siobhan Tully73291342013-05-10 10:50:08 -040023 if not hasattr(self, 'os_manager'):
Tony Mack89f70f12013-05-10 20:20:03 -040024 from openstack.manager import OpenStackManager
Siobhan Tully73291342013-05-10 10:50:08 -040025 setattr(self, 'os_manager', OpenStackManager())
Tony Mack89f70f12013-05-10 20:20:03 -040026 self.os_manager.delete_role(self)
Tony Mackfd24d0d2013-04-14 00:59:17 -040027 super(Role, self).delete(*args, **kwds)
28