You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
658 B

10 years ago
10 years ago
  1. from django.contrib import admin
  2. from hc.api.models import Check
  3. @admin.register(Check)
  4. class ChecksAdmin(admin.ModelAdmin):
  5. class Media:
  6. css = {
  7. 'all': ('css/admin/checks.css',)
  8. }
  9. list_display = ("id", "name", "created", "code", "status", "email", "last_ping")
  10. list_select_related = ("user", )
  11. actions = ["send_alert"]
  12. def email(self, obj):
  13. return obj.user.email if obj.user else None
  14. def send_alert(self, request, qs):
  15. for check in qs:
  16. check.send_alert()
  17. self.message_user(request, "%d alert(s) sent" % qs.count())
  18. send_alert.short_description = "Send Alert"