fix config
This commit is contained in:
parent
131fe30a58
commit
6a6ba425bb
3 changed files with 33 additions and 18 deletions
|
@ -23,14 +23,7 @@ class Page(models.Model):
|
|||
|
||||
RUN_RELOADER = True
|
||||
|
||||
def reloader_thread():
|
||||
_config_mtime = 0
|
||||
while RUN_RELOADER:
|
||||
stat = os.stat(settings.SITE_CONFIG)
|
||||
mtime = stat.st_mtime
|
||||
if _win:
|
||||
mtime -= stat.st_ctime
|
||||
if mtime > _config_mtime:
|
||||
def load_config():
|
||||
with open(settings.SITE_CONFIG) as f:
|
||||
config = json.load(f)
|
||||
|
||||
|
@ -44,8 +37,17 @@ def reloader_thread():
|
|||
config['keys'][key['id']] = key
|
||||
|
||||
settings.CONFIG = config
|
||||
|
||||
def reloader_thread():
|
||||
_config_mtime = 0
|
||||
while RUN_RELOADER:
|
||||
stat = os.stat(settings.SITE_CONFIG)
|
||||
mtime = stat.st_mtime
|
||||
if _win:
|
||||
mtime -= stat.st_ctime
|
||||
if mtime > _config_mtime:
|
||||
load_config()
|
||||
_config_mtime = mtime
|
||||
time.sleep(1)
|
||||
|
||||
thread.start_new_thread(reloader_thread, ())
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def parseCondition(condition):
|
|||
else:
|
||||
return q
|
||||
|
||||
key_type = settings.config['keys'].get(k, {'type':'string'}).get('type')
|
||||
key_type = settings.CONFIG['keys'].get(k, {'type':'string'}).get('type')
|
||||
if isinstance(key_type, list):
|
||||
key_type = key_type[0]
|
||||
key_type = {
|
||||
|
@ -247,11 +247,11 @@ class ItemManager(Manager):
|
|||
|
||||
#anonymous can only see public items
|
||||
if user.is_anonymous():
|
||||
allowed_level = settings.config['capabilities']['canSeeItem']['guest']
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
qs = qs.filter(level__lte=allowed_level)
|
||||
#users can see public items, there own items and items of there groups
|
||||
else:
|
||||
allowed_level = settings.config['capabilities']['canSeeItem'][user.get_profile().get_level()]
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()]
|
||||
qs = qs.filter(Q(level__lte=allowed_level)|Q(user=user)|Q(groups__in=user.groups.all()))
|
||||
#admins can see all available items
|
||||
return qs
|
||||
|
|
|
@ -120,9 +120,9 @@ INSTALLED_APPS = (
|
|||
'devserver',
|
||||
# 'south',
|
||||
'djcelery',
|
||||
'app',
|
||||
|
||||
'annotation',
|
||||
'app',
|
||||
'archive',
|
||||
'event',
|
||||
'item',
|
||||
|
@ -245,3 +245,16 @@ except NameError:
|
|||
except IOError:
|
||||
Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE)
|
||||
|
||||
from ox.utils import json
|
||||
with open(SITE_CONFIG) as f:
|
||||
CONFIG = json.load(f)
|
||||
|
||||
CONFIG['site']['id'] = SITEID
|
||||
CONFIG['site']['name'] = SITENAME
|
||||
CONFIG['site']['sectionName'] = SITENAME
|
||||
CONFIG['site']['url'] = URL
|
||||
|
||||
CONFIG['keys'] = {}
|
||||
for key in CONFIG['itemKeys']:
|
||||
CONFIG['keys'][key['id']] = key
|
||||
|
||||
|
|
Loading…
Reference in a new issue