models,admin: do not put choice for attribut name in models only admin
This commit is contained in:
parent
10821da43e
commit
7990ee11b4
|
@ -1,6 +1,8 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib import admin
|
||||
|
||||
from authentic2.decorators import to_iter
|
||||
from authentic2.attributes_ng.engine import get_attribute_names
|
||||
from provider.oauth2.admin import ClientAdmin
|
||||
|
||||
from . import models
|
||||
|
@ -11,6 +13,11 @@ class WebServiceAdmin(admin.ModelAdmin):
|
|||
class AttributeReleaseInline(admin.TabularInline):
|
||||
model = models.AttributeRelease
|
||||
|
||||
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(AttributeReleaseInline, self).formfield_for_choice_field(db_field, request, **kwargs)
|
||||
|
||||
class A2ClientAdmin(ClientAdmin):
|
||||
inlines = [AttributeReleaseInline]
|
||||
fieldsets = (
|
||||
|
|
|
@ -7,8 +7,6 @@ from provider.oauth2.models import Client
|
|||
|
||||
from authentic2.models import LogoutUrlAbstract
|
||||
from authentic2.managers import GetBySlugManager
|
||||
from authentic2.decorators import to_iter
|
||||
from authentic2.attributes_ng.engine import get_attribute_names
|
||||
|
||||
class A2Client(LogoutUrlAbstract, Client):
|
||||
class Meta:
|
||||
|
@ -21,7 +19,7 @@ class AttributeRelease(models.Model):
|
|||
name = models.CharField(verbose_name=_('name'), max_length=64)
|
||||
attribute_name = models.CharField(max_length=64,
|
||||
verbose_name=_('attribute name'),
|
||||
choices=to_iter(get_attribute_names)({'user': None, 'request': None}))
|
||||
choices=(('', 'None'),))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('OAuth2 attribute release')
|
||||
|
|
Reference in New Issue