blob: efd3933d74a072f1ce5b6f790c1dbc0ac72031f5 [file] [log] [blame]
Tony Mackf593dba2013-03-24 13:17:43 -04001from PLC.Sites import Sites
2from models import Site
3
4class SiteImporter:
5
6 def __init__(self, importer):
7 self.importer = importer
8 self.sites = {}
9
10 def run(self):
11 sites = Sites(self.importer.api)
12 db_sites = Site.objects.all()
13 db_site_names = [s['login_base'] for s in db_sites]
14 for site in sites:
15 if site['login_base'] not in db_site_names:
16 new_site = Site(name=site['name'],
17 site_url=site['url'],
18 enabled=site['enabled'],
19 longitude=site['longitude'],
20 latitude=site['latitude'],
21 is_public=site['is_public'],
22 abbreviated_name=site['abbreviated_name'])
23 new_site.save()
24 self.sites[site['site_id']] = site
25
26
27