1 from django.contrib import admin
2 from django.utils.translation import ugettext_lazy as _
3 from django import forms
4 from django.utils import simplejson as json
6 from toolbar import models
8 #class ButtonGroupAdmin(admin.ModelAdmin):
9 # list_display = ('name', 'slug', 'position',)
10 # search_fields = ('name', 'slug',)
11 # prepopulated_fields = {'slug': ('name',)}
12 # list_editable = ('position',)
15 class ButtonAdminForm(forms.ModelForm):
18 def clean_params(self):
19 value = self.cleaned_data['params']
21 return json.dumps(json.loads(value))
23 raise forms.ValidationError(e)
25 class ButtonAdmin(admin.ModelAdmin):
26 form = ButtonAdminForm
27 list_display = ('label', 'scriptlet', 'key', 'params')
28 prepopulated_fields = {'slug': ('label',)}
30 admin.site.register(models.Button, ButtonAdmin)
31 admin.site.register(models.ButtonGroup)
32 admin.site.register(models.Scriptlet)
34 #class ButtonAdmin(admin.ModelAdmin):
35 # list_display = ('label', 'action', 'key', 'position',)
36 # list_filter = ('group',)
37 # search_fields = ('label', 'action', 'key',)
38 # filter_horizontal = ('group',)
39 # list_editable = ('position',)