Commit 8640274a authored by Gero Müller's avatar Gero Müller
Browse files

add guests to groups

(transplanted from ed5dc5b0dbcd63c0b014ed40d5f7e2300b17e030)
parent bd9c4f48
......@@ -12,7 +12,7 @@ from vispa.controller.bus import BusController
from vispa.controller.error import ErrorController
from vispa.controller.filesystem import FSController
from vispa.models.preference import VispaPreference, ExtensionPreference
from vispa.models.user import User
from vispa.models.user import User, Group
from vispa.models.workspace import Workspace
import cherrypy
import vispa
......@@ -197,6 +197,9 @@ class RootController(AbstractController):
raise cherrypy.HTTPError(403, "Guest login not allowed!")
db = cherrypy.request.db
user, password = User.guest_login(db)
for groupname in vispa.config("web", "guest_groups", []):
group = Group.get_or_create_by_name(db, groupname)
cherrypy.session["user_id"] = unicode(
cherrypy.session["user_name"] =
cherrypy.session["guest_password"] = password
......@@ -307,6 +307,16 @@ class Group(Base):
def get_by_name(session, name):
return session.query(Group).filter_by(name=name).first()
def get_or_create_by_name(session, name):
group = Group.get_by_name(session, name)
if group is None:
group = Group() = name
return group
def all(session):
return session.query(Group)
Markdown is supported
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