0002-auth_saml-move-model-form-parameters-to-class-53442.patch
src/authentic2_auth_saml/forms.py | ||
---|---|---|
17 | 17 |
from django import forms |
18 | 18 | |
19 | 19 |
from authentic2.a2_rbac.models import Role |
20 |
from authentic2.forms.widgets import SelectAttributeWidget |
|
20 | 21 |
from authentic2.manager.utils import label_from_role |
21 | 22 | |
22 | 23 |
from .models import SAMLAuthenticator |
... | ... | |
65 | 66 | |
66 | 67 |
def label_from_instance(self, obj): |
67 | 68 |
return label_from_role(obj) |
69 | ||
70 | ||
71 |
class SAMLRelatedObjectForm(forms.ModelForm): |
|
72 |
class Meta: |
|
73 |
exclude = ('authenticator',) |
|
74 |
field_classes = {'role': RoleChoiceField} |
|
75 |
widgets = {'user_field': SelectAttributeWidget} |
src/authentic2_auth_saml/views.py | ||
---|---|---|
7 | 7 |
from django.views.generic import CreateView, DeleteView, UpdateView |
8 | 8 |
from mellon.utils import get_idp |
9 | 9 | |
10 |
from authentic2.forms.widgets import SelectAttributeWidget |
|
11 | 10 |
from authentic2.manager.views import MediaMixin, TitleMixin |
12 | 11 |
from authentic2.utils.misc import redirect_to_login |
13 | 12 | |
14 |
from .forms import RoleChoiceField
|
|
13 |
from .forms import SAMLRelatedObjectForm
|
|
15 | 14 |
from .models import AddRoleAction, SAMLAttributeLookup, SAMLAuthenticator, SetAttributeAction |
16 | 15 | |
17 | 16 | |
... | ... | |
60 | 59 |
return super().dispatch(request, *args, **kwargs) |
61 | 60 | |
62 | 61 |
def get_form_class(self): |
63 |
return modelform_factory( |
|
64 |
self.model, |
|
65 |
exclude=('authenticator',), |
|
66 |
field_classes={'role': RoleChoiceField}, |
|
67 |
widgets={'user_field': SelectAttributeWidget}, |
|
68 |
) |
|
62 |
return modelform_factory(self.model, SAMLRelatedObjectForm) |
|
69 | 63 | |
70 | 64 |
def get_form_kwargs(self): |
71 | 65 |
kwargs = super().get_form_kwargs() |
72 |
- |