diff --git a/eox_nelp/admin/user.py b/eox_nelp/admin/user.py index 31aa3ce2..1faa6473 100644 --- a/eox_nelp/admin/user.py +++ b/eox_nelp/admin/user.py @@ -1,5 +1,16 @@ +""" +This module defines the Django admin configuration for handling user model. + +Classes: + NelpUserAdmin: Custom admin class for User model to include extra info fields like national_id. +""" from django.contrib.auth import get_user_model -from eox_support.admin.user import SupportUserAdmin +from django.contrib.auth.admin import UserAdmin as BaseUserAdmin + +try: + from eox_support.admin.user import SupportUserAdmin +except ImportError: + SupportUserAdmin = BaseUserAdmin from eox_nelp.admin.register_admin_model import register_admin_model as register @@ -8,13 +19,13 @@ class NelpUserAdmin(SupportUserAdmin): """EoxNelp User admin class.""" - list_display = ('user_national_id',) + SupportUserAdmin.list_display search_fields = SupportUserAdmin.search_fields + ('extrainfo__national_id',) fieldsets = SupportUserAdmin.fieldsets + ( ('Extra info Fields', {'fields': ('user_national_id',)}), ) readonly_fields = SupportUserAdmin.readonly_fields + ('user_national_id',) + def user_national_id(self, instance): """Return national_id associated with the user extra_info instance.""" if getattr(instance, "extrainfo", None):