Dołączenie skryptu /api/toolbar/scriptlets do editor.html.
[redakcja.git] / apps / api / handlers / toolbar_handlers.py
1 # -*- encoding: utf-8 -*-
2
3 __author__= "Łukasz Rekucki"
4 __date__ = "$2009-09-25 15:55:33$"
5 __doc__ = "Module documentation."
6
7 from django.views.generic.simple import direct_to_template
8 from piston.handler import BaseHandler
9 from piston.utils import rc
10
11 import settings
12
13 import toolbar.models
14
15 class ToolbarHandler(BaseHandler):
16     allowed_methods = ('GET',)
17
18     def read(self, request):
19         groups = toolbar.models.ButtonGroup.objects.all()
20         return [ {'name': g.name, 'position': g.position,\
21             'buttons': g.button_set.all()} for g in groups ]
22             
23             
24 class ScriptletsHandler(BaseHandler):
25     allowed_methods = ('GET',)
26
27     def read(self, request):
28         scriptlets = toolbar.models.Scriptlet.objects.all()
29
30         return direct_to_template(request, 'toolbar_api/scriptlets.js',
31             extra_context = {'scriptlets': scriptlets },
32             mimetype='text/javascript' )