admin.py 879 B

123456789101112131415161718192021222324252627282930313233
  1. from django.contrib import admin
  2. from import_export.admin import ImportExportModelAdmin
  3. from .models import Project, ProjectKey, UserProjectAlert
  4. from .resources import ProjectResource
  5. class ProjectKeyInline(admin.StackedInline):
  6. model = ProjectKey
  7. extra = 0
  8. readonly_fields = ("dsn",)
  9. class ProjectAdmin(ImportExportModelAdmin):
  10. search_fields = ("name",)
  11. list_display = ("name", "organization")
  12. raw_id_fields = ("organization",)
  13. inlines = [ProjectKeyInline]
  14. resource_class = ProjectResource
  15. class UserProjectAlertAdmin(admin.ModelAdmin):
  16. list_display = ("user", "project", "status")
  17. list_filter = ("status",)
  18. search_fields = ("project__name", "user__email")
  19. raw_id_fields = (
  20. "user",
  21. "project",
  22. )
  23. admin.site.register(Project, ProjectAdmin)
  24. admin.site.register(UserProjectAlert, UserProjectAlertAdmin)