Beispiel #1
0
        'children',
    ]
    column_filters = [
        'id',
        'name',
        'parent',
    ]

    # override the 'render' method to pass your own parameters to the template
    def render(self, template, **kwargs):
        return super(TreeView, self).render(template, foo="bar", **kwargs)


# Create admin
admin = admin.Admin(app,
                    name='Example: SQLAlchemy',
                    template_mode='bootstrap4')

# Add views
admin.add_view(UserAdmin(User, db.session))
admin.add_view(sqla.ModelView(Tag, db.session))
# The "Post" model gets added in the overriddent __init__(self, Post, session)
admin.add_view(PostAdmin(db.session))
admin.add_view(TreeView(Tree, db.session, category="Other"))
admin.add_sub_category(name="Links", parent_name="Other")
admin.add_link(MenuLink(name='Back Home', url='/', category='Links'))
admin.add_link(
    MenuLink(name='External link',
             url='http://www.example.com/',
             category='Links'))
Beispiel #2
0
admin.add_view(
    ServerView(Server, db.session, name='Servers', category='Config'))
admin.add_view(
    TestResultStatusView(TestResultStatus,
                         db.session,
                         name='Statuses',
                         category='Config'))
admin.add_view(TagView(Tag, db.session, name='Tags', category='Config'))
admin.add_view(
    TestPlanView(TestPlan, db.session, name='Test Plans', category='Config'))
admin.add_view(UserAdmin(User, db.session, name='Users', category='Config'))

#admin.add_view(AccountLogoutView(name='Logout', endpoint='account_logout', category='Account'))
admin.add_view(
    AccountView(name='User', endpoint='account_user', category='Account'))
admin.add_link(LogoutMenuLink(name='Logout', category='', url="/logout"))
admin.add_link(
    LoginMenuLink(name='Login', category='', url="/login?next=/admin/"))

admin.add_view(
    OnlineHelpView(name='Online Help', endpoint='online_help',
                   category='Help'))
admin.add_view(AboutView(name='About', endpoint='help_about', category='Help'))

#proxyfix in case you are running your site on a non-standard port/proxying.
app.wsgi_app = ProxyFix(app.wsgi_app)

if __name__ == '__main__':
    app_dir = op.realpath(os.path.dirname(__file__))
    # Start app
    app.run(debug=True)
Beispiel #3
0
    can_create = False
    column_list = [
        'username',
        'firstname',
        'lastname',
        'email',
    ]

    def is_accessible(self):
        if session.get('logged_out'):
            return False
        if session.get('logged_in'):
            return True


admin = admin.Admin(app,
                    name='Admin',
                    index_view=MyAdminIndexView(name=' '),
                    url='/admin')
admin.add_view(UserModelView(User, db.session, url='/user'))
admin.add_link(MenuLink(name='Logout', category='', url="/logout"))
admin.add_link(MenuLink(name='Send Message', category='', url="/message"))
api.add_resource(NamesResource, '/api/names/')
api.add_resource(UserResource, '/api/users/')
api.add_resource(Applogin, '/api/login/')
api.add_resource(LocationResource, '/api/location/')
api.add_resource(StatusResource, '/api/status/')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7000, debug=True)
Beispiel #4
0

class TreeView(sqla.ModelView):
    form_excluded_columns = ['children', ]


# Create admin
admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap3')

# Add views
admin.add_view(UserAdmin(User, db.session))
admin.add_view(sqla.ModelView(Tag, db.session))
admin.add_view(PostAdmin(db.session))
admin.add_view(TreeView(Tree, db.session, category="Other"))
admin.add_sub_category(name="Links", parent_name="Other")
admin.add_link(MenuLink(name='Back Home', url='/', category='Links'))
admin.add_link(MenuLink(name='Google', url='http://www.google.com/', category='Links'))
admin.add_link(MenuLink(name='Mozilla', url='http://mozilla.org/', category='Links'))


