Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 1 | from PLC.Roles import Roles |
| 2 | from model import Role |
| 3 | |
| 4 | class RoleImporter: |
| 5 | |
| 6 | def __init__(self, importer): |
| 7 | self.importer = importer |
| 8 | self.roles = {} |
| 9 | |
| 10 | def run(self): |
| 11 | roles = self.importer.api.GetRoles() |
| 12 | db_roles = Role.objects.all() |
| 13 | db_roles_list = [db_role['name'] for db_role in db_roles] |
| 14 | for role in roles: |
| 15 | if role['name'] not in db_roles_list: |
| 16 | new_role = Role(name=role['name']) |
| 17 | new_role.save() |
| 18 | self.roles[role['role_id']] = role |
| 19 | |
| 20 | |
| 21 | |