1 from django.contrib import admin
2 from django.utils.translation import ugettext_lazy as _
3 from django import forms
6 from toolbar import models
9 class ButtonAdminForm(forms.ModelForm):
14 def clean_params(self):
15 value = self.cleaned_data['params']
17 return json.dumps(json.loads(value))
18 except ValueError as e:
19 raise forms.ValidationError(e)
22 class ButtonAdmin(admin.ModelAdmin):
23 form = ButtonAdminForm
24 list_display = ('slug', 'label', 'tooltip', 'accesskey')
25 list_display_links = ('slug',)
26 list_editable = ('label', 'tooltip', 'accesskey')
27 prepopulated_fields = {'slug': ('label',)}
29 admin.site.register(models.Button, ButtonAdmin)
30 admin.site.register(models.ButtonGroup)
31 admin.site.register(models.Scriptlet)