def tearDownClass(cls):
     super(CallCenterLocationOwnerOptionsViewTest, cls).tearDownClass()
     for user in cls.users:
         user.delete(deleted_by=None)
     CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, False, NAMESPACE_DOMAIN)
     cls.domain.delete()
     ensure_index_deleted(USER_INDEX_INFO.index)
     ensure_index_deleted(GROUP_INDEX_INFO.index)
Beispiel #2
0
    def setUpClass(cls):
        super(CallCenterLocationOwnerOptionsViewTest, cls).setUpClass()

        with trap_extra_setup(ConnectionError,
                              msg="cannot connect to elasicsearch"):
            es = get_es_new()
            ensure_index_deleted(USER_INDEX_INFO.index)
            ensure_index_deleted(GROUP_INDEX_INFO.index)
            initialize_index_and_mapping(es, USER_INDEX_INFO)
            initialize_index_and_mapping(es, GROUP_INDEX_INFO)

        # Create domain
        cls.domain = create_domain(TEST_DOMAIN)
        cls.domain.save()

        CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, True,
                                        NAMESPACE_DOMAIN)

        cls.username = "******"
        cls.password = "******"
        cls.web_user = WebUser.create(cls.domain.name, cls.username,
                                      cls.password)
        cls.web_user.save()

        # Create case sharing groups
        cls.groups = []
        for i in range(2):
            group = Group(domain=TEST_DOMAIN,
                          name="group{}".format(i),
                          case_sharing=True)
            group.save()
            send_to_elasticsearch('groups', group.to_json())
            cls.groups.append(group)
        es.indices.refresh(GROUP_INDEX_INFO.index)
        cls.group_ids = {g._id for g in cls.groups}

        # Create locations
        LocationType.objects.get_or_create(
            domain=cls.domain.name,
            name=LOCATION_TYPE,
            shares_cases=True,
        )
        cls.locations = [
            make_loc('loc{}'.format(i), type=LOCATION_TYPE, domain=TEST_DOMAIN)
            for i in range(4)
        ]
        cls.location_ids = {l._id for l in cls.locations}

        # Create users
        cls.users = [
            CommCareUser.create(TEST_DOMAIN, 'user{}'.format(i), '***')
            for i in range(3)
        ]
        for user in cls.users:
            send_to_elasticsearch('users', user.to_json())
        es.indices.refresh(USER_INDEX_INFO.index)
        cls.user_ids = {u._id for u in cls.users}
 def tearDownClass(cls):
     super(CallCenterLocationOwnerOptionsViewTest, cls).tearDownClass()
     for user in cls.users:
         user.delete()
     CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, False, NAMESPACE_DOMAIN)
     cls.domain.delete()
     cls.web_user.delete()
     ensure_index_deleted(USER_INDEX_INFO.index)
     ensure_index_deleted(GROUP_INDEX_INFO.index)
    def setUpClass(cls):
        super(CallCenterLocationOwnerOptionsViewTest, cls).setUpClass()

        with trap_extra_setup(ConnectionError, msg="cannot connect to elasicsearch"):
            es = get_es_new()
            ensure_index_deleted(USER_INDEX_INFO.index)
            ensure_index_deleted(GROUP_INDEX_INFO.index)
            initialize_index_and_mapping(es, USER_INDEX_INFO)
            initialize_index_and_mapping(es, GROUP_INDEX_INFO)

        # Create domain
        cls.domain = create_domain(TEST_DOMAIN)
        cls.domain.save()

        CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, True, NAMESPACE_DOMAIN)

        cls.username = "******"
        cls.password = "******"
        cls.web_user = WebUser.create(cls.domain.name, cls.username, cls.password)
        cls.web_user.save()

        # Create case sharing groups
        cls.groups = []
        for i in range(2):
            group = Group(domain=TEST_DOMAIN, name="group{}".format(i), case_sharing=True)
            group.save()
            send_to_elasticsearch('groups', group.to_json())
            cls.groups.append(group)
        es.indices.refresh(GROUP_INDEX_INFO.index)
        cls.group_ids = {g._id for g in cls.groups}

        # Create locations
        LocationType.objects.get_or_create(
            domain=cls.domain.name,
            name=LOCATION_TYPE,
            shares_cases=True,
        )
        cls.locations = [
            make_loc('loc{}'.format(i), type=LOCATION_TYPE, domain=TEST_DOMAIN) for i in range(4)
        ]
        cls.location_ids = {l._id for l in cls.locations}

        # Create users
        cls.users = [CommCareUser.create(TEST_DOMAIN, 'user{}'.format(i), '***') for i in range(3)]
        for user in cls.users:
            send_to_elasticsearch('users', user.to_json())
        es.indices.refresh(USER_INDEX_INFO.index)
        cls.user_ids = {u._id for u in cls.users}
Beispiel #5
0
    def static_options(self):
        from corehq.apps.domain.forms import USE_LOCATION_CHOICE
        from corehq.apps.domain.forms import USE_PARENT_LOCATION_CHOICE

        if CALL_CENTER_LOCATION_OWNERS.enabled(self.domain):
            return [
                (USE_LOCATION_CHOICE, ugettext("user's location [location]")),
                (USE_PARENT_LOCATION_CHOICE, ugettext("user's location's parent [location]")),
            ]
        return []