~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to pybb/admin.py

  • Committer: kaputtnik
  • Date: 2019-09-03 06:16:23 UTC
  • mfrom: (544.2.25 pybb_attachments)
  • Revision ID: kaputtnik-20190903061623-xu4kvqpabnzmuskw
Allow file uploads in the forum; added some basic file checks to validate files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8
2
2
from django.utils.translation import ugettext_lazy as _
3
3
from django.contrib import admin
4
 
from pybb.models import Category, Forum, Topic, Post, Read
 
4
from pybb.models import Category, Forum, Topic, Post, Read, Attachment
5
5
 
6
6
 
7
7
def delete_selected(modeladmin, request, queryset):
75
75
    )
76
76
 
77
77
 
 
78
class AttachmentInline(admin.StackedInline):
 
79
    model = Attachment
 
80
    extra = 0
 
81
    exclude = ('hash',)
 
82
 
 
83
 
78
84
class PostAdmin(admin.ModelAdmin):
79
85
    list_display = ['summary', 'topic', 'user', 'created', 'hidden']
80
86
    list_per_page = 20
82
88
    date_hierarchy = 'created'
83
89
    search_fields = ['body', 'topic__name']
84
90
    actions = [delete_selected, unhide_post]
 
91
    inlines = [AttachmentInline,]
85
92
    fieldsets = (
86
93
        (None, {
87
94
            'fields': ('topic', 'user', 'markup', 'hidden')
88
95
        }
89
96
        ),
90
 
        (_('Additional options'), {
 
97
        (_('Date and Time'), {
91
98
            'classes': ('collapse',),
92
99
            'fields': (('created', 'updated'),)
93
100
        }