Inherited the test, about & help module from PgAdminModule class to load

them automatically by PgAdmin.
This commit is contained in:
Ronan Dunklau
2015-06-29 13:24:05 +05:30
committed by Ashesh Vashi
parent eb6580b43a
commit b626eec0fd
15 changed files with 280 additions and 267 deletions

View File

@@ -0,0 +1,67 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2015, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
"""A blueprint module implementing the about box."""
MODULE_NAME = 'about'
from pgadmin.utils import PgAdminModule
from pgadmin.utils.menu import MenuItem
from flask import Response, current_app, render_template, __version__, url_for
from flask.ext.babel import gettext
from flask.ext.security import current_user, login_required
import sys
import config
class AboutModule(PgAdminModule):
def get_own_menuitems(self):
return {
'help_items': [
MenuItem(name='mnu_about',
priority=999,
url='#',
onclick='about_show()',
label=gettext('About %(appname)s', appname=config.APP_NAME))
]
}
def get_own_javascripts(self):
return [url_for('about.script')]
blueprint = AboutModule(MODULE_NAME, __name__,
static_url_path='')
##########################################################################
# A test page
##########################################################################
@blueprint.route("/")
@login_required
def index():
"""Render the about box."""
info = { }
info['python_version'] = sys.version
info['flask_version'] = __version__
if config.SERVER_MODE == True:
info['app_mode'] = gettext('Server')
else:
info['app_mode'] = gettext('Desktop')
info['current_user'] = current_user.email
return render_template(MODULE_NAME + '/index.html', info=info)
@blueprint.route("/about.js")
@login_required
def script():
"""Render the required Javascript"""
return Response(response=render_template("about/about.js"),
status=200,
mimetype="application/javascript")

View File

@@ -1,28 +0,0 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2015, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
"""Browser integration functions for the About module."""
from flask import render_template, url_for
from flask.ext.babel import gettext
import config
def get_help_menu_items():
"""Return a (set) of dicts of help menu items, with name, priority, URL,
target and onclick code."""
return [{'name': 'mnu_about',
'label': gettext('About %(appname)s', appname=config.APP_NAME),
'priority': 999,
'url': "#",
'onclick': "about_show()"}]
def get_scripts():
"""Return a list of script URLs to include in the rendered page header"""
return [ url_for('about.script') ]

View File

@@ -1,48 +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 implementing the about box."""
MODULE_NAME = 'about'
from flask import Blueprint, Response, current_app, render_template, __version__
from flask.ext.babel import gettext
from flask.ext.security import current_user, login_required
import sys
import config
# Initialise the module
blueprint = Blueprint(MODULE_NAME, __name__, static_folder='static', static_url_path='', template_folder='templates', url_prefix='/' + MODULE_NAME)
##########################################################################
# A test page
##########################################################################
@blueprint.route("/")
@login_required
def index():
"""Render the about box."""
info = { }
info['python_version'] = sys.version
info['flask_version'] = __version__
if config.SERVER_MODE == True:
info['app_mode'] = gettext('Server')
else:
info['app_mode'] = gettext('Desktop')
info['current_user'] = current_user.email
return render_template(MODULE_NAME + '/index.html', info=info)
@blueprint.route("/about.js")
@login_required
def script():
"""Render the required Javascript"""
return Response(response=render_template("about/about.js"),
status=200,
mimetype="application/javascript")