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
9 class ButtonAdminForm(forms.ModelForm):
13 def clean_params(self):
14 value = self.cleaned_data['params']
16 return json.dumps(json.loads(value))
18 raise forms.ValidationError(e)
21 class ButtonAdmin(admin.ModelAdmin):
22 form = ButtonAdminForm
23 list_display = ('slug', 'label', 'tooltip', 'accesskey')
24 list_display_links = ('slug',)
25 list_editable = ('label', 'tooltip', 'accesskey')
26 prepopulated_fields = {'slug': ('label',)}
28 admin.site.register(models.Button, ButtonAdmin)
29 admin.site.register(models.ButtonGroup)
30 admin.site.register(models.Scriptlet)