ftp_deploy.admin: 26 total statements, 87.0% covered

Generated: Mon 2013-12-16 18:43 GMT

Source file: /var/www/service.dev/service/ftp_deploy/admin.py

Stats: 20 executed, 3 missed, 3 excluded, 28 ignored

  1. from django.contrib import admin
  2. from .models import Log, Service, Notification
  3. from ftp_deploy.server.forms import NotificationForm
  4. class ServiceAdmin(admin.ModelAdmin):
  5. list_display = ('repo_name', 'repo_branch', 'hook_url', 'status_message_html', 'status')
  6. fieldsets = (
  7. ('FTP Settings', {
  8. 'fields': ('ftp_host', ('ftp_username', 'ftp_password'), 'ftp_path')
  9. }),
  10. ('Repository', {
  11. 'classes': ('',),
  12. 'fields': ('repo_source', 'repo_name', 'repo_branch')
  13. }),
  14. ('Security', {
  15. 'classes': ('collapse',),
  16. 'fields': ('secret_key',)
  17. }),
  18. )
  19. def status_message_html(self, obj):
  20. return obj.status_message
  21. status_message_html.allow_tags = True
  22. status_message_html.short_description = 'Status Message'
  23. class LogAdmin(admin.ModelAdmin):
  24. list_display = ('id', 'created', 'user', 'status_message_html', 'status')
  25. readonly_fields = ('service', 'created', 'user', 'status','status_message_html')
  26. exclude = ('payload',)
  27. def has_add_permission(self, request):
  28. return False
  29. def status_message_html(self, obj):
  30. return obj.status_message
  31. status_message_html.allow_tags = True
  32. status_message_html.short_description = 'Status Message'
  33. class NotificationAdmin(admin.ModelAdmin):
  34. form = NotificationForm
  35. list_display = ('name',)
  36. admin.site.register(Notification, NotificationAdmin)
  37. admin.site.register(Service, ServiceAdmin)
  38. admin.site.register(Log, LogAdmin)