Beispiel #1
0
def create_alembic_config(silence = False):
    if silence:
        alembic_config = Config("alembic_test.ini")
    else:
        alembic_config = Config("alembic.ini")
    alembic_config.set_main_option("script_location", os.path.abspath(data_filename('alembic')))
    alembic_config.set_main_option("url", app.config['SQLALCHEMY_DATABASE_URI'])
    alembic_config.set_main_option("sqlalchemy.url", app.config['SQLALCHEMY_DATABASE_URI'])
    return alembic_config
Beispiel #2
0
def create_alembic_config(silence = False):
    if silence:
        alembic_config = Config("alembic_test.ini")
    else:
        alembic_config = Config("alembic.ini")
    alembic_config.set_main_option("script_location", os.path.abspath(data_filename('alembic')))
    alembic_config.set_main_option("url", app.config['SQLALCHEMY_DATABASE_URI'])
    alembic_config.set_main_option("sqlalchemy.url", app.config['SQLALCHEMY_DATABASE_URI'])
    return alembic_config
Beispiel #3
0
from flask.ext.admin.contrib.sqlamodel import ModelView

from labmanager import ALGORITHM
from labmanager.babel import gettext, lazy_gettext
from labmanager.models import LabManagerUser, LtUser
from labmanager.models import PermissionToCourse, RLMS, Laboratory, PermissionToLt, RequestPermissionLT
from labmanager.models import BasicHttpCredentials, LearningTool, Course, PermissionToLtUser, ShindigCredentials, EmbedApplication, EmbedApplicationTranslation, GoLabOAuthUser
from labmanager.rlms import get_form_class, get_supported_types, get_supported_versions, get_manager_class, Capabilities
from labmanager.views import RedirectView
from labmanager.scorm import get_scorm_object, get_authentication_scorm
from labmanager.db import db
import labmanager.forms as forms
from labmanager.utils import data_filename, remote_addr
import labmanager.rlms.ext.rest as http_plugin

config = yload(open(data_filename('labmanager/config/config.yml')))

#####################################################################
#
#
#                      Parent views
#
#


class L4lModelView(ModelView):
    def is_accessible(self):
        if not current_user.is_authenticated():
            return False
        return session['usertype'] == 'labmanager' or (
            session['usertype'] == 'golab' and current_user.is_admin)
Beispiel #4
0
from wtforms.fields import PasswordField
from flask.ext.wtf import Form, validators, TextField
from flask import request, redirect, url_for, session, Markup
from flask.ext import wtf
from flask.ext.admin import Admin, AdminIndexView, BaseView, expose
from flask.ext.admin.contrib.sqlamodel import ModelView
from flask.ext.login import current_user
from labmanager.babel import gettext, lazy_gettext
from labmanager.models import LtUser, Course, Laboratory, PermissionToLt, PermissionToCourse, RequestPermissionLT
from labmanager.views import RedirectView
from labmanager.db import db
from labmanager.rlms import get_manager_class
import labmanager.forms as forms
from labmanager.utils import data_filename

config = yload(open(data_filename('labmanager/config/config.yml')))

#################################################################
# 
#            Base class
# 

class PleAuthManagerMixin(object):
    def is_accessible(self):
        if not current_user.is_authenticated():
            return False
        return session['usertype'] == 'lms' and current_user.access_level == 'admin'
    
class L4lPleModelView(PleAuthManagerMixin, ModelView):
    def _handle_view(self, name, **kwargs):
        if not self.is_accessible():