Dodanie inclusion taga {% toolbar %} wstawiajÄ…cego toolbar z ustawieniami z interfejs...
authorzuber <marek@stepniowski.com>
Wed, 19 Aug 2009 14:20:24 +0000 (16:20 +0200)
committerzuber <marek@stepniowski.com>
Wed, 19 Aug 2009 14:20:24 +0000 (16:20 +0200)
apps/toolbar/models.py
apps/toolbar/templates/toolbar/toolbar.html [new file with mode: 0644]
apps/toolbar/templatetags/toolbar_tags.py

index ad4752a..8e2387d 100644 (file)
@@ -8,7 +8,7 @@ class ButtonGroup(models.Model):
     position = models.IntegerField(default=0)
     
     class Meta:
-        ordering = ['name']
+        ordering = ('position', 'name',)
         verbose_name, verbose_name_plural = _('button group'), _('button groups')
     
     def __unicode__(self):
@@ -25,8 +25,9 @@ class Button(models.Model):
     group = models.ManyToManyField(ButtonGroup)
     
     class Meta:
-        ordering = ['label']
+        ordering = ('position', 'label',)
         verbose_name, verbose_name_plural = _('button'), _('buttons')
     
     def __unicode__(self):
         return self.label
+
diff --git a/apps/toolbar/templates/toolbar/toolbar.html b/apps/toolbar/templates/toolbar/toolbar.html
new file mode 100644 (file)
index 0000000..2e61288
--- /dev/null
@@ -0,0 +1,18 @@
+<div id="toolbar">
+    <ol id="toolbar-tabs">
+        {% for group in groups %}
+        <li p:button-list="{{ group.slug }}">{{ group.name }}</li>
+        {% endfor %}
+    </ol>
+    <div style="clear: both; height: 0; width: 0">&nbsp;</div>
+    <div id="toolbar-buttons">
+        {% for group in groups %}
+        <ol id="{{ group.slug }}" style="display:none">
+            {% for button in group.button_set.all %}
+            <li p:tag="{{ button.slug }}" {% if button.key %}p:key="{{ button.key }}"{% endif %}>{{ button.label }}</li>
+            {% endfor %}
+        </ol>
+        {% endfor %}
+        <div style="clear: both; height: 0; width: 0">&nbsp;</div>
+    </div>
+</div>
\ No newline at end of file
index e69de29..69b5b38 100644 (file)
@@ -0,0 +1,13 @@
+from django import template
+
+from toolbar import models
+
+
+register = template.Library()
+
+
+@register.inclusion_tag('toolbar/toolbar.html')
+def toolbar():
+    groups = models.ButtonGroup.objects.all()
+    return {'groups': groups}
+