summaryrefslogtreecommitdiff
path: root/gstudio/admin/complement.py
blob: 6cff0887f8d1253e68967eb5a228d6fac5794fd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from django.contrib import admin
from django.core.urlresolvers import NoReverseMatch
from django.utils.translation import ugettext_lazy as _

from django.template.defaultfilters import slugify
from gstudio.admin.forms import ComplementAdminForm
import reversion
from gstudio.settings import GSTUDIO_VERSIONING
if GSTUDIO_VERSIONING == True:
    parent_class = reversion.VersionAdmin
else:
    parent_class = admin.ModelAdmin 

class ComplementAdmin(parent_class):
    fieldsets=((_('Complement'),{'fields':('title','nodetypes','metatypes','slug')}),)
    
    def save_model(self, request, complement, form, change):
        #complement.title=self.composed_subject
        complement.slug=slugify(complement.title)
        complement.save()