[UPDT] EMPLOYEE: Updated employee admin page by adding additional attributes to Employee model admin registration part

This commit is contained in:
Horilla
2025-04-16 09:58:25 +05:30
parent 0bc710cca5
commit 2807c1c384
2 changed files with 22 additions and 9 deletions

View File

@@ -32,19 +32,32 @@ admin.site.register([DisciplinaryAction, Actiontype])
from django.contrib import admin
class MyModelAdmin(admin.ModelAdmin):
class EmployeeAdmin(admin.ModelAdmin):
list_display = (
"badge_id",
"employee_first_name",
"employee_last_name",
"employee_user_id",
"is_active",
)
search_fields = (
"badge_id",
"employee_user_id__username",
"employee_first_name",
"employee_last_name",
)
list_filter = ("is_active",)
ordering = ("employee_first_name", "employee_last_name")
def delete_view(self, request, object_id, extra_context=None):
# Add custom context for the delete confirmation page
extra_context = extra_context or {}
extra_context["custom_message"] = (
"Are you sure you want to delete this item? This action cannot be undone."
)
# Call the superclass's delete_view to render the page
return super().delete_view(request, object_id, extra_context=extra_context)
def get_deleted_objects(self, objs, request):
response = super().get_deleted_objects(objs, request)
return response
admin.site.register(Employee, MyModelAdmin)
admin.site.register(Employee, EmployeeAdmin)

View File

@@ -46,4 +46,4 @@
</div>
</form>
</div>
</div>
</div>