예제 #1
0
def config_dhis2_repeater(request, domain, repeater_id):
    repeater = Dhis2Repeater.get(repeater_id)
    assert repeater.domain == domain, f'"{repeater.domain}" != "{domain}"'

    if request.method == 'POST':
        form = Dhis2ConfigForm(data=request.POST)
        if form.is_valid():
            data = form.cleaned_data
            repeater.dhis2_config.form_configs = list(
                map(Dhis2FormConfig.wrap, data['form_configs']))
            repeater.save()

    else:
        form_configs = json.dumps([
            form_config.to_json()
            for form_config in repeater.dhis2_config.form_configs
        ])
        form = Dhis2ConfigForm(data={
            'form_configs': form_configs,
        })
    return render(request, 'dhis2/edit_config.html', {
        'domain': domain,
        'repeater_id': repeater_id,
        'form': form
    })
예제 #2
0
 def repeater(self):
     repeater = Dhis2Repeater.get(self.repeater_id)
     assert repeater.domain == self.domain
     return repeater
예제 #3
0
파일: view.py 프로젝트: dimagi/commcare-hq
 def repeater(self):
     repeater = Dhis2Repeater.get(self.repeater_id)
     assert repeater.domain == self.domain
     return repeater