Commit 21f95d22 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Fix permissions for workspace changing, fix #1599.

parent af51faa5
[database]
#sqlalchemy_url = sqlite:////var/db/vispa.db
#sqlalchemy.url = sqlite:////var/db/vispa.db
[alembic]
# inplace installation
......@@ -17,14 +17,14 @@ dev_mode = True
#base_dynamic = /vispa
#base_static = http://localhost:8080/
# logging on client side (only in devmode)
client_log_level = all
client_log_ignore = []
# logging on client side
logging.level = all
logging.ignore = []
welcome_phrase = Welcome to VISPA!
#login_text = Information for Login
#registration_text = Information for Registration
#forgot_text = Check your spam folder and uncheck no-reply@vispa.physik.rwth-aachen.de
text.welcome = Welcome to VISPA!
#text.login = Information for Login
#text.registration = Information for Registration
#text.forgot = Check your spam folder and uncheck no-reply@vispa.physik.rwth-aachen.de
use_forgot = False
[websockets]
......@@ -49,7 +49,9 @@ manager = local
#default_workspace_id = 1
[user]
change_workspaces = True
workspaces.add = True
workspaces.alter = True
# user registration
# use $username and $userid variables
#registration.hook = ['useradd', '$username']
......
......@@ -58,7 +58,10 @@ class AjaxController(AbstractController):
@cherrypy.tools.user(on=False)
@cherrypy.tools.ajax()
def forgotpassword(self, username):
User.forgot_password(cherrypy.request.db, username)
if vispa.config("web", "use_forgot", False):
User.forgot_password(cherrypy.request.db, username)
else:
raise MessageException("Password restoring not allowed!")
@cherrypy.expose
@cherrypy.tools.user(on=False)
......@@ -106,7 +109,7 @@ class AjaxController(AbstractController):
@cherrypy.expose
@cherrypy.tools.ajax()
def addworkspace(self, name, host, login, port=None, key=None, cmd=None):
if not vispa.config("user", "change_workspaces", True):
if not vispa.config("user", "workspaces.add", True):
raise MessageException("No permission to add a new Workspace!")
db = self.get("db")
user_id = self.get("user_id")
......@@ -126,7 +129,7 @@ class AjaxController(AbstractController):
@cherrypy.expose
@cherrypy.tools.ajax()
def deleteworkspace(self, wid):
if not vispa.config("user", "change_workspaces", True):
if not vispa.config("user", "workspaces.add", True):
raise MessageException("No permission to delete a Workspace!")
db = cherrypy.request.db
# is workspace owned by the user?
......
......@@ -103,12 +103,13 @@ class RootController(AbstractController):
dev_mode = vispa.config("web", "dev_mode", True)
use_websockets = vispa.config("websockets", "enabled", False)
preferences = self.get_preferences(db, cherrypy.request.user.id, parse_json=True)
client_log_level = vispa.config("web", "client_log_level", "info")
client_log_level = vispa.config("web", "logging.level", "info")
workspace_ids = self.convert(self.get("workspace_ids"), int)
workspace_ids = JSON.dumps(workspace_ids)
workspace_data = self.workspace_data()
workspace_data = JSON.dumps(workspace_data)
change_workspaces = vispa.config("user", "change_workspaces", True)
add_workspaces = vispa.config("user", "workspaces.add", True)
alter_workspaces = vispa.config("user", "workspaces.alter", True)
data = {
"dev_mode" : dev_mode,
"username" : username,
......@@ -117,7 +118,8 @@ class RootController(AbstractController):
"use_websockets" : use_websockets,
"workspace_ids" : workspace_ids,
"workspace_data" : workspace_data,
"change_workspaces": change_workspaces,
"add_workspaces" : add_workspaces,
"alter_workspaces" : alter_workspaces,
"log_level" : client_log_level,
}
data.update(preferences)
......@@ -129,10 +131,10 @@ class RootController(AbstractController):
@cherrypy.tools.render(template="sites/login.mako")
def login(self, *args, **kwargs):
path = self.requested_path()
welcome_phrase = vispa.config("web", "welcome_phrase", "")
login_text = vispa.config("web", "login_text", "")
registration_text = vispa.config("web", "registration_text", "")
forgot_text = vispa.config("web", "forgot_text", "")
welcome_phrase = vispa.config("web", "text.welcome", "")
login_text = vispa.config("web", "text.login", "")
registration_text = vispa.config("web", "text.registration", "")
forgot_text = vispa.config("web", "text.forgot", "")
use_forgot = vispa.config("web", "use_forgot", False)
return {
"requested_path" : path,
......
......@@ -229,8 +229,8 @@ class Server(object):
cherrypy.log.screen = False
def __init_database(self, args):
sa_identifier = vispa.config('database', 'sqlalchemy_url',
'sqlite:///%s/vispa.db' % self.var_dir)
sa_identifier = vispa.config('database', 'sqlalchemy.url',
'sqlite:///%s/vispa.db' % self.var_dir)
logger.info('Use database %s.' % sa_identifier)
self._engine = sqlalchemy.create_engine(sa_identifier, echo=False)
......@@ -252,7 +252,7 @@ class Server(object):
vispa.plugins.template.MakoPlugin(cherrypy.engine,
base_dir=mako_lookup_dir,
module_dir=self.cache_dir
).subscribe()
).subscribe()
def __init_tools(self, args):
from vispa.tools.template import MakoTool
......
......@@ -172,11 +172,12 @@ var Vispa = Emitter.extend({
this.workspaces.on("disconnectedWorkspace", toggleIcons);
// apply vispaUser.changeWorkspaces
if (!window.vispaUser.changeWorkspaces) {
if (!window.vispaUser.addWorkspaces)
$("#ws-menu-entry-add-ws").remove();
if (!window.vispaUser.alterWorkspaces)
$("#ws-menu-entry-conf-ws").remove();
if (!window.vispaUser.addWorkspaces && !window.vispaUser.alterWorkspaces)
$("#ws-menu-entry-divide-ws").remove();
}
this.connectEvents();
......
......@@ -85,16 +85,15 @@
var vispa = extensionClasses;
$(function() {
% if dev_mode:
$.Logger().enable().level("${log_level}");
% endif
$.Logger().enable().level("${log_level}");
jQuery.fn.render = Transparency.jQueryPlugin;
// store user data
window.vispaUser = {
name: "${username}",
changeWorkspaces: ${"true" if change_workspaces else "false"}
addWorkspaces: ${"true" if add_workspaces else "false"},
alterWorkspaces: ${"true" if alter_workspaces else "false"}
};
// use template variables to create the vispa config
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment