forked from 0x2620/pandora
do not chach site.json
This commit is contained in:
parent
38bfbe50aa
commit
6f0d76b5c5
7 changed files with 24 additions and 41 deletions
|
@ -23,9 +23,10 @@ class SiteSettings(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.key
|
||||
|
||||
with open(os.path.join(settings.PROJECT_ROOT, 'templates', 'site.json')) as f:
|
||||
def site_config():
|
||||
with open(os.path.join(settings.PROJECT_ROOT, 'templates', 'site.json')) as f:
|
||||
site_config = json.load(f)
|
||||
site_config['keys'] = {}
|
||||
for key in site_config['sortKeys']:
|
||||
site_config['keys'][key['id']] = key
|
||||
|
||||
return site_config
|
||||
|
|
|
@ -34,7 +34,7 @@ def parseCondition(condition):
|
|||
else:
|
||||
exclude = False
|
||||
|
||||
key_type = models.site_config['keys'].get(k, {'type':'string'}).get('type')
|
||||
key_type = models.site_config()['keys'].get(k, {'type':'string'}).get('type')
|
||||
key_type = {
|
||||
'title': 'string',
|
||||
'person': 'string',
|
||||
|
|
|
@ -304,7 +304,7 @@ class Item(models.Model):
|
|||
}
|
||||
item.update(self.external_data)
|
||||
item.update(self.data)
|
||||
for key in site_config['keys'].keys():
|
||||
for key in site_config()['keys'].keys():
|
||||
if key not in item:
|
||||
value = self.get(key)
|
||||
#also get values from sort table, i.e. numberof values
|
||||
|
@ -416,7 +416,7 @@ class Item(models.Model):
|
|||
'modified',
|
||||
'popularity'
|
||||
)
|
||||
for key in site_config['sortKeys']:
|
||||
for key in site_config()['sortKeys']:
|
||||
name = key['id']
|
||||
source = key.get('key', name)
|
||||
field_type = key['type']
|
||||
|
@ -763,11 +763,12 @@ class Item(models.Model):
|
|||
|
||||
Item.facet_keys = []
|
||||
Item.person_keys = []
|
||||
for key in site_config['findKeys']:
|
||||
config = site_config()
|
||||
for key in config['findKeys']:
|
||||
name = key['id']
|
||||
if key.get('autocomplete', False) and not site_config['keys'].get(name, {'type': None})['type'] == 'title':
|
||||
if key.get('autocomplete', False) and not config['keys'].get(name, {'type': None})['type'] == 'title':
|
||||
Item.facet_keys.append(name)
|
||||
if name in site_config['keys'] and site_config['keys'][name]['type'] == 'person':
|
||||
if name in config['keys'] and config['keys'][name]['type'] == 'person':
|
||||
Item.person_keys.append(name)
|
||||
|
||||
class ItemFind(models.Model):
|
||||
|
@ -792,7 +793,7 @@ attrs = {
|
|||
'__module__': 'item.models',
|
||||
'item': models.OneToOneField('Item', related_name='sort', primary_key=True),
|
||||
}
|
||||
for key in site_config['sortKeys']:
|
||||
for key in config['sortKeys']:
|
||||
name = key['id']
|
||||
name = {'id': 'itemId'}.get(name, name)
|
||||
field_type = key['type']
|
||||
|
|
|
@ -238,7 +238,8 @@ def autocomplete(request):
|
|||
data['range'] = [0, 10]
|
||||
op = data.get('operator', '')
|
||||
|
||||
if models.site_config['keys'][data['key']]['type'] == 'title':
|
||||
site_config = models.site_config()
|
||||
if site_config['keys'][data['key']]['type'] == 'title':
|
||||
qs = models.Item.objects.filter(available=True) #does this need more limiting? user etc
|
||||
if data['value']:
|
||||
if op == '':
|
||||
|
@ -247,7 +248,7 @@ def autocomplete(request):
|
|||
qs = qs.filter(find__key=data['key'], find__value__istartswith=data['value'])
|
||||
elif op == '$':
|
||||
qs = qs.filter(find__key=data['key'], find__value__iendswith=data['value'])
|
||||
qs = qs.order_by('-sort__%s'%models.site_config['keys'][data['key']]['autocompleteSortKey'])
|
||||
qs = qs.order_by('-sort__%s'%site_config['keys'][data['key']]['autocompleteSortKey'])
|
||||
qs = qs[data['range'][0]:data['range'][1]]
|
||||
response = json_response({})
|
||||
response['data']['items'] = [i.get(data['key']) for i in qs]
|
||||
|
|
|
@ -31,11 +31,12 @@ class UserProfile(models.Model):
|
|||
|
||||
def get_ui(self):
|
||||
ui = {}
|
||||
ui.update(site_config['user']['ui'])
|
||||
config = site_config()
|
||||
ui.update(config['user']['ui'])
|
||||
ui.update(self.ui)
|
||||
if not 'lists' in ui:
|
||||
ui['lists'] = {}
|
||||
ui['lists'][''] = site_config['uiDefaults']['list']
|
||||
ui['lists'][''] = config['uiDefaults']['list']
|
||||
|
||||
def add(lists, section):
|
||||
ids = []
|
||||
|
|
|
@ -101,7 +101,7 @@ def signout(request):
|
|||
response = json_response(text='logged out')
|
||||
logout(request)
|
||||
|
||||
response['data']['user'] = site_config['user']
|
||||
response['data']['user'] = site_config()['user']
|
||||
return render_to_json_response(response)
|
||||
actions.register(signout, cache=False)
|
||||
|
||||
|
|
|
@ -35,27 +35,6 @@ var pandora = new Ox.App({
|
|||
$.browser.safari && Ox.theme('modern');
|
||||
}
|
||||
|
||||
// fixme: remove
|
||||
app.uiDefaults = {
|
||||
"list": {
|
||||
"columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"],
|
||||
"listView": "icons",
|
||||
"selected": [],
|
||||
"sort": [
|
||||
{"key": "director", "operator": ""}
|
||||
]
|
||||
}
|
||||
}
|
||||
// fixme: remove
|
||||
app.user.ui.showSection = {
|
||||
"my": true,
|
||||
"public": true,
|
||||
"featured": true
|
||||
}
|
||||
|
||||
// $.each(pandora.afterLaunch, function(i, f) { f(); });
|
||||
|
||||
|
||||
function load() {
|
||||
|
||||
$(function() {
|
||||
|
@ -2623,7 +2602,7 @@ var pandora = new Ox.App({
|
|||
type: data.id == 'new' ? 'static' : 'smart'
|
||||
}, function(result) {
|
||||
id = result.data.id;
|
||||
app.user.ui.lists[id] = app.uiDefaults.list;
|
||||
app.user.ui.lists[id] = app.config.uiDefaults.list;
|
||||
URL.set('?find=list:' + id)
|
||||
Ox.Request.emptyCache(); // fixme: remove
|
||||
$list.reloadList().bindEvent({load: load});
|
||||
|
@ -3031,7 +3010,7 @@ var pandora = new Ox.App({
|
|||
$list.resizeColumn(i == 1 ? 'id' : 'name', width - 88);
|
||||
}
|
||||
if (!app.user.ui.showSection[id]) {
|
||||
//app.$ui.section[i].update();
|
||||
app.$ui.section[i].update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue