|
3 | 3 | from django.utils.html import format_html
|
4 | 4 |
|
5 | 5 |
|
6 |
| -from mod_app.models import ProjectNote, Feedback |
| 6 | +from mod_app.models import ProjectNote, Feedback, VisualInfluences, WrittenInfluences |
| 7 | +from mod_app.utils.mixins import s3BrowserButtonMixin |
7 | 8 |
|
8 | 9 |
|
9 | 10 | @admin.register(ProjectNote)
|
@@ -40,3 +41,63 @@ def safe_content(self, obj):
|
40 | 41 |
|
41 | 42 | safe_content.allow_tags = True
|
42 | 43 | safe_content.short_description = "Content"
|
| 44 | + |
| 45 | + |
| 46 | +class VisInline(s3BrowserButtonMixin, admin.TabularInline): |
| 47 | + model = VisualInfluences.films.through |
| 48 | + extra = 1 |
| 49 | + classes = [ |
| 50 | + "grp-collapse", |
| 51 | + "grp-open", |
| 52 | + ] |
| 53 | + verbose_name = "Visual Influences" |
| 54 | + verbose_name_plural = "Visual Influences" |
| 55 | + |
| 56 | + |
| 57 | +class WritInline(s3BrowserButtonMixin, admin.TabularInline): |
| 58 | + model = WrittenInfluences.films.through |
| 59 | + extra = 1 |
| 60 | + classes = [ |
| 61 | + "grp-collapse", |
| 62 | + "grp-open", |
| 63 | + ] |
| 64 | + verbose_name = "Written Influences" |
| 65 | + verbose_name_plural = "Written Influences" |
| 66 | + |
| 67 | + |
| 68 | +@admin.register(VisualInfluences) |
| 69 | +class VisualInfluencesAdmin(s3BrowserButtonMixin, admin.ModelAdmin): |
| 70 | + class Media: |
| 71 | + js = ("admin/js/mentionsPluginConfig.js",) |
| 72 | + |
| 73 | + search_fields = ["title"] |
| 74 | + list_display = ["title", "safe_content"] |
| 75 | + readonly_fields = ("bibliography",) |
| 76 | + filter_horizontal = ("films",) |
| 77 | + |
| 78 | + def safe_content(self, obj): |
| 79 | + truncated_content = truncatechars_html(obj.content, 200) |
| 80 | + modified_content = truncated_content.replace("{", "(").replace("}", ")") |
| 81 | + return format_html(modified_content) |
| 82 | + |
| 83 | + safe_content.allow_tags = True |
| 84 | + safe_content.short_description = "Content" |
| 85 | + |
| 86 | + |
| 87 | +@admin.register(WrittenInfluences) |
| 88 | +class WrittenInfluencesAdmin(s3BrowserButtonMixin, admin.ModelAdmin): |
| 89 | + class Media: |
| 90 | + js = ("admin/js/mentionsPluginConfig.js",) |
| 91 | + |
| 92 | + search_fields = ["title"] |
| 93 | + list_display = ["title", "safe_content"] |
| 94 | + readonly_fields = ("bibliography",) |
| 95 | + filter_horizontal = ("films",) |
| 96 | + |
| 97 | + def safe_content(self, obj): |
| 98 | + truncated_content = truncatechars_html(obj.content, 200) |
| 99 | + modified_content = truncated_content.replace("{", "(").replace("}", ")") |
| 100 | + return format_html(modified_content) |
| 101 | + |
| 102 | + safe_content.allow_tags = True |
| 103 | + safe_content.short_description = "Content" |
0 commit comments