cablegates/pandora/text/views.py

90 lines
2 KiB
Python
Raw Normal View History

2010-11-23 10:30:03 +00:00
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
from ox.utils import json
from ox.django.decorators import login_required_json
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
import models
from api.actions import actions
2010-11-23 10:30:03 +00:00
2011-01-01 11:44:42 +00:00
def getNews(request):
2010-11-23 10:30:03 +00:00
'''
param data
string id
return page
'''
response = json_response({})
itemId = json.loads(request.POST['data'])
item = get_object_or_404_json(models.News, pk=itemId)
response['data']['page'] = item.html()
return render_to_json_response(response)
actions.register(getNews)
2010-11-23 10:30:03 +00:00
2011-01-01 11:44:42 +00:00
@login_required_json
def editNews(request):
'''
param data
string id
return page
'''
response = json_response({})
itemId = json.loads(request.POST['data'])
item = get_object_or_404_json(models.Text, pk=itemId)
response['data']['page'] = item.html()
return render_to_json_response(response)
2011-01-13 08:33:14 +00:00
actions.register(editNews, cache=False)
2011-01-01 11:44:42 +00:00
def findNews(request):
2010-11-23 10:30:03 +00:00
'''
'''
response = json_response({})
return render_to_json_response(response)
actions.register(findNews)
2010-11-23 10:30:03 +00:00
2011-01-01 11:44:42 +00:00
def getText(request):
2010-11-23 10:30:03 +00:00
'''
param data
string id
return page
'''
response = json_response({})
itemId = json.loads(request.POST['data'])
item = get_object_or_404_json(models.Text, pk=itemId)
response['data']['page'] = item.html()
return render_to_json_response(response)
actions.register(getText)
2010-11-23 10:30:03 +00:00
2011-01-01 11:44:42 +00:00
@login_required_json
def editText(request):
'''
param data
string id
return page
'''
response = json_response({})
itemId = json.loads(request.POST['data'])
item = get_object_or_404_json(models.Text, pk=itemId)
response['data']['page'] = item.html()
return render_to_json_response(response)
2011-01-13 08:33:14 +00:00
actions.register(editText, cache=False)
2011-01-01 11:44:42 +00:00
def findText(request):
2010-11-23 10:30:03 +00:00
'''
'''
response = json_response({})
return render_to_json_response(response)
actions.register(findText)