from django.contrib.admin import register, ModelAdmin, TabularInline, StackedInline from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin as OriginalUserAdmin from django.contrib.admin.sites import site from .models import Application, Protocol, ProtocolApplication, Token, TokenAttribute, TokenPermission, UserAttribute site.unregister(User) User.get_full_name.short_description = _("Nome") @register(User) class UserAdmin(OriginalUserAdmin): readonly_fields = ('last_login', 'date_joined') change_user_password_template = None fieldsets = ( (None, { 'fields': ('username', 'password', 'date_joined', 'last_login') }), # (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), (_('Permissions'), { 'fields': ('is_active', 'is_staff', 'is_superuser', 'groups') }), ) add_fieldsets = ( (None, { 'classes': ('wide', ), 'fields': ('username', 'password1', 'password2') }), # (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
'fields': [('backend_class', ), ('priority', ), ('is_active', ), ('name', ), ('code', )] }), ] list_display = ['uuid', 'backend_class', 'is_active', 'name', 'code'] list_filter = ['is_active'] ordering = ['name'] search_fields = ['backend_class', 'name'] inlines = [MessagingProviderDirectoryOptionInline] prepopulated_fields = {'code': ('name', )} @admin.register(MessagingRoute) class MessagingRouteAdmin(AbstractReplicatableAdmin): fieldsets = [ ('General', { 'classes': ('wide', ), 'fields': [('directory', ), ('prefix', )] }), ] list_display = ['uuid', 'directory', 'prefix'] ordering = ['prefix'] search_fields = ['directory', 'prefix'] from django.contrib.admin.sites import site from django.contrib.auth.models import Group site.unregister(Group)
@admin.register(ApiScopeTranslation) class ApiScopeTranslationAdmin(admin.ModelAdmin): list_filter = ['master', 'language_code'] list_display = ['master', 'language_code', 'name', 'description'] class OidcClientForm(oidc_provider.admin.ClientForm): """ OIDC Client form which allows changing the client_id. """ def __init__(self, *args, **kwargs): super(OidcClientForm, self).__init__(*args, **kwargs) self.fields['client_id'].required = True self.fields['client_id'].widget.attrs.pop('disabled', None) def clean_client_id(self): return self.cleaned_data['client_id'] class OidcClientOptionsInlineAdmin(admin.StackedInline): model = OidcClientOptions admin_site.unregister(oidc_provider.models.Client) @admin.register(oidc_provider.models.Client) class ClientAdmin(oidc_provider.admin.ClientAdmin): form = OidcClientForm inlines = [OidcClientOptionsInlineAdmin]
'fields': ('email', 'password', 'first_name', 'last_name') }), (_('Permissions'), { 'fields': ('is_active', 'is_staff', 'is_email_verified', 'is_superuser', 'groups', 'user_permissions') }), (_('Important dates'), { 'fields': ('last_login', 'created') }), ) add_fieldsets = ((None, { 'classes': ('wide', ), 'fields': ('email', 'password1', 'password2'), }), ) list_display = ('email', 'is_superuser', 'is_staff', 'is_email_verified', 'created') search_fields = ('email', 'first_name', 'last_name') list_filter = ('is_email_verified', 'is_active', 'is_staff') ordering = ('-is_superuser', 'email') readonly_fields = ('last_login', 'created') class GroupAdmin(admin.ModelAdmin): list_display = ('name', ) filter_horizontal = ('permissions', ) default_site.unregister(DjangoGroup) admin.site.register(Group, GroupAdmin)