1 from django.db import models
2 from django.utils.translation import ugettext_lazy as _
5 class ButtonGroup(models.Model):
6 name = models.CharField(max_length=32)
7 slug = models.SlugField()
8 position = models.IntegerField(default=0)
11 ordering = ('position', 'name',)
12 verbose_name, verbose_name_plural = _('button group'), _('button groups')
14 def __unicode__(self):
17 class Button(models.Model):
18 label = models.CharField(max_length=32)
19 slug = models.SlugField() #unused
22 params = models.TextField() # TODO: should be a JSON field
23 scriptlet = models.ForeignKey('Scriptlet')
26 key = models.CharField(blank=True, max_length=1)
27 tooltip = models.CharField(blank=True, max_length=120)
29 # Why the button is restricted to have the same position in each group ?
30 # position = models.IntegerField(default=0)
32 group = models.ManyToManyField(ButtonGroup)
36 verbose_name, verbose_name_plural = _('button'), _('buttons')
38 def __unicode__(self):
41 class Scriptlet(models.Model):
42 name = models.CharField(max_length=64, primary_key=True)
43 code = models.TextField()
45 # TODO: add this later and remap code property to this
46 # code_min = models.TextField()
48 def __unicode__(self):
49 return _(u'javascript')+u':'+self.name