def build_sample_db():
    """
    Populate a small db with some example entries.
    """

    import random
    import datetime

    db.drop_all()
    db.create_all()
Beispiel #5
0
def create_app():

    app = Flask(__name__,
                static_url_path='/static',
                static_folder='static',
                template_folder='templates',
                instance_relative_config=True)
    app.config.from_object(config.Config)

    db.init_app(app)

    user_datastore = SQLAlchemyUserDatastore(db, User, Role)

    security = Security(app, user_datastore, login_form=LoginForm)
    babel = Babel(app, default_locale='ru')

    with app.test_request_context():
        if not os.path.isfile(
                app.config.get('SQLALCHEMY_DATABASE_URI').replace(
                    'sqlite:///', '')):
            db.create_all()

            admin_role = Role('admin')
            db.session.add(admin_role)
            db.session.commit()

            linux = OperationSystemType('Linux')
            windows = OperationSystemType('Windows')
            db.session.add_all([linux, windows])
            db.session.commit()

            ct_agent = Agent('CerediraTess', windows)
            ct_agent.add_role(admin_role)
            db.session.add(ct_agent)
            db.session.commit()

            user_datastore.create_user(email='*****@*****.**',
                                       password=hash_password("admin"),
                                       roles=[admin_role],
                                       username='******')
            db.session.commit()

    with app.app_context():
        import flask_admin as admin
        # Create admin
        admin = admin.Admin(app,
                            'CerediraTess',
                            template_mode='bootstrap4',
                            index_view=MyAdminIndexView(),
                            base_template='my_master.html',
                            static_url_path='../static')

        admin.add_link(
            MenuLink(name='Выполнение запросов',
                     category='',
                     url='/CerediraTess.html'))
        admin.add_link(
            MenuLink(name='Блокировка агентов',
                     category='',
                     url='/AgentLocker.html'))

        admin.add_view(
            UserModelView(User,
                          db.session,
                          endpoint='User',
                          name='Пользователи'))
        admin.add_view(
            RoleModelView(Role, db.session, endpoint='Role', name='Роли'))
        admin.add_view(
            OperationSystemTypeModelView(OperationSystemType,
                                         db.session,
                                         endpoint='OperationSystemType',
                                         name='Типы ОС'))
        admin.add_view(
            AgentModelView(Agent, db.session, endpoint='Agent', name='Агенты'))
        admin.add_view(
            ScriptModelView(Script,
                            db.session,
                            endpoint='Script',
                            name='Скрипты'))

        from ceredira_tess.commons import app as app2
        app.register_blueprint(app2)

    @babel.localeselector
    def get_locale():
        # Put your logic here. Application can store locale in
        # user profile, cookie, session, etc.
        return 'ru'

    @app.context_processor
    def inject_url():
        return dict(admin_view=admin.index_view, get_url=url_for, role=Role)

    @security.context_processor
    def security_context_processor():
        return dict(admin_base_template=admin.base_template,
                    admin_view=admin.index_view,
                    h=helpers,
                    get_url=url_for,
                    role=Role)

    return app
Beispiel #6
0
    column_filters = ('number_of_pixels', )


# Create admin
admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap3')

# Add views
admin.add_view(UserAdmin(User, db.session))
admin.add_view(sqla.ModelView(Tag, db.session))
admin.add_view(PostAdmin(db.session))
admin.add_view(sqla.ModelView(Pet, db.session, category="Other"))
admin.add_view(sqla.ModelView(UserInfo, db.session, category="Other"))
admin.add_view(TreeView(Tree, db.session, category="Other"))
admin.add_view(ScreenView(Screen, db.session, category="Other"))
admin.add_sub_category(name="Links", parent_name="Other")
admin.add_link(MenuLink(name='Back Home', url='/', category='Links'))
admin.add_link(MenuLink(name='Google', url='http://www.google.com/', category='Links'))
admin.add_link(MenuLink(name='Mozilla', url='http://mozilla.org/', category='Links'))


