Esempio n. 1
0
 def decorator(cls):
     if 'category' not in kwargs:
         kwargs['category'] = cls.__module__.rsplit('.', 1)[-1].capitalize()
     admin_views.add_view(cls(**kwargs))
     return cls
Esempio n. 2
0
    @expose('callback')
    def callback(self):
        try:
            _verify_oauth_callback(request.args['code'], request.args['state'])
        except Exception as e:
            if request.args.get('error') == 'access_denied':
                error = 'Access was denied'
            else:
                error = e.message or e.description or str(e) or 'unknown error'
            return self.render('admin/auth.html', error=error)
        else:
            next = session.pop('_auth_next', None) or url_for('admin.index')
            return redirect(next)


admin_views.add_view(AdminAuthView(url='/admin/oauth2'))


class AdminView(BaseView):

    def is_accessible(self):
        if 'admin_user' in session:
            return True
        else:
            session['_auth_next'] = request.full_path
            raise AuthRedirect(_get_google_auth_url())


class AdminModelView(ModelView, AdminView):

    model = None