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