merging changes
This commit is contained in:
commit
3c03d4fd68
5 changed files with 43 additions and 20 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
|
||||
|
|
|
@ -128,7 +128,8 @@ class Item(models.Model):
|
|||
|
||||
#while metadata is updated, files are set to rendered=False
|
||||
rendered = models.BooleanField(default=False, db_index=True)
|
||||
level = models.IntegerField(default=False, db_index=True)
|
||||
#should be set based on user
|
||||
level = models.IntegerField(default=4, db_index=True)
|
||||
|
||||
itemId = models.CharField(max_length=128, unique=True, blank=True)
|
||||
oxdbId = models.CharField(max_length=42, unique=True, blank=True, null=True)
|
||||
|
@ -162,7 +163,11 @@ class Item(models.Model):
|
|||
return default
|
||||
|
||||
def access(self, user):
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()]
|
||||
if user.is_anonymous():
|
||||
level = 'guest'
|
||||
else:
|
||||
level = user.get_profile().get_level()
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem'][level]
|
||||
if self.level < allowed_level:
|
||||
return True
|
||||
elif user.is_authenticated() and \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ from ox.django.http import HttpFileResponse
|
|||
|
||||
from django.conf import settings
|
||||
|
||||
#gunicorn has issues with settings.CONFIG otherwise
|
||||
import app.models
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
|
Loading…
Reference in a new issue