blob: 7476967087f43def1722b6bcaae31083dc74b588 [file] [log] [blame]
Tony Mackf593dba2013-03-24 13:17:43 -04001from PLC.Persons import Persons
2from models import User
3
4class UserImporter:
5
6 def __init__(self, importer):
7 self.importer = importer
8 self.users = {}
9
10 def run(self):
11 users = Persons(self.importer.api)
12 db_users = User.objects.all()
13 usernames = [u['email'] for u in db_users]
14 for user in users:
15 if user['email'] not in usernames:
16 new_user = User(firstname=user['first_name'],
17 lastname=user['last_name'],
18 email=user['email'],
19 phone=user['phone'],
20 user_url = user['url'],
21 site = user['sites_ids'][0])
22 new_user.save()
23 self.save_site_privs(user)
24 self.save_slice_privs(user)
25 self.users[user['person_id']] = user
26
27 def save_site_privs(self, user):
28 # update site roles
29 pass
30
31 def save_slice_privs(self, user):
32 # update slice roles
33 pass
34
35