Beispiel #1
0
class PleSpacesPanel(L4lPleModelView):

    can_create = can_edit = False

    column_list = ['name', 'context_id', 'url']
    form_columns = ('name', 'context_id')
    column_formatters = dict(url=format_space_url)
    column_labels = dict(name=lazy_gettext('name'),
                         context_id=lazy_gettext('context_id'),
                         url=lazy_gettext('url'))

    def __init__(self, session, **kwargs):
        super(PleSpacesPanel, self).__init__(Course, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(PleSpacesPanel, self).get_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PleSpacesPanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt=current_user.lt)
        return query_obj

    def on_model_change(self, form, model):
        model.lt = current_user.lt
Beispiel #2
0
class PermissionToLtPanel(L4lModelView):
    # 
    # TODO: manage configuration
    # 
    column_list = ['laboratory', 'lt', 'local_identifier', 'configuration', 'SCORM']
    column_labels = dict(laboratory=lazy_gettext('laboratory'), lt=lazy_gettext('lt'), local_identifier=lazy_gettext('local_identifier'), configuration=lazy_gettext('configuration'), SCORM=lazy_gettext('SCORM'))
    column_descriptions = dict(
                laboratory       = lazy_gettext(u"Laboratory"),
                lt               = lazy_gettext(u"Learning Management System"),
                local_identifier = lazy_gettext(u"Unique identifier for a Learning Tool to access a laboratory"),
            )
    column_formatters = dict( SCORM = scorm_formatter )

    def __init__(self, session, **kwargs):
        super(PermissionToLtPanel, self).__init__(PermissionToLt, session, **kwargs)

    @expose('/scorm/<lt_id>/scorm_<local_id>.zip')
    def get_scorm(self, lt_id, local_id):
        permission = self.session.query(PermissionToLt).filter_by(lt_id = lt_id, local_identifier = local_id).one()
        db_lt = permission.lt
        if db_lt.basic_http_authentications:
            url = db_lt.basic_http_authentications[0].lt_url or ''
        else:
            url = ''
        lt_path = urlparse.urlparse(url).path or '/'
        extension = '/'
        if 'gateway4labs/' in lt_path:
            extension = lt_path[lt_path.rfind('gateway4labs/lms/list') + len('gateway4labs/lms/list'):]
            lt_path  = lt_path[:lt_path.rfind('gateway4labs/')]
        contents = get_scorm_object(False, local_id, lt_path, extension)
        return Response(contents, headers = {'Content-Type' : 'application/zip', 'Content-Disposition' : 'attachment; filename=scorm_%s.zip' % local_id})
