--- /dev/null
+from django.contrib import admin
+from django.utils.translation import ugettext_lazy as _
+
+from toolbar import models
+
+
+class ButtonGroupAdmin(admin.ModelAdmin):
+ list_display = ('name', 'slug', 'position',)
+ search_fields = ('name', 'slug',)
+ prepopulated_fields = {'slug': ('name',)}
+ list_editable = ('position',)
+
+admin.site.register(models.ButtonGroup, ButtonGroupAdmin)
+
+
+class ButtonAdmin(admin.ModelAdmin):
+ list_display = ('label', 'slug', 'tag', 'key', 'position',)
+ list_filter = ('group',)
+ search_fields = ('label', 'slug', 'tag', 'key',)
+ prepopulated_fields = {'slug': ('label',)}
+ filter_horizontal = ('group',)
+ list_editable = ('position',)
+
+admin.site.register(models.Button, ButtonAdmin)
+
--- /dev/null
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+
+class ButtonGroup(models.Model):
+ name = models.CharField(max_length=32)
+ slug = models.SlugField()
+ position = models.IntegerField(default=0)
+
+ class Meta:
+ ordering = ['name']
+ verbose_name, verbose_name_plural = _('button group'), _('button groups')
+
+ def __unicode__(self):
+ return self.name
+
+
+class Button(models.Model):
+ label = models.CharField(max_length=32)
+ slug = models.SlugField()
+ tag = models.CharField(max_length=128)
+ key = models.IntegerField(blank=True, null=True)
+ position = models.IntegerField(default=0)
+
+ group = models.ManyToManyField(ButtonGroup)
+
+ class Meta:
+ ordering = ['label']
+ verbose_name, verbose_name_plural = _('button'), _('buttons')
+
+ def __unicode__(self):
+ return self.label