Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | import datetime |
| 3 | from django.db import models |
Siobhan Tully | 30fd429 | 2013-05-10 08:59:56 -0400 | [diff] [blame] | 4 | from core.models import PlCoreBase |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 5 | from openstack.manager import OpenStackManager |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 6 | |
| 7 | class Role(PlCoreBase): |
| 8 | |
Tony Mack | fd24d0d | 2013-04-14 00:59:17 -0400 | [diff] [blame] | 9 | #ROLE_CHOICES = (('admin', 'Admin'), ('pi', 'Principle Investigator'), ('user','User')) |
Tony Mack | cdec090 | 2013-04-15 00:38:49 -0400 | [diff] [blame] | 10 | role_id = models.CharField(max_length=256, unique=True) |
Tony Mack | fd24d0d | 2013-04-14 00:59:17 -0400 | [diff] [blame] | 11 | role_type = models.CharField(max_length=80, unique=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 12 | |
| 13 | def __unicode__(self): return u'%s' % (self.role_type) |
| 14 | |
Tony Mack | fd24d0d | 2013-04-14 00:59:17 -0400 | [diff] [blame] | 15 | |
| 16 | def save(self, *args, **kwds): |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 17 | if not hasattr(self, 'os_manager'): |
| 18 | setattr(self, 'os_manager', OpenStackManager()) |
| 19 | self.os_manager.save_role(self) |
Tony Mack | fd24d0d | 2013-04-14 00:59:17 -0400 | [diff] [blame] | 20 | super(Role, self).save(*args, **kwds) |
| 21 | |
| 22 | def delete(self, *args, **kwds): |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 23 | if not hasattr(self, 'os_manager'): |
| 24 | setattr(self, 'os_manager', OpenStackManager()) |
| 25 | self.os_manager.delete_role(self) |
Tony Mack | fd24d0d | 2013-04-14 00:59:17 -0400 | [diff] [blame] | 26 | super(Role, self).delete(*args, **kwds) |
| 27 | |