Skip to content

Commit

Permalink
Adjust comment and method name
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Mar 8, 2023
1 parent e0a2e86 commit 2bea8b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion temba/channels/types/twilio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ def __init__(self, *args, **kwargs):
default="",
)

# We override the clean method for Twilio we need to make sure we grab the primary auth tokens
def clean(self) -> Dict[str, Any]:
"""
We override the clean method for Twilio we need to make sure we grab the primary auth tokens
"""
account_sid = self.cleaned_data.get("account_sid", None)
account_token = self.cleaned_data.get("auth_token", None)

Expand Down
7 changes: 5 additions & 2 deletions temba/channels/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,17 @@ def add_config_field(self, config_key: str, field, *, default):
self.fields[config_key] = field
self.config_fields.append(config_key)

def transform_form_data_credentials_config(self, cleaned_data: dict, extra: dict) -> dict:
def creds_config(self, cleaned_data: dict, extra: dict) -> dict:
"""
Transform form data credentials to config format dict
"""
config = cleaned_data.copy()
config.update(**extra)
return config

def clean(self) -> dict[str, Any]:
cleaned_data = super().clean()
credentials_config = self.transform_form_data_credentials_config(cleaned_data, {})
credentials_config = self.creds_config(cleaned_data, {})
if not Channel.get_type_from_code(self.object.channel_type).check_credentials(credentials_config):
raise ValidationError(_("Channel credentials don't appear to be valid."))
return cleaned_data
Expand Down

0 comments on commit 2bea8b5

Please sign in to comment.