root / txapp / response.py @ 8:92f04bf7349c
History | View | Annotate | Download (749 Bytes)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
|
3 |
from django.utils import simplejson as json |
4 |
from django.template.response import TemplateResponse |
5 |
|
6 |
|
7 |
class TxTemplateResponse(TemplateResponse): |
8 |
"""Transifex specific response class."""
|
9 |
|
10 |
@property
|
11 |
def rendered_content(self): |
12 |
"""
|
13 |
Render the content.
|
14 |
|
15 |
Convert the content to a suitable json-encoded string to send to
|
16 |
Transifex.
|
17 |
"""
|
18 |
content = super(TxTemplateResponse, self).rendered_content |
19 |
return self._convert_to_json(content) |
20 |
|
21 |
def _convert_to_json(self, content): |
22 |
"""Convert the content to a json-encoded string along
|
23 |
with any other information necessary.
|
24 |
"""
|
25 |
data = {'content': content}
|
26 |
return json.dumps(data)
|