Show More
@@ -7,12 +7,12 b' from boards.models import Post, Tag, Ban' | |||||
7 | @admin.register(Post) |
|
7 | @admin.register(Post) | |
8 | class PostAdmin(admin.ModelAdmin): |
|
8 | class PostAdmin(admin.ModelAdmin): | |
9 |
|
9 | |||
10 | list_display = ('id', 'title', 'text', 'poster_ip', 'linked_images') |
|
10 | list_display = ('id', 'title', 'text', 'poster_ip', 'linked_images', 'linked_global_id') | |
11 | list_filter = ('pub_time',) |
|
11 | list_filter = ('pub_time',) | |
12 | search_fields = ('id', 'title', 'text', 'poster_ip') |
|
12 | search_fields = ('id', 'title', 'text', 'poster_ip') | |
13 | exclude = ('referenced_posts', 'refmap', 'images') |
|
13 | exclude = ('referenced_posts', 'refmap', 'images', 'global_id') | |
14 | readonly_fields = ('poster_ip', 'threads', 'thread', 'linked_images', |
|
14 | readonly_fields = ('poster_ip', 'threads', 'thread', 'linked_images', | |
15 | 'attachments', 'uid', 'url', 'pub_time', 'opening') |
|
15 | 'attachments', 'uid', 'url', 'pub_time', 'opening', 'linked_global_id') | |
16 |
|
16 | |||
17 | def ban_poster(self, request, queryset): |
|
17 | def ban_poster(self, request, queryset): | |
18 | bans = 0 |
|
18 | bans = 0 | |
@@ -45,6 +45,14 b' class PostAdmin(admin.ModelAdmin):' | |||||
45 | return ', '.join(image_urls) |
|
45 | return ', '.join(image_urls) | |
46 | linked_images.allow_tags = True |
|
46 | linked_images.allow_tags = True | |
47 |
|
47 | |||
|
48 | def linked_global_id(self, obj: Post): | |||
|
49 | global_id = obj.global_id | |||
|
50 | if global_id is not None: | |||
|
51 | return '<a href="{}">{}</a>'.format( | |||
|
52 | reverse('admin:%s_%s_change' % (global_id._meta.app_label, | |||
|
53 | global_id._meta.model_name), | |||
|
54 | args=[global_id.id]), str(global_id)) | |||
|
55 | linked_global_id.allow_tags = True | |||
48 |
|
56 | |||
49 | actions = ['ban_poster', 'ban_with_hiding'] |
|
57 | actions = ['ban_poster', 'ban_with_hiding'] | |
50 |
|
58 | |||
@@ -125,4 +133,4 b' class GlobalIdAdmin(admin.ModelAdmin):' | |||||
125 | return Post.objects.filter(global_id=obj).exists() |
|
133 | return Post.objects.filter(global_id=obj).exists() | |
126 |
|
134 | |||
127 | list_display = ('__str__', 'is_linked',) |
|
135 | list_display = ('__str__', 'is_linked',) | |
128 | readonly_fields = ('content',) No newline at end of file |
|
136 | readonly_fields = ('content',) |
General Comments 0
You need to be logged in to leave comments.
Login now