5408db3b9e1c5c88ec3acb8757bb910bed6536f4
[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 [g.to_dict(with_buttons=True) for g in groups]
21             
22 class ScriptletsHandler(BaseHandler):
23     allowed_methods = ('GET',)
24
25     def read(self, request):
26         scriptlets = toolbar.models.Scriptlet.objects.all()
27
28         return direct_to_template(request, 'toolbar_api/scriptlets.js',
29             extra_context = {'scriptlets': scriptlets },
30             mimetype='text/javascript' )