<s> from corehq . apps . sms . forms import BackendForm <EOL> from corehq . apps . sms . util import validate_phone_number <EOL> from corehq . apps . style import crispy as hqcrispy <EOL> from crispy_forms import layout as crispy <EOL> from crispy_forms . bootstrap import StrictButton , FormActions <EOL> from crispy_forms . helper import FormHelper <EOL> from crispy_forms . layout import Layout , Div , HTML <EOL> from dimagi . utils . django . fields import TrimmedCharField <EOL> from django . core . exceptions import ValidationError <EOL> from django . forms . fields import ChoiceField <EOL> from django . forms . forms import Form <EOL> from django . utils . translation import ugettext as _ , ugettext_lazy <EOL> def get_rmi_error_placeholder ( error_name ) : <EOL> return Div ( <EOL> HTML ( '<STR_LIT>' % error_name ) , <EOL> ng_show = error_name , <EOL> ) <EOL> class TelerivetBackendForm ( BackendForm ) : <EOL> api_key = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> ) <EOL> project_id = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> ) <EOL> phone_id = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> ) <EOL> webhook_secret = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> ) <EOL> @ property <EOL> def gateway_specific_fields ( self ) : <EOL> return crispy . Fieldset ( <EOL> _ ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def clean_webhook_secret ( self ) : <EOL> from corehq . messaging . smsbackends . telerivet . models import SQLTelerivetBackend <EOL> value = self . cleaned_data [ '<STR_LIT>' ] <EOL> backend = SQLTelerivetBackend . by_webhook_secret ( value ) <EOL> if backend and backend . pk != self . _cchq_backend_id : <EOL> raise ValidationError ( _ ( "<STR_LIT>" ) ) <EOL> return value <EOL> class TelerivetOutgoingSMSForm ( Form ) : <EOL> api_key = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> required = True <EOL> ) <EOL> project_id = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> required = True <EOL> ) <EOL> phone_id = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> required = True <EOL> ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TelerivetOutgoingSMSForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . helper = FormHelper ( ) <EOL> self . helper . form_class = '<STR_LIT>' <EOL> self . helper . label_class = '<STR_LIT>' <EOL> self . helper . field_class = '<STR_LIT>' <EOL> self . helper . layout = Layout ( <EOL> Div ( <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT>' , <EOL> ng_model = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) , <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT>' , <EOL> ng_model = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) , <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT>' , <EOL> ng_model = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) <EOL> ) <EOL> ) <EOL> class TelerivetPhoneNumberForm ( Form ) : <EOL> test_phone_number = TrimmedCharField ( <EOL> required = True <EOL> ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TelerivetPhoneNumberForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . helper = FormHelper ( ) <EOL> self . helper . form_class = '<STR_LIT>' <EOL> self . helper . label_class = '<STR_LIT>' <EOL> self . helper . field_class = '<STR_LIT>' <EOL> self . helper . layout = Layout ( <EOL> Div ( <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT>' , <EOL> ng_model = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> Div ( <EOL> StrictButton ( <EOL> _ ( "<STR_LIT>" ) , <EOL> id = '<STR_LIT>' , <EOL> css_class = '<STR_LIT>' , <EOL> ng_click = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) <EOL> ) <EOL> ) <EOL> def clean_test_phone_number ( self ) : <EOL> value = self . cleaned_data . get ( '<STR_LIT>' ) <EOL> validate_phone_number ( value ) <EOL> return value <EOL> class FinalizeGatewaySetupForm ( Form ) : <EOL> YES = '<STR_LIT:Y>' <EOL> NO = '<STR_LIT:N>' <EOL> YES_NO_CHOICES = ( <EOL> ( YES , ugettext_lazy ( "<STR_LIT>" ) ) , <EOL> ( NO , ugettext_lazy ( "<STR_LIT>" ) ) , <EOL> ) <EOL> name = TrimmedCharField ( <EOL> label = ugettext_lazy ( "<STR_LIT:Name>" ) , <EOL> required = True <EOL> ) <EOL> set_as_default = ChoiceField ( <EOL> label = ugettext_lazy ( "<STR_LIT>" ) , <EOL> choices = YES_NO_CHOICES , <EOL> required = True <EOL> ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( FinalizeGatewaySetupForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . helper = FormHelper ( ) <EOL> self . helper . form_class = '<STR_LIT>' <EOL> self . helper . label_class = '<STR_LIT>' <EOL> self . helper . field_class = '<STR_LIT>' <EOL> self . helper . layout = Layout ( <EOL> Div ( <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT:Name>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT:name>' , <EOL> ng_model = '<STR_LIT:name>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) , <EOL> hqcrispy . B3MultiField ( <EOL> _ ( "<STR_LIT>" ) , <EOL> Div ( <EOL> hqcrispy . MultiInlineField ( <EOL> '<STR_LIT>' , <EOL> ng_model = '<STR_LIT>' <EOL> ) <EOL> ) , <EOL> get_rmi_error_placeholder ( '<STR_LIT>' ) , <EOL> ng_class = "<STR_LIT>" <EOL> ) , <EOL> FormActions ( <EOL> StrictButton ( <EOL> _ ( "<STR_LIT>" ) , <EOL> id = "<STR_LIT>" , <EOL> css_class = '<STR_LIT>' , <EOL> ng_click = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> ) <EOL> ) </s>
