summaryrefslogtreecommitdiff
path: root/gstudio/admin/attribute_urlfield.py
blob: 6f773819e444b5c29d8444cd14a2d98d929143cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 AttributeURLFieldAdminForm
import reversion
from gstudio.settings import GSTUDIO_VERSIONING
if GSTUDIO_VERSIONING == True:
    parent_class = reversion.VersionAdmin
else:
    parent_class = admin.ModelAdmin 

class AttributeURLFieldAdmin(parent_class):
    fieldsets=((_('AttributeURLField'),{'fields': ('attributetype','attributetype_scope','subject','subject_scope','svalue','value_scope','value')}),

)
    prepopulated_fields = {'svalue': ('value', )}
    def save_model(self, request, attributeurlfield, form, change):
    	attributeurlfield.title = attributeurlfield.composed_sentence
        attributeurlfield.slug =   slugify(attributeurlfield.title)
        attributeurlfield.save()