saml: do not configure choice for attribute names at the model level as it breaks model validation before running migrations
This commit is contained in:
parent
ed76842bd5
commit
df8075399b
|
@ -23,6 +23,9 @@ from authentic2.saml.models import LibertySession
|
|||
from authentic2.saml.models import SAMLAttribute
|
||||
from authentic2.http_utils import get_url
|
||||
|
||||
from authentic2.decorators import to_iter
|
||||
from authentic2.attributes_ng.engine import get_attribute_names
|
||||
|
||||
from . import admin_views
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -165,6 +168,11 @@ def update_metadata(modeladmin, request, queryset):
|
|||
class SAMLAttributeInlineAdmin(GenericTabularInline):
|
||||
model = SAMLAttribute
|
||||
|
||||
def formfield_for_choice_field(self, db_field, request, **kwargs):
|
||||
if db_field.name == 'attribute_name':
|
||||
kwargs['choices'] = to_iter(get_attribute_names)({'user': None, 'request': None})
|
||||
return super(SAMLAttributeInlineAdmin, self).formfield_for_choice_field(db_field, request, **kwargs)
|
||||
|
||||
|
||||
class LibertyProviderAdmin(admin.ModelAdmin):
|
||||
form = LibertyProviderForm
|
||||
|
|
|
@ -24,8 +24,6 @@ except ImportError:
|
|||
from fields import PickledObjectField, MultiSelectField
|
||||
|
||||
from . import app_settings, managers
|
||||
from ..decorators import to_iter
|
||||
from ..attributes_ng.engine import get_attribute_names
|
||||
from .. import managers as a2_managers
|
||||
|
||||
def metadata_validator(meta):
|
||||
|
@ -348,7 +346,7 @@ class SAMLAttribute(models.Model):
|
|||
blank=True)
|
||||
attribute_name = models.CharField(max_length=64,
|
||||
verbose_name=_('attribute name'),
|
||||
choices=to_iter(get_attribute_names)({'user': None, 'request': None}))
|
||||
choices=(('', 'None'),))
|
||||
|
||||
def clean(self):
|
||||
super(SAMLAttribute, self).clean()
|
||||
|
|
Loading…
Reference in New Issue