def fetch_all_groups(): """Pull all group names and ids from Elvanto.""" data = elvanto("groups/getAll") if data['status'] != 'ok': raise ElvantoException for grp in data['groups']['group']: grp_obj = ElvantoGroup.objects.get_or_create(e_id=grp['id'])[0] grp_obj.name = grp['name'] grp_obj.save()
def fetch_all_groups(): """Pull all group names and ids from Elvanto.""" data = elvanto("groups/getAll") if data["status"] != "ok": raise ElvantoException for grp in data["groups"]["group"]: grp_obj = ElvantoGroup.objects.get_or_create(e_id=grp["id"])[0] grp_obj.name = grp["name"] grp_obj.save()
def pull(self): """Pull group from Elvanto into related apostello group.""" apostello_group = self.create_apostello_group() data = elvanto("groups/getInfo", id=self.e_id, fields=['people']) if data['status'] != 'ok': raise ElvantoException if data['group'][0]['people']: for prsn in data['group'][0]['people']['person']: ElvantoGroup.add_person(apostello_group, prsn) apostello_group.save() self.last_synced = timezone.now() self.save()