~widelands-dev/widelands-website/django_staticfiles

17 by Holger Rapp
Main Page contains now the same informations as before
1
from django.contrib import admin
404.2.1 by franku
first try on Django1.8
2
from news.models import *
486.2.2 by franku
modified news admin page
3
from datetime import datetime
17 by Holger Rapp
Main Page contains now the same informations as before
4
486.2.3 by franku
make pyformat happy
5
17 by Holger Rapp
Main Page contains now the same informations as before
6
class CategoryAdmin(admin.ModelAdmin):
7
    prepopulated_fields = {'slug': ('title',)}
8
9
admin.site.register(Category, CategoryAdmin)
10
11
12
class PostAdmin(admin.ModelAdmin):
486.2.1 by franku
News admin: Use current user as initial author of a new news
13
14
    def get_changeform_initial_data(self, request):
486.2.4 by franku
changed a comment
15
        # Set initial values for new news
486.2.2 by franku
modified news admin page
16
        return {'author': request.user,
486.2.3 by franku
make pyformat happy
17
                'publish': datetime.now(),
18
                }
486.2.1 by franku
News admin: Use current user as initial author of a new news
19
438.1.6 by franku
run the script
20
    list_display = ('title', 'publish', 'status')
21
    list_filter = ('publish', 'categories', 'status')
17 by Holger Rapp
Main Page contains now the same informations as before
22
    search_fields = ('title', 'body')
23
    prepopulated_fields = {'slug': ('title',)}
486.2.2 by franku
modified news admin page
24
    fieldsets = (
25
        (None, {
486.2.5 by franku
removed unneeded commas
26
            'fields': (('title', 'slug'), 'body', ('publish', 'categories'))
486.2.2 by franku
modified news admin page
27
        }),
28
        ('More options', {
29
            'classes': ('collapse',),
486.2.5 by franku
removed unneeded commas
30
            'fields': ('author', ('status', 'allow_comments'), 'tease', 'tags')
486.2.2 by franku
modified news admin page
31
        }),
32
    )
17 by Holger Rapp
Main Page contains now the same informations as before
33
34
admin.site.register(Post, PostAdmin)