admin.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. """ Newforms Admin configuration for Darkroom
  2. """
  3. from django.contrib import admin
  4. from models import *
  5. PER_PAGE = 50
  6. class MovieAdmin(admin.ModelAdmin):
  7. list_display = ("title", "slug", "created", "published")
  8. list_filter = ["created", "published"]
  9. list_per_page = PER_PAGE
  10. admin.site.register(Movie, MovieAdmin)
  11. class GalleryAdmin(admin.ModelAdmin):
  12. list_display = ("title", "slug", "created", "photo_count", "published")
  13. list_filter = ["created", "published"]
  14. date_hierarchy = "created"
  15. filter_horizontal = (
  16. "towns",
  17. "sites",
  18. "photos",
  19. )
  20. class PhotographerAdmin(admin.ModelAdmin):
  21. list_display = ("name",)
  22. list_filter = ["created"]
  23. list_per_page = PER_PAGE
  24. class PhotoAdmin(admin.ModelAdmin):
  25. list_display = (
  26. "title",
  27. "slug",
  28. "created",
  29. "published",
  30. "view_count",
  31. "admin_thumbnail",
  32. )
  33. list_filter = ["created", "published"]
  34. list_per_page = PER_PAGE
  35. search_fields = (
  36. "title",
  37. "description",
  38. "photographer__name",
  39. )
  40. filter_horizontal = (
  41. "towns",
  42. "sites",
  43. )
  44. fieldsets = (
  45. (
  46. None,
  47. {
  48. "fields": (
  49. "title",
  50. "slug",
  51. "description",
  52. "image",
  53. "photographer",
  54. "courtesy",
  55. "file_photo",
  56. )
  57. },
  58. ),
  59. (
  60. "Publishing",
  61. {
  62. "fields": (
  63. "weight",
  64. "published",
  65. "published_on",
  66. "tags",
  67. "towns",
  68. "sites",
  69. )
  70. },
  71. ),
  72. ("Presentation", {"fields": ("crop_from", "effect", "orientation")}),
  73. )
  74. class PhotoEffectAdmin(admin.ModelAdmin):
  75. list_display = ("name", "description", "admin_sample")
  76. fieldsets = (
  77. (None, {"fields": ("name", "description")}),
  78. ("Adjustments", {"fields": ("color", "brightness", "contrast", "sharpness")}),
  79. ("Filters", {"fields": ("filters",)}),
  80. (
  81. "Reflection",
  82. {"fields": ("reflection_size", "reflection_strength", "background_color")},
  83. ),
  84. )
  85. class PhotoSizeAdmin(admin.ModelAdmin):
  86. list_display = (
  87. "name",
  88. "width",
  89. "height",
  90. "crop",
  91. "pre_cache",
  92. "effect",
  93. "increment_count",
  94. )
  95. fieldsets = (
  96. (None, {"fields": ("name", "width", "height", "quality")}),
  97. ("Options", {"fields": ("upscale", "crop", "pre_cache", "increment_count")}),
  98. ("Enhancements", {"fields": ("effect", "watermark",)}),
  99. )
  100. class WatermarkAdmin(admin.ModelAdmin):
  101. list_display = ("name", "opacity", "style")
  102. class GraphicAdmin(admin.ModelAdmin):
  103. list_display = (
  104. "title",
  105. "slug",
  106. "created",
  107. "published",
  108. "view_count",
  109. "admin_thumbnail",
  110. )
  111. list_filter = ["created", "published"]
  112. list_per_page = PER_PAGE
  113. admin.site.register(Graphic, GraphicAdmin)
  114. admin.site.register(Gallery, GalleryAdmin)
  115. admin.site.register(GalleryUpload)
  116. admin.site.register(Slideshow)
  117. admin.site.register(SlideshowUpload)
  118. admin.site.register(Photographer, PhotographerAdmin)
  119. admin.site.register(Photo, PhotoAdmin)
  120. admin.site.register(PhotoEffect, PhotoEffectAdmin)
  121. admin.site.register(PhotoSize, PhotoSizeAdmin)
  122. admin.site.register(Watermark, WatermarkAdmin)
  123. admin.site.register(Webcam)