diff --git a/apps/account/admin/user.py b/apps/account/admin/user.py index 49f7f6a..955dc9f 100644 --- a/apps/account/admin/user.py +++ b/apps/account/admin/user.py @@ -22,7 +22,7 @@ from apps.account.models import User, ClientUser, StudentUser, ProfessorUser, Lo from apps.course.models import Participant # Import Admin Sites from utils -from utils.admin import project_admin_site, dovoodi_admin_site +from utils.admin import project_admin_site, dovoodi_admin_site , is_dovoodi_panel from apps.account.admin.location import LocationHistoryInline # ========================================================= @@ -99,6 +99,34 @@ class UserAdmin(BaseUserAdmin, ModelAdmin): radio_fields = {"gender": admin.HORIZONTAL} readonly_fields = ["last_login", "date_joined", "display_auth_token"] + def get_fieldsets(self, request, obj=None): + # UserAdmin.get_fieldsets returns add_fieldsets when obj is None + fieldsets = super().get_fieldsets(request, obj) + if is_dovoodi_panel(request): + new_fieldsets = [] + for name, options in fieldsets: + # Hide entire Permissions section + if name == _('Permissions'): + continue + + new_options = options.copy() + # Hide skill field inside "Basic Information" (Edit) or the titleless section (Add) + if name == _("Basic Information") or name is None: + fields = list(new_options.get("fields", [])) + new_fields = [] + for f in fields: + if isinstance(f, (list, tuple)): + inner_f = [inner for inner in f if inner != 'skill'] + if inner_f: + new_fields.append(tuple(inner_f)) + elif f != 'skill': + new_fields.append(f) + new_options["fields"] = tuple(new_fields) + + new_fieldsets.append((name, new_options)) + return tuple(new_fieldsets) + return fieldsets + @display(description=_("Date Joined")) def display_date_joined(self, instance: User): return instance.date_joined.strftime("%Y-%m-%d %H:%M") if instance.date_joined else "-" diff --git a/apps/hadis/urls.py b/apps/hadis/urls.py index 7f698c5..9c9cc8c 100644 --- a/apps/hadis/urls.py +++ b/apps/hadis/urls.py @@ -55,7 +55,7 @@ urlpatterns = [ path('/corrections/', HadisCorrectionsView.as_view(), name='hadis-corrections'), path('/', HadisBasicView.as_view(), name='hadis-basic'), # ← Least specific LAST - path('test/test-deploy',test_deploy , name='test'), - path('debug-headers',debug_headers , name='headers'), + # path('test/test-deploy',test_deploy , name='test'), + # path('debug-headers',debug_headers , name='headers'), ]