Introduced a PgAdmin class inherited from the Flask, which looks for

submodules inherited from the PgAdminModule instead of regular
Blueprint. This allows us to load the module automatically from the
under the pgadmin directory, and will work to extend the pgAdmin
extension module.

PgAdminModule is inherited from the Blueprint, and bring several
methods:
-  get_own_stylesheets, which returns the stylesheets used by the module
   (excluding its submodules stylesheets)
- get_own_javascripts
- menu_items, which returns a dictionray mapping the old hook names
  (context_items etc) to a list of MenuItem instances

For more specialized modules (as for now, any module that should be part
of the browser tree construction), one can define an abstract base class
defining additional methods.

For example, the BrowserPluginModule abstract base class defines the
following methods:
- jssnippets
- csssnipeets
- node_type
- get_nodes
This commit is contained in:
Ronan Dunklau
2015-06-29 12:28:41 +05:30
committed by Ashesh Vashi
parent 9e0b011ec8
commit eb6580b43a
25 changed files with 876 additions and 943 deletions

View File

@@ -0,0 +1,19 @@
from pgadmin import PgAdminModule
from flask.ext.security import login_required
from flask import redirect, url_for
MODULE_NAME = 'redirects'
blueprint = PgAdminModule(MODULE_NAME, __name__,
url_prefix='/')
@blueprint.route('/')
@login_required
def index():
"""Redirect users hitting the root to the browser"""
return redirect(url_for('browser.index'))
@blueprint.route('/favicon.ico')
def favicon():
"""Redirect to the favicon"""
return redirect(url_for('static', filename='favicon.ico'))

View File

@@ -1,29 +0,0 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2015, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
"""A blueprint module providing URL redirects."""
MODULE_NAME = 'redirects'
import config
from flask import Blueprint, redirect, url_for
from flask.ext.security import login_required
# Initialise the module
blueprint = Blueprint(MODULE_NAME, __name__)
@blueprint.route('/')
@login_required
def index():
"""Redirect users hitting the root to the browser"""
return redirect(url_for('browser.index'))
@blueprint.route('/favicon.ico')
def favicon():
"""Redirect to the favicon"""
return redirect(url_for('static', filename='favicon.ico'))