Skip to content
Snippets Groups Projects
Commit dacd156e authored by Kevin S. Hahn's avatar Kevin S. Hahn
Browse files

add sensible defaults to various stuffs

parent d6f783a5
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ ap.add_argument('--data_path', help='path to storage area', required=True)
ap.add_argument('--ssl_cert', help='path to SSL certificate file, containing private key and certificate chain', required=True)
ap.add_argument('--api_uri', help='api uri, with https:// prefix')
ap.add_argument('--site_id', help='site ID for Scitran Central [local]', default='local')
ap.add_argument('--site_name', help='site name', nargs='+') # hack for uwsgi --pyargv
ap.add_argument('--site_name', help='site name', nargs='*', default=['Local']) # hack for uwsgi --pyargv
ap.add_argument('--oauth2_id_endpoint', help='OAuth2 provider ID endpoint', default='https://www.googleapis.com/plus/v1/people/me/openIdConnect')
ap.add_argument('--demo', help='enable automatic user creation', action='store_true', default=False)
ap.add_argument('--insecure', help='allow user info as urlencoded param', action='store_true', default=False)
......@@ -30,7 +30,7 @@ args = ap.parse_args()
# HACK to allow setting the --site_name in the same way as api.py
# --site_name 'Example Site' or --site_name "Example Site"
args.site_name = ' '.join(args.site_name).strip('"\'') if args.site_name else args.site_name
args.site_name = ' '.join(args.site_name).strip('"\'')
args.quarantine_path = os.path.join(args.data_path, 'quarantine')
logging.basicConfig(level=getattr(logging, args.log_level.upper())) #FIXME probably not necessary, because done in api.py
......@@ -61,7 +61,7 @@ else:
raise Exception('Could not connect to MongoDB')
# TODO: make api_uri a required arg?
application.db.sites.update({'_id': args.site_id}, {'_id': args.site_id, 'name': args.site_name or 'Local', 'api_uri': args.api_uri, 'onload': True}, upsert=True)
application.db.sites.update({'_id': args.site_id}, {'_id': args.site_id, 'name': args.site_name, 'api_uri': args.api_uri}, upsert=True)
if not args.ssl_cert:
log.warning('SSL certificate not specified, Scitran Central functionality disabled')
......
......@@ -185,13 +185,18 @@ class Core(base.RequestHandler):
def sites(self):
"""Return local and remote sites."""
if self.app.config['site_id'] == 'local':
return [self.app.db.sites.find_one({'_id': 'local'}, {'_id': 1, 'name': 1, 'onload': 1})]
projection = ['name', 'onload']
# TODO onload for local is true
if self.public_request or self.request.get('all').lower() in ('1', 'true'):
sites = list(self.app.db.sites.find(None, ['name']))
sites = list(self.app.db.sites.find(None, projection))
else:
# TODO onload based on user prefs
remote_ids = (self.app.db.users.find_one({'_id': self.uid}, ['remotes']) or {}).get('remotes', []) + [self.app.config['site_id']]
sites = list(self.app.db.sites.find({'_id': {'$in': remote_ids}}, ['name']))
sites = list(self.app.db.sites.find({'_id': {'$in': remote_ids}}, projection))
for s in sites: # TODO: this for loop will eventually move to public case
if s['_id'] == self.app.config['site_id']:
s['onload'] = True
break
return sites
search_schema = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment