@classmethod
    def get_template_json(cls, domain, apps):
        app_ids = dict([(app['_id'], app) for app in apps])
        self = ApplicationAccess.get_by_domain(domain)
        j = self.to_json()
        merged_access_list = []
        for a in j['app_groups']:
            app_id = a['app_id']
            if app_id in app_ids:
                merged_access_list.append(a)
                del app_ids[app_id]
        for app in app_ids.values():
            merged_access_list.append({
                'app_id': app['_id'],
                'group_id': None
            })
        j['app_groups'] = merged_access_list
        return j
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/cloudcare/models.py/ApplicationAccess.get_template_json/original