예제 #1
0
def migrate_auth_field(apps, schema_editor):
    repeater_ids = [row['id'] for row in Repeater.view(
        'receiverwrapper/repeaters',
        include_docs=False,
        reduce=False,
        wrap_doc=False
    )]
    iter_update(
        db=Repeater.get_db(),
        fn=migrate_repeater,
        ids=repeater_ids,
    )
예제 #2
0
 def obj_update(self, bundle, **kwargs):
     bundle.obj = Repeater.get(kwargs['pk'])
     assert bundle.obj.domain == kwargs['domain']
     bundle = self._update(bundle)
     assert bundle.obj.domain == kwargs['domain']
     bundle.obj.save()
     return bundle
예제 #3
0
 def obj_update(self, bundle, **kwargs):
     bundle.obj = Repeater.get(kwargs['pk'])
     assert bundle.obj.domain == kwargs['domain']
     bundle = self._update(bundle)
     assert bundle.obj.domain == kwargs['domain']
     bundle.obj.save()
     return bundle
예제 #4
0
    def test_clone_repeaters(self):
        from corehq.apps.repeaters.models import Repeater
        from corehq.apps.repeaters.models import CaseRepeater
        from corehq.apps.repeaters.models import FormRepeater
        from custom.enikshay.integrations.nikshay.repeaters import NikshayRegisterPatientRepeater

        self.assertEqual(0, len(Repeater.by_domain(self.new_domain)))
        self.assertEqual(
            0, len(NikshayRegisterPatientRepeater.by_domain(self.new_domain)))

        case_repeater = CaseRepeater(
            domain=self.old_domain,
            url='case-repeater-url',
        )
        case_repeater.save()
        self.addCleanup(case_repeater.delete)
        form_repeater = FormRepeater(
            domain=self.old_domain,
            url='form-repeater-url',
        )
        form_repeater.save()
        self.addCleanup(form_repeater.delete)
        custom_repeater = NikshayRegisterPatientRepeater(
            domain=self.old_domain, url='99dots')
        custom_repeater.save()
        self.addCleanup(custom_repeater.delete)

        self.make_clone(include=['repeaters'])

        cloned_repeaters = Repeater.by_domain(self.new_domain)
        self.assertEqual(3, len(cloned_repeaters))
        self.assertEqual(
            {'CaseRepeater', 'FormRepeater', 'NikshayRegisterPatientRepeater'},
            {repeater.doc_type
             for repeater in cloned_repeaters})

        # test cache clearing
        cloned_niksay_repeaters = NikshayRegisterPatientRepeater.by_domain(
            self.new_domain)
        self.assertEqual(1, len(cloned_niksay_repeaters))
예제 #5
0
 def obj_get_list(self, bundle, domain, **kwargs):
     repeaters = Repeater.by_domain(domain)
     return list(repeaters)
예제 #6
0
 def obj_get_list(self, bundle, domain, **kwargs):
     repeaters = Repeater.by_domain(domain)
     return list(repeaters)