it/itf/boxes/views.py

41 lines
1.1 KiB
Python
Raw Normal View History

2011-04-04 01:35:25 +00:00
# Create your views here.
from api.actions import actions
import ox
from ox.django.decorators import login_required_json
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
from models import Panel
2011-04-08 20:15:51 +00:00
import json
2011-04-04 01:35:25 +00:00
def getPage(request):
'''
returns displayed panels as displayed; hidden panels as hidden.
each panel is:
title
boxes:
type
title
default_model
etc
'''
2011-04-08 20:15:51 +00:00
# data = json.loads(request.POST['data'])
panels = _getPageData(request)
response = json_response({})
response['data'] = panels
response['status'] = {'code': 200}
return render_to_json_response(response)
actions.register(getPage)
def _getPageData(request):
2011-04-04 01:35:25 +00:00
data = json.loads(request.POST['data'])
displayedPanels = Panel.objects.filter(enabled=True).filter(displayed=True)
hiddenPanels = Panel.objects.filter(enabled=True).filter(displayed=False)
panels = {}
panels['displayed'] = []
for d in displayedPanels:
panels['displayed'].append(d.get_dict())
panels['hidden'] = []
for h in hiddenPanels:
panels['hidden'].append(h.get_dict())
2011-04-08 20:15:51 +00:00
return panels