Browse Source

Spravne pridano Reversion pro zaznamenavani zmen (modely, middleware)

remotes/origin/Galerie
Tomas Gavenciak 9 years ago
parent
commit
3c501cdda5
  1. 20
      seminar/admin.py
  2. 3
      seminar/models.py

20
seminar/admin.py

@ -3,7 +3,7 @@
from django.contrib import admin
from django import forms
from django.forms import widgets
import reversion
from reversion.admin import VersionAdmin
from solo.admin import SingletonModelAdmin
from ckeditor.widgets import CKEditorWidget
from django.db.models import Count
@ -165,7 +165,7 @@ class Soustredeni_UcastniciInline(admin.TabularInline):
### Resitel
class ResitelAdmin(reversion.VersionAdmin):
class ResitelAdmin(VersionAdmin):
form = autocomplete_light.modelform_factory(Resitel, autocomplete_fields=['skola'], fields=['skola'])
fieldsets = [
(None, {'fields': ['jmeno', 'prijmeni', 'user']}),
@ -192,7 +192,7 @@ admin.site.register(Resitel, ResitelAdmin)
### Skola
class SkolaAdmin(reversion.VersionAdmin):
class SkolaAdmin(VersionAdmin):
fieldsets = [
(None, {'fields': ['nazev', 'kratky_nazev', 'je_zs', 'je_ss']}),
(u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}),
@ -209,7 +209,7 @@ admin.site.register(Skola, SkolaAdmin)
### Cislo
class CisloAdmin(reversion.VersionAdmin):
class CisloAdmin(VersionAdmin):
fieldsets = [
(None, {'fields': ['cislo', 'rocnik', 'verejne_db', 'verejna_vysledkovka', 'poznamka', 'pdf']}),
(u'Data', {'fields': ['datum_vydani', 'datum_deadline']}),
@ -232,7 +232,7 @@ admin.site.register(Cislo, CisloAdmin)
### Rocnik
class RocnikAdmin(reversion.VersionAdmin):
class RocnikAdmin(VersionAdmin):
fieldsets = [
(None, {'fields': ['rocnik', 'prvni_rok', 'exportovat']}),
]
@ -264,7 +264,7 @@ admin.site.register(Rocnik, RocnikAdmin)
### Reseni
class ReseniAdmin(reversion.VersionAdmin):
class ReseniAdmin(VersionAdmin):
form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitel'], fields=['problem', 'resitel'])
fieldsets = [
(None, {'fields': ['problem', 'resitel', 'forma', 'body', 'cislo_body', 'timestamp']}),
@ -299,7 +299,7 @@ class ProblemAdminForm(forms.ModelForm):
model = Problem
exclude = []
class ProblemAdmin(reversion.VersionAdmin):
class ProblemAdmin(VersionAdmin):
form = ProblemAdminForm
fieldsets = [
(None, {'fields': ['nazev', 'typ', 'stav', 'autor', 'zamereni', 'body', 'timestamp', 'import_dakos_id']}),
@ -354,7 +354,7 @@ class SoustredeniAdminForm(forms.ModelForm):
model = Soustredeni
exclude = []
class SoustredeniAdmin(reversion.VersionAdmin):
class SoustredeniAdmin(VersionAdmin):
form = SoustredeniAdminForm
fieldsets = [
(None, {'fields': ['rocnik', 'misto', 'typ', 'verejne_db', 'exportovat', 'text']}),
@ -399,7 +399,7 @@ def zneverejnit_novinky(modeladmin, request, queryset):
zneverejnit_novinky.short_description = 'Zneveřejnit vybrané novinky'
class NovinkyAdmin(admin.ModelAdmin):
class NovinkyAdmin(VersionAdmin):
form = NovinkyAdminForm
list_display = ['datum', 'autor', 'text', 'zverejneno', 'obrazek']
actions = [zverejnit_novinky, zneverejnit_novinky]
@ -444,7 +444,7 @@ deaktivovat_organizatory.short_description = 'Deaktivovat organizátory'
@admin.register(Organizator)
class OrganizatorAdmin(admin.ModelAdmin):
class OrganizatorAdmin(VersionAdmin):
list_filter = ['organizuje_do_roku']
list_display = [jmeno_organizatora, je_organizator_aktivni,]
actions = [zaktivovat_organizatory, deaktivovat_organizatory,]

3
seminar/models.py

@ -630,6 +630,7 @@ class Soustredeni(SeminarModelBase):
return reverse('seminar_seznam_soustredeni')
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class Soustredeni_Ucastnici(models.Model):
@ -747,6 +748,7 @@ class Nastaveni(SingletonModel):
return False
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class Novinky(models.Model):
datum = models.DateField(auto_now_add=True)
@ -765,6 +767,7 @@ class Novinky(models.Model):
verbose_name_plural = 'Novinky'
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class Organizator(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, verbose_name='Osoba',

Loading…
Cancel
Save