@@ -0,0 +1,2881 @@
+from __future__ import absolute_import%0Afrom __future__ import unicode_literals%0A%0Afrom memoized import memoized%0Afrom django import forms%0Afrom django.utils.translation import ugettext as _, ugettext_noop, ugettext_lazy%0A%0Afrom crispy_forms.layout import Submit%0Afrom crispy_forms import layout as crispy%0Afrom crispy_forms.bootstrap import StrictButton%0A%0Afrom corehq.apps.hqwebapp import crispy as hqcrispy%0Afrom corehq.apps.integration.models import SimprintsIntegration%0A%0A%0Aclass SimprintsIntegrationForm(forms.Form):%0A    is_enabled = forms.BooleanField(%0A        label=ugettext_noop(%22Enable Simprints Integration%22),%0A        required=False%0A    )%0A    project_id = forms.CharField(%0A        label=ugettext_noop(%22Project ID%22),%0A        required=False,%0A    )%0A    user_id = forms.CharField(%0A        label=ugettext_noop(%22User ID%22),%0A        required=False,%0A    )%0A    module_id = forms.CharField(%0A        label=ugettext_noop(%22Module ID%22),%0A        required=False,%0A    )%0A%0A    def __init__(self, data, *args, **kwargs):%0A        self._domain = kwargs.pop('domain')%0A        super(SimprintsIntegrationForm, self).__init__(data, *args, **kwargs)%0A%0A        self.helper = hqcrispy.HQFormHelper()%0A        self.helper.form_method = 'POST'%0A        self.helper.layout = crispy.Layout(%0A            hqcrispy.B3MultiField(%0A                _(%22Simprints Integration%22),%0A                hqcrispy.InlineField(%0A                    'is_enabled', data_bind=%22checked: isEnabled%22%0A                ),%0A            ),%0A            crispy.Div(%0A                crispy.Field('project_id', data_bind=%22value: projectId%22),%0A                crispy.Field('user_id', data_bind=%22value: userId%22),%0A                crispy.Field('module_id', data_bind=%22value: moduleId%22),%0A                data_bind=%22visible: isEnabled%22%0A            ),%0A            hqcrispy.FormActions(%0A                crispy.ButtonHolder(%0A                    Submit('submit', ugettext_lazy(%22Update%22))%0A                )%0A            )%0A        )%0A%0A    @property%0A    @memoized%0A    def _existing_integration(self):%0A        existing, _created = SimprintsIntegration.objects.get_or_create(%0A            domain=self._domain,%0A        )%0A        return existing%0A%0A    @property%0A    def initial_data(self):%0A        return %7B%0A            'is_enabled': self._existing_integration.is_enabled,%0A            'project_id': self._existing_integration.project_id,%0A            'user_id': self._existing_integration.user_id or %22global_user%22,%0A            'module_id': self._existing_integration.module_id or %22global_module%22,%0A        %7D%0A%0A    def save(self):%0A        self._existing_integration.is_enabled = self.cleaned_data%5B'is_enabled'%5D%0A        self._existing_integration.project_id = self.cleaned_data%5B'project_id'%5D%0A        self._existing_integration.user_id = self.cleaned_data%5B'user_id'%5D%0A        self._existing_integration.module_id = self.cleaned_data%5B'module_id'%5D%0A        self._existing_integration.save()%0A

add form for updating simprints integration