From cd3097ba5c776e2c1546d071b70c499820721aea Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Mon, 16 Mar 2015 11:36:26 +0100 Subject: [PATCH] Integrate reversion to seminar, add admin-tools --- mamweb/settings_common.py | 5 +++++ mamweb/urls.py | 1 + requirements.txt | 3 ++- seminar/admin.py | 17 +++++++++-------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index c5b186c1..2c0abe59 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -76,6 +76,11 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ) INSTALLED_APPS = ( + 'admin_tools', + 'admin_tools.theming', + 'admin_tools.menu', + 'admin_tools.dashboard', + # Basic 'django.contrib.admin', 'django.contrib.auth', diff --git a/mamweb/urls.py b/mamweb/urls.py index de51d3da..28e43361 100644 --- a/mamweb/urls.py +++ b/mamweb/urls.py @@ -7,6 +7,7 @@ from django.conf import settings urlpatterns = i18n_patterns('', url(r'^admin/', include(admin.site.urls)), # NOQA + url(r'^admin_tools/', include('admin_tools.urls')), url(r'^ckeditor/', include('ckeditor.urls')), url(r'^', include('seminar.urls')), ) diff --git a/requirements.txt b/requirements.txt index 21fc890d..fb07b8ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ Pillow==2.7.0 pytz==2014.10 six==1.9.0 -# Django +# Django and modules Django==1.7.5 django-bootstrap-sass==0.0.6a0 @@ -16,6 +16,7 @@ django-sekizai==0.8.1 django-countries==3.2 django-solo==1.1.0 django-ckeditor==4.4.7 +django-admin-tools==0.5.2 # debug tools/extensions diff --git a/seminar/admin.py b/seminar/admin.py index 2fe2c4ae..de6afbf0 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.contrib import admin from django import forms +import reversion from solo.admin import SingletonModelAdmin from ckeditor.widgets import CKEditorWidget @@ -12,7 +13,7 @@ admin.site.register(Nastaveni, SingletonModelAdmin) ### Skola -class SkolaAdmin(admin.ModelAdmin): +class SkolaAdmin(reversion.VersionAdmin, admin.ModelAdmin): fieldsets = [ (None, {'fields': ['nazev', 'kratky_nazev']}), (u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}), @@ -26,7 +27,7 @@ admin.site.register(Skola, SkolaAdmin) ### Resitel -class ResitelAdmin(admin.ModelAdmin): +class ResitelAdmin(reversion.VersionAdmin, admin.ModelAdmin): fieldsets = [ (None, {'fields': ['jmeno', 'prijmeni', 'user']}), (u'Škola', {'fields': ['skola', 'rok_maturity']}), @@ -43,7 +44,7 @@ admin.site.register(Resitel, ResitelAdmin) ### Cislo -class CisloAdmin(admin.ModelAdmin): +class CisloAdmin(reversion.VersionAdmin, admin.ModelAdmin): fieldsets = [ (None, {'fields': ['cislo', 'rocnik']}), (u'Data', {'fields': ['datum_vydani', 'datum_deadline']}), @@ -60,7 +61,7 @@ class CisloInline(admin.StackedInline): ### Rocnik -class RocnikAdmin(admin.ModelAdmin): +class RocnikAdmin(reversion.VersionAdmin, admin.ModelAdmin): fieldsets = [ (None, {'fields': ['rocnik', 'prvni_rok']}), ] @@ -72,7 +73,7 @@ admin.site.register(Rocnik, RocnikAdmin) ### PrilohaReseni -class PrilohaReseniAdmin(admin.ModelAdmin): +class PrilohaReseniAdmin(reversion.VersionAdmin, admin.ModelAdmin): readonly_fields = ['timestamp'] fieldsets = [ (None, {'fields': ['reseni', 'soubor', 'timestamp']}), @@ -90,7 +91,7 @@ class PrilohaReseniInline(admin.StackedInline): ### Reseni -class ReseniAdmin(admin.ModelAdmin): +class ReseniAdmin(reversion.VersionAdmin, admin.ModelAdmin): readonly_fields = ['timestamp'] fieldsets = [ (None, {'fields': ['problem', 'resitel', 'body', 'cislo_body', 'timestamp']}), @@ -102,7 +103,7 @@ class ReseniAdmin(admin.ModelAdmin): admin.site.register(Reseni, ReseniAdmin) -class ReseniInline(admin.StackedInline): +class ReseniInline(admin.TabularInline): model = Reseni extra = 0 @@ -116,7 +117,7 @@ class ProblemAdminForm(forms.ModelForm): model = Problem exclude = [] -class ProblemAdmin(admin.ModelAdmin): +class ProblemAdmin(reversion.VersionAdmin, admin.ModelAdmin): form = ProblemAdminForm # readonly_fields = ['autor'] fieldsets = [