Skip to content

Commit

Permalink
♻️ [#45] Split clean functionality from form Model
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Apr 8, 2022
1 parent 4fb7b0e commit 8511969
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions mozilla_django_oidc_db/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@
from .models import OpenIDConnectConfig


class OpenIDConnectConfigForm(forms.ModelForm):
required_endpoints = [
"oidc_op_authorization_endpoint",
"oidc_op_token_endpoint",
"oidc_op_user_endpoint",
]
class CleanUrlsFormMixin:
required_endpoints = []
oidc_mapping = OIDC_MAPPING

class Meta:
model = OpenIDConnectConfig
fields = "__all__"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -65,3 +57,16 @@ def clean(self):
self.add_error(field, _("This field is required."))

return cleaned_data


class OpenIDConnectConfigForm(CleanUrlsFormMixin, forms.ModelForm):
required_endpoints = [
"oidc_op_authorization_endpoint",
"oidc_op_token_endpoint",
"oidc_op_user_endpoint",
]
oidc_mapping = OIDC_MAPPING

class Meta:
model = OpenIDConnectConfig
fields = "__all__"

0 comments on commit 8511969

Please sign in to comment.