Beispiel #3
0
class PermissionToLmsUserPanel(L4lLmsModelView):

    list_template = 'lms_admin/list_lti.html'

    can_edit = False
    form_columns = ('lt_user', 'permission_to_lt')
    column_labels = dict(permission_to_lt=lazy_gettext('Permission To LT'),
                         lms_user=lazy_gettext('LT User'),
                         key=lazy_gettext('Key'),
                         secret=lazy_gettext('Secret'))
    lt_user_filter = None
    permission_to_lt_filter = None
    form_args = dict(
        lt_user=dict(
            query_factory=lambda: PermissionToLmsUserPanel.lt_user_filter()),
        permission_to_lt=dict(query_factory=lambda: PermissionToLmsUserPanel.
                              permission_to_lt_filter()),
    )

    def __init__(self, session, **kwargs):
        super(PermissionToLmsUserPanel, self).__init__(PermissionToLtUser,
                                                       session, **kwargs)
        PermissionToLmsUserPanel.lt_user_filter = create_lms_user_filter(
            self.session)
        PermissionToLmsUserPanel.permission_to_lt_filter = create_permission_to_lms_filter(
            self.session)

    def get_query(self, *args, **kwargs):
        query_obj = super(PermissionToLmsUserPanel,
                          self).get_query(*args, **kwargs)
        query_obj = query_obj.join(LtUser).filter_by(lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PermissionToLmsUserPanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.join(LtUser).filter_by(lt=current_user.lt)
        return query_obj

    def on_model_change(self, form, model):
        existing_permission = self.session.query(PermissionToLtUser).filter_by(
            lt_user=model.lt_user,
            permission_to_lt=model.permission_to_lt).first()
        if existing_permission:
            raise Exception(
                gettext(
                    "Existing permission on that user for that laboratory"))
        key = u'%s_%s_%s' % (current_user.lt, model.lt_user.login,
                             model.permission_to_lt.local_identifier)
        key = key.lower().replace(' ', '_')
        final_key = u''
        for c in key:
            if c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-':
                final_key += c
            else:
                final_key += '_'
        # uuid4 returns a random string (based on random functions, not in any characteristic of this computer or network)
        secret = uuid.uuid4().hex
        model.key = final_key
        model.secret = secret
Beispiel #4
0
class PlePermissionToSpacePanel(L4lPleModelView):
    form_args = dict(
        permission_to_lt=dict(query_factory=lambda: PlePermissionToSpacePanel.
                              permission_to_lms_filter()),
        course=dict(
            query_factory=lambda: PlePermissionToSpacePanel.course_filter()),
    )
    column_labels = dict(
        permission_to_lt=lazy_gettext('Permission'),
        course=lazy_gettext('Space'),
        configuration=lazy_gettext('Configuration'),
    )

    def __init__(self, session, **kwargs):
        super(PlePermissionToSpacePanel,
              self).__init__(PermissionToCourse, session, **kwargs)
        PlePermissionToSpacePanel.permission_to_lms_filter = create_permission_to_lms_filter(
            self.session)
        PlePermissionToSpacePanel.course_filter = create_course_filter(
            self.session)

    def get_query(self, *args, **kwargs):
        query_obj = super(PlePermissionToSpacePanel,
                          self).get_query(*args, **kwargs)
        query_obj = query_obj.join(Course).filter_by(lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PlePermissionToSpacePanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.join(Course).filter_by(lt=current_user.lt)
        return query_obj
Beispiel #5
0
class LTPanel(L4lModelView):
    inline_models = (BasicHttpCredentialsForm(BasicHttpCredentials), ShindigCredentials)
    column_list = ['full_name', 'name', 'url', 'download']
    column_labels = dict(full_name=lazy_gettext('full_name'), name=lazy_gettext('name'), url=lazy_gettext('url'), download=lazy_gettext('download'))
    column_formatters = dict( download = download )
    column_descriptions = dict( name = lazy_gettext("Institution short name (lower case, all letters, dots and numbers)"), full_name = lazy_gettext("Name of the institution."))

    def __init__(self, session, **kwargs):
        super(LTPanel, self).__init__(LearningTool, session, **kwargs)
        self.local_data = threading.local()

    def edit_form(self, obj = None):
        form = super(LTPanel, self).edit_form(obj)
        self.local_data.basic_http_authentications = {}
        if obj is not None:
            for auth in obj.basic_http_authentications:
                self.local_data.basic_http_authentications[auth.id] = auth.lt_password
        return form

    def on_model_change(self, form, model):
        old_basic_http_authentications = getattr(self.local_data, 'basic_http_authentications', {})
        for authentication in model.basic_http_authentications:
            old_password = old_basic_http_authentications.get(authentication.id, None)
            authentication.update_password(old_password)

    @expose('/<id>/scorm_authentication.zip')
    def scorm_authentication(self, id):
        lt = self.session.query(LearningTool).filter_by(id = id).one()
        if lt.basic_http_authentications:
            url = lt.basic_http_authentications[0].lt_url or ''
        else:
            url = ''
        return get_authentication_scorm(url)
Beispiel #6
0
class LtUsersPanel(L4lModelView):
    column_list = ['lt', 'login', 'full_name', 'access_level']
    column_labels = dict(lt=lazy_gettext('lt'), login=lazy_gettext('login'), full_name=lazy_gettext('full_name'), access_level=lazy_gettext('access_level'))
    form_columns = ('full_name', 'login', 'password', 'access_level', 'lt')
    sel_choices = [(level, level.title()) for level in config['user_access_level']]
    form_overrides = dict(access_level=wtf.SelectField, password=PasswordField)
    form_args = dict(access_level=dict( choices=sel_choices ),
                            login=dict(validators=forms.USER_LOGIN_DEFAULT_VALIDATORS[:]),
                            password=dict(validators=forms.USER_PASSWORD_DEFAULT_VALIDATORS[:]))
    
    def __init__(self, session, **kwargs):
        super(LtUsersPanel, self).__init__(LtUser, session, **kwargs)

    def create_model(self, form):
        if form.password.data == '':
            form.password.errors.append(lazy_gettext("This field is required."))
            return False
        form.password.data = unicode(new_hash("sha", form.password.data.encode('utf8')).hexdigest())
        return super(LtUsersPanel, self).create_model(form)

    def update_model(self, form, model):
        old_password = model.password
        if form.password.data != '':
            form.password.data = unicode(new_hash("sha", form.password.data.encode('utf8')).hexdigest())
        return_value = super(LtUsersPanel, self).update_model(form, model)
        if form.password.data == '':
            model.password = old_password
            self.session.add(model)
            self.session.commit()
        return return_value
Beispiel #7
0
def init_public_admin(app):
    public_admin_url = '/public'
    public_admin = Admin(index_view = PublicAdminPanel(url=public_admin_url, endpoint = 'public_admin'), name = lazy_gettext(u"Public laboratories"), url = public_admin_url, endpoint = 'public-admin')
    public_admin.add_view(PublicSystemsPanel( db.session, name = lazy_gettext(u"Show public systems"), endpoint = 'public_admin_systems', url = 'systems/public'))
    public_admin.add_view(PublicLaboratoriesPanel( db.session, name = lazy_gettext(u"Show public labs"), endpoint = 'public_admin_labs', url = 'labs/public'))
    public_admin.add_view(RedirectView('index', name = lazy_gettext(u"Back"), endpoint = 'public_admin_logout', url = 'back'))
    public_admin.init_app(app)
Beispiel #8
0
class UsersPanel(L4lModelView):
    column_list = ['login', 'name']
    form_columns = ('name', 'login', 'password')
    column_labels = dict(name=lazy_gettext('name'),
                         login=lazy_gettext('login'),
                         password=lazy_gettext('password'))
    form_overrides = dict(access_level=wtf.SelectField, password=PasswordField)
    form_args = dict(
        login=dict(validators=forms.USER_LOGIN_DEFAULT_VALIDATORS[:]),
        password=dict(validators=forms.USER_PASSWORD_DEFAULT_VALIDATORS[:]))

    def __init__(self, session, **kwargs):
        super(UsersPanel, self).__init__(LabManagerUser, session, **kwargs)

    def create_model(self, form):
        if form.password.data == '':
            form.password.errors.append(
                lazy_gettext("This field is required."))
            return False
        form.password.data = unicode(
            new_hash(ALGORITHM, form.password.data.encode('utf8')).hexdigest())
        return super(UsersPanel, self).create_model(form)

    def update_model(self, form, model):
        old_password = model.password
        if form.password.data != '':
            form.password.data = unicode(
                new_hash(ALGORITHM,
                         form.password.data.encode('utf8')).hexdigest())
        return_value = super(UsersPanel, self).update_model(form, model)
        if form.password.data == '':
            model.password = old_password
            self.session.add(model)
            self.session.commit()
        return return_value
Beispiel #9
0
class SpaceUrlForm(Form):
    url = TextField(
        lazy_gettext('Space URL'),
        [validators.Length(min=6, max=200),
         validators.URL()],
        description=lazy_gettext("Drop here the URL of the Space."),
        default="http://graasp.epfl.ch/#item=space_1234")
Beispiel #10
0
class LmsInstructorLaboratoriesPanel(L4lLmsModelView):

    can_delete = False
    can_edit = False
    can_create = False

    column_list = [
        'rlms', 'name', 'laboratory_id', 'local_identifier', 'SCORM'
    ]
    column_labels = dict(rlms=lazy_gettext('Rlms'),
                         name=lazy_gettext('Name'),
                         laboratory_id=lazy_gettext('Laboratory Id'),
                         local_identifier=lazy_gettext('Local Identifier'),
                         scorm=lazy_gettext('Scorm'))
    column_formatters = dict(SCORM=scorm_formatter,
                             local_identifier=local_id_formatter)

    def __init__(self, session, **kwargs):
        super(LmsInstructorLaboratoriesPanel,
              self).__init__(Laboratory, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(LmsInstructorLaboratoriesPanel,
                          self).get_query(*args, **kwargs)
        query_obj = query_obj.join(PermissionToLt).filter_by(
            lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(LmsInstructorLaboratoriesPanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.join(PermissionToLt).filter_by(
            lt=current_user.lt)
        return query_obj

    @expose('/scorm/scorm_<local_id>.zip')
    def get_scorm(self, local_id):
        db_lt = current_user.lt
        if db_lt.basic_http_authentications:
            url = db_lt.basic_http_authentications[0].lt_url or ''
        else:
            url = ''
        lt_path = urlparse.urlparse(url).path or '/'
        extension = '/'
        if 'gateway4labs/' in lt_path:
            extension = lt_path[lt_path.rfind('gateway4labs/lms/list') +
                                len('gateway4labs/lms/list'):]
            lt_path = lt_path[:lt_path.rfind('gateway4labs/')]
        contents = get_scorm_object(False, local_id, lt_path, extension)
        return Response(contents,
                        headers={
                            'Content-Type':
                            'application/zip',
                            'Content-Disposition':
                            'attachment; filename=scorm_%s.zip' % local_id
                        })
Beispiel #11
0
def init_ple_instructor_admin(app):
    ple_instructor_url = '/ple_instructor'
    ple_instructor = Admin(index_view = PleInstructorPanel(url=ple_instructor_url, endpoint = 'ple_instructor'), name = lazy_gettext(u'PLEinstructor'), url = ple_instructor_url, endpoint = 'ple_instructor')
    ple_instructor.add_view(PleInstructorLaboratoriesPanel(db.session, name = lazy_gettext(u'Laboratories'), endpoint = 'ple_instructor_laboratories', url = 'laboratories'))
    i18n_spaces=lazy_gettext(u'Spaces')
    ple_instructor.add_view(PleInstructorNewSpacesPanel(db.session,    category = i18n_spaces, name     = lazy_gettext(u'New'), endpoint = 'ple_instructor_new_courses', url = 'spaces/create'))
    ple_instructor.add_view(PleInstructorSpacesPanel(db.session,    category = i18n_spaces, name     = lazy_gettext(u'Spaces'), endpoint = 'ple_instructor_courses', url = 'spaces'))
    ple_instructor.add_view(PleInstructorPermissionToSpacesPanel(db.session,    category = i18n_spaces, name     = lazy_gettext(u'Permissions'), endpoint = 'ple_instructor_course_permissions', url = 'spaces/permissions'))
    ple_instructor.add_view(RedirectView('logout',         name = lazy_gettext(u'Log out'), endpoint = 'ple_instructor_logout', url = 'logout'))
    ple_instructor.init_app(app)
Beispiel #12
0
def init_ple_admin(app):
    ple_admin_url = '/ple_admin'
    i18n_labs = lazy_gettext(u'Labs')
    ple_admin = Admin(index_view=PleAdminPanel(url=ple_admin_url,
                                               endpoint='ple_admin'),
                      name=lazy_gettext(u'PLE admin'),
                      url=ple_admin_url,
                      endpoint='ple-admin')
    ple_admin.add_view(
        PleInstructorLaboratoriesPanel(db.session,
                                       category=i18n_labs,
                                       name=lazy_gettext(u"Available labs"),
                                       endpoint='ple_admin_labs',
                                       url='labs/available'))
    ple_admin.add_view(
        PleInstructorRequestLaboratoriesPanel(
            db.session,
            category=i18n_labs,
            name=lazy_gettext(u"Request new labs"),
            endpoint='ple_admin_request_labs',
            url='labs/request'))

    i18n_spaces = lazy_gettext(u'Spaces')
    ple_admin.add_view(
        PleNewSpacesPanel(db.session,
                          category=i18n_spaces,
                          name=lazy_gettext(u'New'),
                          endpoint='ple_admin_new_courses',
                          url='spaces/create'))
    ple_admin.add_view(
        PleSpacesPanel(db.session,
                       category=i18n_spaces,
                       name=lazy_gettext(u'Spaces'),
                       endpoint='ple_admin_courses',
                       url='spaces'))
    ple_admin.add_view(
        PlePermissionToSpacePanel(db.session,
                                  category=i18n_spaces,
                                  name=lazy_gettext(u'Permissions'),
                                  endpoint='ple_admin_course_permissions',
                                  url='spaces/permissions'))

    ple_admin.add_view(
        PleUsersPanel(db.session,
                      name=lazy_gettext(u'Users'),
                      endpoint='ple_admin_users',
                      url='users'))
    ple_admin.add_view(
        RedirectView('logout',
                     name=lazy_gettext(u'Log out'),
                     endpoint='ple_admin_logout',
                     url='logout'))
    ple_admin.init_app(app)
Beispiel #13
0
class AddUserForm(RetrospectiveForm):
    name = TextField(lazy_gettext("Name"), validators=[Required()])
    login = TextField(lazy_gettext("Login"), validators=[Required()])
    password = PasswordField(lazy_gettext("Password"))

    def __init__(self, add_or_edit, *args, **kwargs):
        super(AddUserForm, self).__init__(*args, **kwargs)
        self.add_or_edit = add_or_edit

    def validate_password(form, field):
        if form.add_or_edit and field.data == '':
            raise ValidationError(gettext("This field is required."))
Beispiel #14
0
class PleInstructorLaboratoriesPanel(L4lPleInstructorModelView):

    can_delete = False
    can_edit = False
    can_create = False

    column_list = [
        'rlms', 'name', 'laboratory_id', 'local_identifier', 'widgets'
    ]
    column_formatters = dict(local_identifier=local_id_formatter,
                             widgets=list_widgets_formatter)
    column_labels = dict(rlms=lazy_gettext('RLMS'),
                         name=lazy_gettext('Name'),
                         laboratory_id=lazy_gettext('Laboratory Id'),
                         local_identifier=lazy_gettext('Local Identifier'),
                         widgets=lazy_gettext('widgets'))

    def __init__(self, session, **kwargs):
        super(PleInstructorLaboratoriesPanel,
              self).__init__(Laboratory, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(PleInstructorLaboratoriesPanel,
                          self).get_query(*args, **kwargs)
        query_obj = query_obj.join(PermissionToLt).filter_by(
            lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PleInstructorLaboratoriesPanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.join(PermissionToLt).filter_by(
            lt=current_user.lt)
        return query_obj

    @expose("/widgets/<local_identifier>/")
    def list_widgets(self, local_identifier):
        laboratory = self.session.query(Laboratory).join(
            PermissionToLt).filter_by(
                lt=current_user.lt, local_identifier=local_identifier).first()
        if laboratory is None:
            return self.render("ple_admin/errors.html",
                               message=gettext("Laboratory not found"))
        rlms_db = laboratory.rlms
        RLMS_CLASS = get_manager_class(rlms_db.kind, rlms_db.version,
                                       rlms_db.id)
        rlms = RLMS_CLASS(rlms_db.configuration)
        widgets = rlms.list_widgets(laboratory.laboratory_id)
        return self.render("ple_admin/list_widgets.html",
                           widgets=widgets,
                           institution_id=current_user.lt.name,
                           lab_name=local_identifier)
Beispiel #15
0
def init_lms_admin(app):
    lms_admin_url = '/lms_admin'
    lms_admin = Admin(index_view = LmsAdminPanel(url=lms_admin_url, endpoint = 'lms_admin'), name = lazy_gettext(u'LMS admin'), url = lms_admin_url, endpoint = 'lms-admin')
    lms_admin.add_view(LmsInstructorLaboratoriesPanel( db.session, name = lazy_gettext(u"Lab"), endpoint = 'lms_admin_labs', url = 'labs'))
    i18n_courses=lazy_gettext(u"Courses")
    lms_admin.add_view(LmsCoursesPanel(db.session,    category = i18n_courses, name     = lazy_gettext(u"Courses"), endpoint = 'lms_admin_courses', url = 'courses'))
    lms_admin.add_view(LmsCourseDiscoveryPanel(db.session,    category = i18n_courses, name     = lazy_gettext(u'Discover'), endpoint = 'lms_admin_course_discover', url = 'courses/discover'))
    lms_admin.add_view(LmsPermissionToCoursesPanel(db.session,    category =i18n_courses, name     = lazy_gettext(u'Permissions'), endpoint = 'lms_admin_course_permissions', url = 'courses/permissions'))
    i18n_users=lazy_gettext(u'Users')
    lms_admin.add_view(LmsUsersPanel(db.session,      category = i18n_users, name     = lazy_gettext(u'Users'), endpoint = 'lms_admin_users', url = 'users'))
    lms_admin.add_view(PermissionToLmsUserPanel(db.session,      category = i18n_users, name     = lazy_gettext(u'Permissions'), endpoint = 'lms_admin_user_permissions', url = 'user_permissions'))
    lms_admin.add_view(RedirectView('logout',         name = lazy_gettext(u'Log out'), endpoint = 'lms_admin_logout', url = 'logout'))
    lms_admin.init_app(app)
Beispiel #16
0
class ApplicationForm(SimplifiedApplicationForm):
    url = URLField(lazy_gettext("Web:"),
                   validators=[required()],
                   widget=AngularJSURLInput(ng_model='embed.url',
                                            ng_enter="submitForm()"),
                   description=lazy_gettext("Web address of the resource"))
    height = HiddenField(lazy_gettext("Height:"),
                         validators=[required()],
                         widget=AngularJSHiddenInput(ng_model='embed.height'))
    scale = HiddenField(lazy_gettext("Scale:"),
                        validators=[required()],
                        widget=AngularJSHiddenInput(ng_model='embed.scale'))
    uses_proxy = BooleanField(lazy_gettext("Try https proxy?"))
Beispiel #17
0
def init_ple_admin(app):
    ple_admin_url = '/ple_admin'
    i18n_labs = lazy_gettext(u'Labs')
    ple_admin = Admin(index_view = PleAdminPanel(url=ple_admin_url, endpoint = 'ple_admin'), name = lazy_gettext(u'PLE admin'), url = ple_admin_url, endpoint = 'ple-admin')
    ple_admin.add_view(PleInstructorLaboratoriesPanel( db.session,  category = i18n_labs, name = lazy_gettext(u"Available labs"), endpoint = 'ple_admin_labs', url = 'labs/available'))
    ple_admin.add_view(PleInstructorRequestLaboratoriesPanel( db.session, category = i18n_labs, name = lazy_gettext(u"Request new labs"), endpoint = 'ple_admin_request_labs', url = 'labs/request'))

    i18n_spaces = lazy_gettext(u'Spaces')
    ple_admin.add_view(PleNewSpacesPanel(db.session,             category = i18n_spaces, name     = lazy_gettext(u'New'), endpoint = 'ple_admin_new_courses', url = 'spaces/create'))
    ple_admin.add_view(PleSpacesPanel(db.session,                   category = i18n_spaces, name     = lazy_gettext(u'Spaces'), endpoint = 'ple_admin_courses', url = 'spaces'))
    ple_admin.add_view(PlePermissionToSpacePanel(db.session,  category = i18n_spaces, name     = lazy_gettext(u'Permissions'), endpoint = 'ple_admin_course_permissions', url = 'spaces/permissions'))

    ple_admin.add_view(PleUsersPanel(db.session,      name = lazy_gettext(u'Users'), endpoint = 'ple_admin_users', url = 'users'))
    ple_admin.add_view(RedirectView('logout',         name = lazy_gettext(u'Log out'), endpoint = 'ple_admin_logout', url = 'logout'))
    ple_admin.init_app(app)
Beispiel #18
0
class BasicHttpCredentialsForm(InlineFormAdmin):
    column_descriptions = dict(
            lt_login = lazy_gettext('Login of the LT when contacting the LabManager'),
        )
    form_overrides = dict(lt_password=PasswordField, labmanager_password=PasswordField)
    form_columns = ('id', 'lt_login', 'lt_password', 'lt_url', 'labmanager_login', 'labmanager_password')
    excluded_form_fields = ('id',)
Beispiel #19
0
class LmsUsersPanel(L4lLmsModelView):

    column_list = ['login', 'full_name', 'access_level']
    form_columns = ('login', 'full_name', 'access_level', 'password')
    column_labels = dict(login = lazy_gettext('Login'),
                                    full_name = lazy_gettext('Full Name'),
                                    access_level = lazy_gettext('Access Level'),
                                    password = lazy_gettext('Password'))  
    sel_choices = [(level, level.title()) for level in config['user_access_level']]
    form_overrides = dict(password=PasswordField, access_level=wtf.SelectField)
    form_args = dict( access_level=dict( choices=sel_choices ),
                            login=dict(validators=forms.USER_LOGIN_DEFAULT_VALIDATORS[:]),
                           password=dict(validators=forms.USER_PASSWORD_DEFAULT_VALIDATORS[:]))            
                           
    def __init__(self, session, **kwargs):
        super(LmsUsersPanel, self).__init__(LtUser, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(LmsUsersPanel, self).get_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt = current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(LmsUsersPanel, self).get_count_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt = current_user.lt)
        return query_obj
        
    def create_model(self, form):
        if form.password.data == '':
            form.password.errors.append(lazy_gettext("This field is required."))
            return False
        form.password.data = unicode(new_hash(ALGORITHM, form.password.data.encode('utf8')).hexdigest())
        return super(LmsUsersPanel, self).create_model(form)

    def on_model_change(self, form, model):
        model.lt = current_user.lt

    def update_model(self, form, model):
        old_password = model.password
        if form.password.data != '':
            form.password.data = unicode(new_hash(ALGORITHM, form.password.data.encode('utf8')).hexdigest())
        return_value = super(LmsUsersPanel, self).update_model(form, model)
        if form.password.data == '':
            model.password = old_password
            self.session.add(model)
            self.session.commit()
        return return_value
Beispiel #20
0
 def create_model(self, form):
     if form.password.data == '':
         form.password.errors.append(
             lazy_gettext("This field is required."))
         return False
     form.password.data = unicode(
         new_hash(ALGORITHM, form.password.data.encode('utf8')).hexdigest())
     return super(LtUsersPanel, self).create_model(form)
Beispiel #21
0
def init_instructor_admin(app):
    lms_instructor_url = '/lms_instructor'
    lms_instructor = Admin(index_view=LmsInstructorPanel(
        url=lms_instructor_url, endpoint='lms_instructor'),
                           name=lazy_gettext(u'LMS instructor'),
                           url=lms_instructor_url,
                           endpoint='lms-instructor')
    lms_instructor.add_view(
        PermissionToLmsUserPanel(db.session,
                                 name=lazy_gettext(u'Permissions'),
                                 endpoint='lms_instructor_permissions',
                                 url='permissions'))
    lms_instructor.add_view(
        RedirectView('logout',
                     name=lazy_gettext(u'Log out'),
                     endpoint='lms_instructor_logout',
                     url='logout'))
    lms_instructor.init_app(app)
Beispiel #22
0
class LabRequestsPanel(L4lModelView):
    #
    # TODO: manage configuration
    #
    can_create = can_delete = can_edit = False
    column_list = ['laboratory', 'local_identifier', 'lt', 'accept', 'reject']
    column_labels = dict(laboratory=lazy_gettext('laboratory'),
                         local_identifier=lazy_gettext('local_identifier'),
                         lt=lazy_gettext('lt'),
                         accept=lazy_gettext('accept'),
                         reject=lazy_gettext('reject'))
    column_formatters = dict(accept=accept_formatter, reject=reject_formatter)
    column_descriptions = dict(
        laboratory=lazy_gettext(u"The laboratory that has been requested"),
        lt=lazy_gettext(
            u"Learning Management System which created each request"),
        local_identifier=lazy_gettext(
            u"Unique identifier for a LT to access a laboratory"),
    )

    def __init__(self, session, **kwargs):
        super(LabRequestsPanel, self).__init__(RequestPermissionLT, session,
                                               **kwargs)

    @expose('/accept_request', methods=['GET', 'POST'])
    def accept_request(self):
        request_id = unicode(request.form['request_id'])
        req = self.session.query(RequestPermissionLT).filter_by(
            id=request_id).first()
        perm = PermissionToLt(lt=req.lt,
                              laboratory=req.laboratory,
                              configuration='',
                              local_identifier=req.local_identifier)
        self.session.add(perm)
        self.session.delete(req)
        self.session.commit()
        return redirect(url_for('.index_view'))

    @expose('/reject_request', methods=['GET', 'POST'])
    def reject_request(self):
        request_id = unicode(request.form['request_id'])
        req = self.session.query(RequestPermissionLT).filter_by(
            id=request_id).first()
        perm = PermissionToLt(lt=req.lt,
                              laboratory=req.laboratory,
                              configuration='',
                              local_identifier=req.local_identifier)
        self.session.add(perm)
        self.session.delete(req)
        self.session.commit()
        return redirect(url_for('.index_view'))
Beispiel #23
0
def reject_formatter(v, c, req, p):
    klass = 'btn-danger'
    msg =  lazy_gettext('Reject request')
    return Markup("""<form method='POST' action='%(url)s' style="text-align: center">
                        <input class='btn %(klass)s' type='submit' value="%(msg)s"></input>
                        <input type='hidden' name='request_id' value='%(request_id)s'/>
                    </form>""" % dict(
                        url                      = url_for('.reject_request'),                     
                        klass                    = klass,
                        msg                      = msg,
                        request_id               = req.id,
                    ))
Beispiel #24
0
def reject_formatter(v, c, req, p):
    klass = 'btn-danger'
    msg =  lazy_gettext('Reject request')
    return Markup("""<form method='POST' action='%(url)s' style="text-align: center">
                        <input class='btn %(klass)s' type='submit' value="%(msg)s"></input>
                        <input type='hidden' name='request_id' value='%(request_id)s'/>
                    </form>""" % dict(
                        url                      = url_for('.reject_request'),                     
                        klass                    = klass,
                        msg                      = msg,
                        request_id               = req.id,
                    ))
Beispiel #25
0
class RegistrationForm(Form):
    full_name  = TextField(lazy_gettext('School name'), [validators.Required(), validators.Length(min=4)] + forms.SCHOOL_FULL_NAME_VALIDATORS, description = lazy_gettext('School name.'))
    short_name = TextField(lazy_gettext('Short name'), [validators.Required()] + forms.SCHOOL_SHORT_NAME_VALIDATORS, description = lazy_gettext('Short name (lower case, all letters, dots and numbers).'))
    url        = TextField(lazy_gettext('School URL'), [validators.Length(min=6, max=200), validators.URL(), validators.Required()], description = lazy_gettext('Address of your school.'))
    user_full_name  = TextField(lazy_gettext('User name'), [validators.Required(), validators.Length(min=4)] + forms.USER_FULL_NAME_VALIDATORS, description = lazy_gettext('Your name and last name.'))
    user_login      = TextField(lazy_gettext('Login'), [validators.Required()] + forms.USER_LOGIN_DEFAULT_VALIDATORS, description = lazy_gettext('Your new login (you can create more later).'))
    user_password   = PasswordField(lazy_gettext('Password'), [validators.Required()] + forms.USER_PASSWORD_DEFAULT_VALIDATORS, description = lazy_gettext('Your access password.'))
Beispiel #26
0
class LmsCoursesPanel(L4lLmsModelView):

    column_list = ['name', 'context_id']
    form_columns = ('name', 'context_id')
    column_labels = dict(name = lazy_gettext('Name'),
                                    context_id = lazy_gettext('Context Id'))

    def __init__(self, session, **kwargs):
        super(LmsCoursesPanel, self).__init__(Course, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(LmsCoursesPanel, self).get_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt = current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(LmsCoursesPanel, self).get_count_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt = current_user.lt)
        return query_obj

    def on_model_change(self, form, model):
        model.lt   = current_user.lt
Beispiel #27
0
class SimplifiedApplicationForm(Form):
    name = TextField(lazy_gettext("Name:"), validators=[required()], widget = AngularJSTextInput(ng_model='embed.name', ng_enter="submitForm()"), description=lazy_gettext("Name of the resource"))
    age_ranges_range = HiddenField(lazy_gettext("Age ranges:"), validators=[], description=lazy_gettext("Select the age ranges this tool is useful for"))

    # The following are NOT REQUIRED
    description = TextField(lazy_gettext("Description:"), validators=[], widget = AngularJSTextInput(ng_model='embed.description', ng_enter="submitForm()"), description=lazy_gettext("Describe the resource in a few words"))
    domains_text = TextField(lazy_gettext("Domains:"), validators=[], widget = AngularJSTextInput(ng_enter="submitForm()"), description=lazy_gettext("Say in which domains apply to the resource (separated by commas): e.g., physics, electronics..."))

    url = URLField(lazy_gettext("Web:"), widget = AngularJSURLInput(ng_model='embed.url', ng_enter="submitForm()"), description=lazy_gettext("Web address of the resource"))
    height = HiddenField(lazy_gettext("Height:"), widget = AngularJSHiddenInput(ng_model='embed.height'))
    scale = HiddenField(lazy_gettext("Scale:"), widget = AngularJSHiddenInput(ng_model='embed.scale'))
Beispiel #28
0
class PleUsersPanel(L4lPleModelView):

    can_delete = True
    can_edit = False
    can_create = True

    column_list = ['login', 'full_name', 'access_level']
    form_columns = ('login', 'full_name', 'access_level', 'password')
    column_labels = dict(login=lazy_gettext('login'),
                         full_name=lazy_gettext('full_name'),
                         access_level=lazy_gettext('access_level'),
                         password=lazy_gettext('password'))
    sel_choices = [(level, level.title())
                   for level in config['user_access_level']]
    form_overrides = dict(password=PasswordField, access_level=wtf.SelectField)
    form_args = dict(
        access_level=dict(choices=sel_choices),
        login=dict(validators=forms.USER_LOGIN_DEFAULT_VALIDATORS[:]),
        password=dict(validators=forms.USER_PASSWORD_DEFAULT_VALIDATORS[:]))

    def __init__(self, session, **kwargs):
        super(PleUsersPanel, self).__init__(LtUser, session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(PleUsersPanel, self).get_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt=current_user.lt)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PleUsersPanel, self).get_count_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt=current_user.lt)
        return query_obj

    def on_model_change(self, form, model):
        # TODO: don't update password always
        # Edit is false, so there is no possibility of changing data
        model.lt = current_user.lt
        model.password = unicode(
            hashlib.new('sha', model.password.encode('utf8')).hexdigest())
Beispiel #29
0
def init_public_admin(app):
    public_admin_url = '/public'
    public_admin = Admin(index_view=PublicAdminPanel(url=public_admin_url,
                                                     endpoint='public_admin'),
                         name=lazy_gettext(u"Public laboratories"),
                         url=public_admin_url,
                         endpoint='public-admin')
    public_admin.add_view(
        PublicSystemsPanel(db.session,
                           name=lazy_gettext(u"Show public systems"),
                           endpoint='public_admin_systems',
                           url='systems/public'))
    public_admin.add_view(
        PublicLaboratoriesPanel(db.session,
                                name=lazy_gettext(u"Show public labs"),
                                endpoint='public_admin_labs',
                                url='labs/public'))
    public_admin.add_view(
        RedirectView('index',
                     name=lazy_gettext(u"Back"),
                     endpoint='public_admin_logout',
                     url='back'))
    public_admin.init_app(app)
Beispiel #30
0
class PermissionToLmsUserPanel(L4lLmsInstructorModelView):

    can_create = can_edit = can_delete = False
    column_labels = dict(permission_to_lms=lazy_gettext('Permission To LMS'),
                         lms_user=lazy_gettext('LMS User'),
                         key=lazy_gettext('Key'),
                         secret=lazy_gettext('Secret'))

    def __init__(self, session, **kwargs):
        super(PermissionToLmsUserPanel, self).__init__(PermissionToLtUser,
                                                       session, **kwargs)

    def get_query(self, *args, **kwargs):
        query_obj = super(PermissionToLmsUserPanel,
                          self).get_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt_user=current_user)
        return query_obj

    def get_count_query(self, *args, **kwargs):
        query_obj = super(PermissionToLmsUserPanel,
                          self).get_count_query(*args, **kwargs)
        query_obj = query_obj.filter_by(lt_user=current_user)
        return query_obj
Beispiel #31
0
def init_ple_instructor_admin(app):
    ple_instructor_url = '/ple_instructor'
    ple_instructor = Admin(index_view=PleInstructorPanel(
        url=ple_instructor_url, endpoint='ple_instructor'),
                           name=lazy_gettext(u'PLEinstructor'),
                           url=ple_instructor_url,
                           endpoint='ple_instructor')
    ple_instructor.add_view(
        PleInstructorLaboratoriesPanel(db.session,
                                       name=lazy_gettext(u'Laboratories'),
                                       endpoint='ple_instructor_laboratories',
                                       url='laboratories'))
    i18n_spaces = lazy_gettext(u'Spaces')
    ple_instructor.add_view(
        PleInstructorNewSpacesPanel(db.session,
                                    category=i18n_spaces,
                                    name=lazy_gettext(u'New'),
                                    endpoint='ple_instructor_new_courses',
                                    url='spaces/create'))
    ple_instructor.add_view(
        PleInstructorSpacesPanel(db.session,
                                 category=i18n_spaces,
                                 name=lazy_gettext(u'Spaces'),
                                 endpoint='ple_instructor_courses',
                                 url='spaces'))
    ple_instructor.add_view(
        PleInstructorPermissionToSpacesPanel(
            db.session,
            category=i18n_spaces,
            name=lazy_gettext(u'Permissions'),
            endpoint='ple_instructor_course_permissions',
            url='spaces/permissions'))
    ple_instructor.add_view(
        RedirectView('logout',
                     name=lazy_gettext(u'Log out'),
                     endpoint='ple_instructor_logout',
                     url='logout'))
    ple_instructor.init_app(app)
Beispiel #32
0
class AddLmsForm(RetrospectiveForm):
    name = TextField(lazy_gettext("Name"), validators=[Required()])
    url = TextField(lazy_gettext("URL"), validators=[Required()])
    lms_login = TextField(lazy_gettext("LMS login"), validators=[Required()])
    lms_password = PasswordField(lazy_gettext("LMS password"))
    labmanager_login = TextField(lazy_gettext("Labmanager login"),
                                 validators=[Required()])
    labmanager_password = PasswordField(lazy_gettext("Labmanager password"))

    def __init__(self, add_or_edit, *args, **kwargs):
        super(AddLmsForm, self).__init__(*args, **kwargs)
        self.add_or_edit = add_or_edit

    def validate_lms_password(form, field):
        if form.add_or_edit and field.data == '':
            raise ValidationError(gettext("This field is required."))

    def validate_labmanager_password(form, field):
        if form.add_or_edit and field.data == '':
            raise ValidationError(gettext("This field is required."))
Beispiel #33
0
class LaboratoryPanel(L4lModelView):

    can_create = can_edit = False
    column_list = [
        'rlms', 'name', 'laboratory_id', 'visibility', 'availability',
        'public_availability', 'go_lab_reservation', 'test'
    ]
    column_labels = dict(
        rlms=lazy_gettext('rlms'),
        name=lazy_gettext('name'),
        laboratory_id=lazy_gettext('laboratory_id'),
        visibility=lazy_gettext('visibility'),
        availability=lazy_gettext('availability'),
        public_availability=lazy_gettext('public_availability'),
        go_lab_reservation=lazy_gettext('Go-Lab reservation'),
        test=lazy_gettext("Test"))
    column_formatters = dict(availability=accessibility_formatter,
                             public_availability=public_availability_formatter,
                             go_lab_reservation=go_lab_reservation_formatter,
                             test=test_lab_formatter)
    column_descriptions = dict(
        availability=lazy_gettext(
            "Make this laboratory automatically available for the Learning Tools"
        ),
        public_availability=lazy_gettext(
            "Make this laboratory automatically available even from outside the registered Learning Tools"
        ),
        go_lab_reservation=lazy_gettext(
            "Make this laboratory available to Go-Lab booking system"),
        test=lazy_gettext("Test this laboratory"),
    )

    def __init__(self, session, **kwargs):
        super(LaboratoryPanel, self).__init__(Laboratory, session, **kwargs)

    @expose('/lab/availability/local', methods=['POST'])
    def change_accessibility(self):
        lab_id = int(request.form['lab_id'])
        activate = request.form['activate'] == 'true'
        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is not None:
            if activate:
                lab.available = not activate
                lab.default_local_identifier = u""
            else:
                local_id = request.form['default_local_identifier']
                local_id = local_id.lstrip(' ')
                local_id = local_id.strip(' ')
                if not activate and len(local_id) == 0:
                    flash(gettext("Invalid local identifier (empty)"))
                    return redirect(url_for('.index_view'))
                existing_labs = self.session.query(Laboratory).filter_by(
                    default_local_identifier=local_id).all()
                if len(existing_labs) > 0 and lab not in existing_labs:
                    flash(
                        gettext(
                            u"Local identifier '%(localidentifier)s' already exists",
                            localidentifier=local_id))
                    return redirect(url_for('.index_view'))
                lab.available = not activate
                lab.default_local_identifier = local_id
            self.session.add(lab)
            self.session.commit()
        return redirect(url_for('.index_view'))

    @expose('/lab/test/')
    def test_lab(self):
        lab_id = request.args.get('id')
        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is None:
            return "Laboratory id not found", 404

        return self.render("labmanager_admin/test-lab.html", lab=lab)

    @expose('/lab/test/display/')
    def display_lab(self):
        try:
            lab_id = int(request.args.get('id', '-1'))
        except ValueError:
            return "id must be an integer", 400

        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is None:
            return "Laboratory id not found", 404

        return self.render("labmanager_admin/display_lab.html", laboratory=lab)

    @expose('/lab/test/launch/', methods=['POST'])
    def launch_lab(self):
        lab_id = request.args.get('id')
        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is None:
            return "Laboratory id not found", 404

        db_rlms = lab.rlms
        ManagerClass = get_manager_class(db_rlms.kind, db_rlms.version,
                                         db_rlms.id)
        remote_laboratory = ManagerClass(db_rlms.configuration)
        back_url = url_for('.display_lab', id=lab_id)
        try:
            response = remote_laboratory.reserve(
                lab.laboratory_id,
                current_user.login,
                "admin-panel",
                "{}", [], {}, {
                    'user_agent': unicode(request.user_agent),
                    'from_ip': remote_addr(),
                    'referer': request.referrer,
                },
                back_url=back_url,
                debug=True)

            load_url = response['load_url']
        except Exception as e:
            flash(
                gettext(
                    "There was a problem testing this experiment. Error message: %s"
                    % e))
            return redirect(back_url)
        return redirect(load_url)

    @expose('/lab/availability/public', methods=['POST'])
    def change_public_availability(self):
        lab_id = int(request.form['lab_id'])
        activate = request.form['activate'] == "true"
        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is not None:
            if activate:
                lab.publicly_available = not activate
                lab.public_identifier = u""
            else:
                public_id = request.form['public_identifier']
                public_id = public_id.lstrip(' ')
                public_id = public_id.strip(' ')
                if not activate and len(public_id) == 0:
                    flash(gettext("Invalid public identifier (empty)"))
                    return redirect(url_for('.index_view'))
                existing_labs = self.session.query(Laboratory).filter_by(
                    public_identifier=public_id).all()
                if len(existing_labs) > 0 and lab not in existing_labs:
                    flash(
                        gettext(
                            u"Public identifier '%(publicidentifier)s' already exists",
                            publicidentifier=public_id))
                    return redirect(url_for('.index_view'))
                lab.publicly_available = not activate
                lab.public_identifier = public_id
            self.session.add(lab)
            self.session.commit()
        return redirect(url_for('.index_view'))

    @expose('/lab/golabreservation', methods=['POST'])
    def change_go_lab_reservation(self):
        lab_id = int(request.form['lab_id'])
        activate = request.form['activate'] == 'true'
        lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
        if lab is not None:
            if activate:
                lab.go_lab_reservation = not activate
            else:
                lab.go_lab_reservation = not activate
            self.session.add(lab)
            self.session.commit()
        return redirect(url_for('.index_view'))
Beispiel #34
0
def test_lab_formatter(v, c, lab, p):
    return Markup(
        """<label>%s</label><a class='btn btn-success' href="%s">%s</a>""" %
        (lazy_gettext("Test laboratory"), url_for(
            '.test_lab', id=lab.id), lazy_gettext("Test")))
Beispiel #35
0
def init_instructor_admin(app):
    lms_instructor_url = '/lms_instructor'
    lms_instructor = Admin(index_view = LmsInstructorPanel(url=lms_instructor_url, endpoint = 'lms_instructor'), name = lazy_gettext(u'LMS instructor'), url = lms_instructor_url, endpoint = 'lms-instructor')
    lms_instructor.add_view(PermissionToLmsUserPanel(db.session, name     = lazy_gettext(u'Permissions'), endpoint = 'lms_instructor_permissions', url = 'permissions'))
    lms_instructor.add_view(RedirectView('logout',         name = lazy_gettext(u'Log out'), endpoint = 'lms_instructor_logout', url = 'logout'))
    lms_instructor.init_app(app)
Beispiel #36
0
def test_lab_formatter(v, c, lab, p):
    return Markup("""<label>%s</label><a class='btn btn-success' href="%s">%s</a>""" % (lazy_gettext("Test laboratory"), url_for('.test_lab', id = lab.id), lazy_gettext("Test")))
Beispiel #37
0
def init_admin(app):
    admin_url = '/admin'
    admin = Admin(index_view = AdminPanel(url=admin_url), name = lazy_gettext(u"Lab Manager"), url = admin_url, endpoint = admin_url)
    i18n_LMSmngmt = lazy_gettext(u'LT Management')
    admin.add_view(LTPanel(db.session,        category = i18n_LMSmngmt, name = lazy_gettext(u"LT"),     endpoint = 'lt/lt'))
    admin.add_view(PermissionToLtPanel(db.session, category = i18n_LMSmngmt, name = lazy_gettext(u"LT Permissions"),    endpoint = 'lt/permissions'))
    admin.add_view(LtUsersPanel(db.session,   category = i18n_LMSmngmt, name = lazy_gettext(u"LT Users"),        endpoint = 'lt/users'))
    admin.add_view(LabRequestsPanel(db.session,   category = i18n_LMSmngmt, name = lazy_gettext(u"LT Requests"),        endpoint = 'lt/requests'))
    i18n_ReLMSmngmt = lazy_gettext(u'ReLMS Management')
    admin.add_view(RLMSPanel(db.session,       category = i18n_ReLMSmngmt, name = lazy_gettext(u"RLMS"),            endpoint = 'rlms/rlms'))
    admin.add_view(LaboratoryPanel(db.session, category = i18n_ReLMSmngmt, name = lazy_gettext(u"Registered labs"), endpoint = 'rlms/labs'))
    admin.add_view(UsersPanel(db.session,      category = lazy_gettext(u'Users'), name = lazy_gettext(u"Labmanager Users"), endpoint = 'users/labmanager'))
    if app.config.get('GOLAB'):
        admin.add_view(EmbedApplicationsPanel(db.session, category="Go-Lab", name="Embed Apps", endpoint='golab/embed'))
        admin.add_view(GoLabUsersPanel(db.session, category="Go-Lab", name="Go-Lab users", endpoint='golab/users'))
    admin.add_view(RedirectView('logout',      name = lazy_gettext(u"Log out"), endpoint = 'admin/logout'))
    admin.init_app(app)
Beispiel #38
0
 def create_model(self, form):
     if form.password.data == '':
         form.password.errors.append(lazy_gettext("This field is required."))
         return False
     form.password.data = unicode(new_hash(ALGORITHM, form.password.data.encode('utf8')).hexdigest())
     return super(LmsUsersPanel, self).create_model(form)