def build_sample_db():
    """
    Populate a small db with some example entries.
    """

    import random
    import datetime

    db.drop_all()
    db.create_all()
Beispiel #7
0
        return "{}".format(self.name)


# 创建视图
@app.route('/')
def index():
    return '<a href="/admin/">点击这里来到管理后台</a>'


admin = admin.Admin(app,
                    name='Example: SQLAlchemy',
                    template_mode='bootstrap3')

# 添加导航视图
admin.add_view(sqla.ModelView(Tag, db.session))
admin.add_link(MenuLink(name='Back Home', url='/', category='Links'))
admin.add_link(
    MenuLink(name='百度', url='http://www.baidu.com/', category='Links'))
admin.add_link(
    MenuLink(name='书创文化', url='http://www.toppr.net/', category='Links'))


def build_sample_db():
    db.drop_all()
    db.create_all()

    # 在数据库中添加几个数值
    tag_list = []
    for tmp in [
            "YELLOW", "WHITE", "BLUE", "GREEN", "RED", "BLACK", "BROWN",
            "PURPLE", "ORANGE"
Beispiel #8
0
        "tags": {
            "fields": (Tag.name, ),
            "minimum_input_length": 0,
            "placeholder": "Please select",
            "page_size": 5,
        },
    }

    def __init__(self, session):
        super(BookAdmin, self).__init__(Book, session)


admin = admin.Admin(app,
                    name="Desktop Database Application",
                    template_mode="bootstrap3")
admin.add_view(AuthorAdmin(Author, db.session))
admin.add_view(BookAdmin(db.session))
admin.add_view(sqla.ModelView(Tag, db.session))
admin.add_sub_category(name="Links", parent_name="Other")
admin.add_link(MenuLink(name="Admin Home", url="/admin", category="Links"))
admin.add_link(
    MenuLink(
        name="Library and Archives Canada",
        url="https://www.bac-lac.gc.ca/eng/Pages/home.aspx",
        category="Links",
    ))
admin.add_link(
    MenuLink(name="Library of Congress",
             url="https://loc.gov/",
             category="Links"))
Beispiel #9
0
    ]
    def is_accessible(self):
        try :
            return current_user.is_admin
        except :
            False
    
class IndexAdmin(admin.AdminIndexView) :
    @expose('/')
    def index(self):
        if request.method == "GET" :
            if not current_user.is_authenticated :
                return redirect(url_for('index'))
            elif current_user.is_anonymous :
                return redirect(url_for('index'))
            elif current_user.is_admin :
                return self.render('index.html')
            else :
                return redirect(url_for('index'))

admin = admin.Admin(app,index_view=IndexAdmin(), name ='WhyDoThat Admin page', template_mode='bootstrap4')

admin.add_view(UserAdmin(User,db.session))
admin.add_view(JobDetailAdmin(JobDetail,db.session))
admin.add_view(CompanyInfoAdmin(CompanyInfo,db.session))
admin.add_view(sqla.ModelView(JobSector,db.session))
admin.add_view(sqla.ModelView(JobSkill,db.session))
admin.add_view(sqla.ModelView(Resume,db.session,category='Other'))
admin.add_sub_category(name="Links", parent_name="Other")
admin.add_link(MenuLink(name='Back Home', url='/', category='Links'))
admin.add_link(MenuLink(name='Logout', url='/api/logout', category='Links'))
Beispiel #10
0
                    'create_date', 'modified_date', 'login_date')

    excluded_list_columns = ('password', 'create_date', 'modified_date',
                             'login_date', 'passwordchange')
    column_searchable_list = ('username', 'email')


admin = Admin(app,
              'API ADMIN',
              index_view=AppAdminIndexView(),
              template_mode='bootstrap3')
