use init request instead of config

This commit is contained in:
j 2011-01-23 00:59:56 +05:30
parent 77e9b0cf90
commit 25629ac491
3 changed files with 13 additions and 5 deletions

View file

@ -2,11 +2,14 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import os
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.template import RequestContext from django.template import RequestContext
from django.conf import settings from django.conf import settings
from ox.django.shortcuts import render_to_json_response, json_response from ox.django.shortcuts import render_to_json_response, json_response
from ox.utils import json
from pandora.user.models import get_user_json from pandora.user.models import get_user_json
@ -42,7 +45,7 @@ def api(request):
return response return response
def hello(request): def init(request):
''' '''
return {'status': {'code': int, 'text': string}, return {'status': {'code': int, 'text': string},
'data': {user: object}} 'data': {user: object}}
@ -55,8 +58,14 @@ def hello(request):
response['data']['user'] = {'name': 'Guest', response['data']['user'] = {'name': 'Guest',
'group': 'guest', 'group': 'guest',
'preferences': {}} 'preferences': {}}
with open(os.path.join(settings.PROJECT_ROOT, 'templates', 'site.json')) as f:
response['data']['config'] = json.load(f)
response['data']['config']['site']['id'] = settings.SITEID
response['data']['config']['site']['name'] = settings.SITENAME
response['data']['config']['site']['sectionName'] = settings.SITENAME
response['data']['config']['site']['url'] = settings.URL
return render_to_json_response(response) return render_to_json_response(response)
actions.register(hello) actions.register(init)
def error(request): def error(request):

View file

@ -4,8 +4,7 @@
var app = new Ox.App({ var app = new Ox.App({
apiURL: '/api/', apiURL: '/api/',
config: '/site.json', init: 'init',
init: 'hello',
}).launch(function(data) { }).launch(function(data) {
Ox.print('data', data) Ox.print('data', data)
app.config = data.config; app.config = data.config;

View file

@ -5,7 +5,7 @@
var pandora = new Ox.App({ var pandora = new Ox.App({
apiURL: '/api/', apiURL: '/api/',
config: '/site.json', config: '/site.json',
init: 'hello', init: 'init',
}).launch(function(data) { }).launch(function(data) {
//Ox.print('data', data); //Ox.print('data', data);