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(unique=True) #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)
31 group = models.ManyToManyField(ButtonGroup)
35 verbose_name, verbose_name_plural = _('button'), _('buttons')
37 def __unicode__(self):
40 class Scriptlet(models.Model):
41 name = models.CharField(max_length=64, primary_key=True)
42 code = models.TextField()
44 # TODO: add this later and remap code property to this
45 # code_min = models.TextField()
47 def __unicode__(self):
48 return _(u'javascript')+u':'+self.name