admin.add_view(AppUserAdmin(User, db_session))
admin.add_view(BaseModelView(News, db_session))
admin.add_view(BaseModelView(StockWatchlist, db_session))
admin.add_view(BaseModelView(ServiceProvider, db_session))
admin.add_link(
    MenuLink(name='Get all data', category='Menu', url='/api/v1/getfulllist/'))
admin.add_link(
    MenuLink(name='Generate new Db', category='Menu', url='/admin/generate/'))
admin.add_link(MenuLink(name='Logout', category='Menu', url='/admin/logout/'))


@myadmins.route("/generate/", methods=["GET"])
def generate_db():
    app.logger.info("Start make db")
    currentsession = get_user_session_by_userid()
    serviceprovider = [
        '3 River Wireless', 'ACS Wireless', 'Alltel', 'AT&T', 'Bell Canada',
        'Bell Canada', 'Bell Mobility (Canada)', 'Bell Mobility',
        'Blue Sky Frog', 'Bluegrass Cellular', 'Boost Mobile', 'BPL Mobile',
        'Carolina West Wireless', 'Cellular One', 'Cellular South',
        'Centennial Wireless', 'CenturyTel', 'Cingular (Now AT&T)', 'Clearnet',
Beispiel #11
0
    
    platform1['users'] = []
    #Use case 1: To test one broadcast message to one user
    if uname != '':
        tuser = {}
        tuser['id'] = uname 
        tuser['name'] = uname 
        platform1['users'].append(tuser)

    platforms.append(platform1)
    
    broadcast_text(platforms, text, image_url, full_size, suggested_responses)

    return '<a href="/admin/">Click to get to Admin!</a>'


# Create admin with custom base template
admin = admin.Admin(app, 'Example: Layout', base_template='layout.html')
admin.add_link(MenuLink(name='Replies', url='/admin'))
admin.add_link(MenuLink(name='Widgets', url='/admin'))
admin.add_link(MenuLink(name='Reports', url='/admin'))
admin.add_link(MenuLink(name='Alerts', url='/admin'))
admin.add_link(MenuLink(name='Support', url='/admin'))

# Add views
admin.add_view(BotAdmin(Bot, db.session))
admin.add_view(BroadcastAdmin(Broadcast, db.session))

if __name__ == '__main__':
    app.run(debug=True)
Beispiel #12
0
    can_edit = True
    can_create = True


if __name__ == '__main__':
    admin = admin.Admin(app,
                        name='Telemarie Recipients',
                        index_view=MyAdminIndexView(name=' '),
                        url='/admin')
    admin.add_view(UserModelView(User, db.session, url='/user'))
    admin.add_view(
        TelemarieView(Telemarie,
                      db.session,
                      endpoint="/telemarie",
                      url="/telemarie"))
    admin.add_view(
        TelemarieView(Switch,
                      db.session,
                      endpoint="/recipeint",
                      url="/recipeint"))
    admin.add_view(
        TelemarieView(Recipient, db.session, endpoint="/switch",
                      url="/switch"))
    # admin.add_view(SuperModelView(Super, db.session, url='/super'))
    admin.add_link(MenuLink(name='Send Message', url="/message"))
    admin.add_link(MenuLink(name='Power-Ops', url="/power_ops"))
    admin.add_link(MenuLink(name='Logout', url="/logout"))

    # api.add_resource(RecipientResource, '/api/recipients/')
    app.run(host='0.0.0.0', port=7777, debug=True)
Beispiel #13
0
        flash("Bye " + name + "! U bent succesvol uitgelogd", "success")

        return redirect(url_for(".index"))


### end of admin routes

admin = admin.Admin(
    app,
    name="Panel",
    index_view=MyAdminIndexView(),
    base_template="base_admin.html",
    template_mode="bootstrap3",
)

admin.add_view(SuperUserView(User, db.session,
                             endpoint="superUser"))  # users table
admin.add_view(AdminUserView(User, db.session,
                             endpoint="adminUser"))  # users table

admin.add_view(LayersView(Layers, db.session))  # Layers

admin.add_link(
    MenuLink(name="Go to Atlas",
             category="",
             url=url_root_path,
             target="_blank"))

# EOF
Beispiel #14
0
    form = AddProductFromAdminForm


class UserView(ModelView):
    column_list = ('username', 'email', 'first_name')
    #form_edit_rules = ('password')
    form = UsersForm


class MainIndexLink(MenuLink):
    def get_url(self):
        return url_for("products")


admin = admin.Admin(app, template_mode='bootstrap4', index_view=MyHomeView())
admin.add_link(MainIndexLink(name="Main Page"))
admin.add_view(ProductView(mongo.db.products))
admin.add_view(UserView(mongo.db.customers))


@app.context_processor
def utility_processor():
    def isAdmin():
        return True if 'isAdmin' in session and session[
            "isAdmin"] == "1" else False

    return dict(isAdmin=isAdmin)


@app.errorhandler(404)
def page_not_found(e):
Beispiel #15
0
if __name__ == '__main__':
    init_login()

    # Create admin
    admin = admin.Admin(app, 'Tianguis', index_view=MyAdminIndexView())

    # Add views

    admin.add_view(MyModelView(Marchante))

#    admin.add_view(ModelView(Marchante))
    admin.add_view(ModelView(Anuncio))


    # Add home link by url
    admin.add_link(MenuLink(name='Back Home', url='/'))

    # Add login link by endpoint
    admin.add_link(NotAuthenticatedMenuLink(name='Login',
                                            endpoint='login_view'))

    # Add links with categories
    admin.add_link(MenuLink(name='Google', category='Links', url='http://www.google.com/'))
    admin.add_link(MenuLink(name='Mozilla', category='Links', url='http://mozilla.org/'))

    # Add logout link by endpoint
    admin.add_link(AuthenticatedMenuLink(name='Logout',
                                         endpoint='logout_view'))


    # Start app
Beispiel #16
0
from views.ratingcurve import RatingCurveView
from views.general import LogoutMenuLink, LoginMenuLink, UserModelView

from views.help import HelpView

admin = admin.Admin(name="OpenRiverCam",
                    template_mode="bootstrap4",
                    base_template="base.html",
                    index_view=AdminIndexView(url="/portal",
                                              menu_icon_type="fa",
                                              menu_icon_value="fa-home"))

# Login/logout menu links.
admin.add_link(
    LogoutMenuLink(name="Logout",
                   category="",
                   url="/logout",
                   icon_type="fa",
                   icon_value="fa-user"))
admin.add_link(
    LoginMenuLink(name="Login",
                  category="",
                  url="/login",
                  icon_type="fa",
                  icon_value="fa-user-o"))

# Specific Site view
admin.add_view(
    SiteView(Site,
             db,
             name="Sites",
             url="sites",
Beispiel #17
0

class AuthenticatedMenuLink(MenuLink):
    def is_accessible(self):
        return hasattr(g, 'user')


# Create customized index view class that handles login & registration
class MyAdminIndexView(admin.AdminIndexView):

    @expose('/')
    def index(self):
        if not hasattr(g, 'user'):
            return redirect(url_for('login'))
        return super(MyAdminIndexView, self).index()


# Create admin
admin = admin.Admin(name='Admin', template_mode='bootstrap3', index_view=MyAdminIndexView())
# Add views
admin.add_view(UserAdmin(User, db.session))
admin.add_view(MyModelView(Tag, db.session))
admin.add_view(MyModelView(SourceType, db.session))
admin.add_view(MyModelView(Source, db.session))
admin.add_view(MyModelView(Algorithm, db.session))

admin.add_view(MyModelView(Orn, db.session))
admin.add_view(MyModelView(PersonaProvider, db.session))

admin.add_link(AuthenticatedMenuLink(name="Logout", endpoint="logout"))