1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django.contrib import admin
5 from django.utils.translation import ugettext_lazy as _
6 from django import forms
9 from toolbar import models
12 class ButtonAdminForm(forms.ModelForm):
17 def clean_params(self):
18 value = self.cleaned_data['params']
20 return json.dumps(json.loads(value))
21 except ValueError as e:
22 raise forms.ValidationError(e)
25 class ButtonAdmin(admin.ModelAdmin):
26 form = ButtonAdminForm
27 list_display = ('slug', 'label', 'tooltip', 'accesskey')
28 list_display_links = ('slug',)
29 list_editable = ('label', 'tooltip', 'accesskey')
30 prepopulated_fields = {'slug': ('label',)}
32 admin.site.register(models.Button, ButtonAdmin)
33 admin.site.register(models.ButtonGroup)
34 admin.site.register(models.Scriptlet)