admin.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # coding: utf-8
  2. from __future__ import print_function
  3. from __future__ import absolute_import
  4. from __future__ import division
  5. from __future__ import unicode_literals
  6. from django.contrib import admin
  7. from django.db import models
  8. import django.contrib.admin.widgets as adminwidgets
  9. import backend.models as bmodels
  10. class PersonAdmin(admin.ModelAdmin):
  11. exclude = ("user",)
  12. search_fields = ("cn", "sn", "email", "uid")
  13. def save_model(self, request, obj, form, change):
  14. """
  15. Given a model instance save it to the database.
  16. """
  17. obj.save(audit_author=request.user, audit_notes="edited from admin")
  18. admin.site.register(bmodels.Person, PersonAdmin)
  19. class AMAdmin(admin.ModelAdmin):
  20. search_fields = ("person__cn", "person__sn", "person__email", "person__uid")
  21. admin.site.register(bmodels.AM, AMAdmin)
  22. class LogInline(admin.TabularInline):
  23. model = bmodels.Log
  24. class ProcessAdmin(admin.ModelAdmin):
  25. raw_id_fields = ('manager',)
  26. filter_horizontal = ("advocates",)
  27. search_fields = ("person__cn", "person__sn", "person__email", "person__uid")
  28. admin.site.register(bmodels.Process, ProcessAdmin)
  29. class LogAdmin(admin.ModelAdmin):
  30. raw_id_fields = ('changed_by',)
  31. admin.site.register(bmodels.Log, LogAdmin)