Schule als Staat Projekt Web, Dokumente, etc.
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.

43 line
1.3KB

  1. from django.contrib import admin
  2. from .models import Betrieb, Partei, PresidentCandidate, Question
  3. from startpage.models import Banned
  4. def ban_ip(modeladmin, request, queryset):
  5. for obj in queryset:
  6. banned = Banned(ip_address=obj.ip_address,
  7. reason="")
  8. banned.save()
  9. modeladmin.message_user(request, "Ausgewählte Urheber erfolgreich verbannt.")
  10. ban_ip.short_description = "Urheber ausgewählter Eintrage verbannen"
  11. # Register your models here.
  12. class BetriebAdmin(admin.ModelAdmin):
  13. list_display = ('name', 'manager', 'confirmed')
  14. list_filter = ('confirmed',)
  15. actions = [ban_ip]
  16. class ParteiAdmin(admin.ModelAdmin):
  17. list_display = ('name', 'abbreviation', 'chef', 'description', 'confirmed')
  18. list_filter = ('confirmed',)
  19. actions = ('ban_ip',)
  20. class PresidentAdmin(admin.ModelAdmin):
  21. list_display = ('name', 'confirmed')
  22. list_filter = ('confirmed',)
  23. actions = ('ban_ip',)
  24. class QuestionAdmin(admin.ModelAdmin):
  25. list_display = ('subject', 'answered')
  26. list_filter = ('answered',)
  27. actions = ('ban_ip',)
  28. admin.site.register(Betrieb, BetriebAdmin)
  29. admin.site.register(Partei, ParteiAdmin)
  30. admin.site.register(PresidentCandidate, PresidentAdmin)
  31. admin.site.register(Question, QuestionAdmin)