Add a simple version check mechanism to warn the user if a new release is available.
parent
712f47987f
commit
2a52462dbf
|
@ -172,6 +172,16 @@ SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE = "Your %s password has been reset" \
|
||||||
SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = \
|
SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = \
|
||||||
"Your password for %s has been changed" % APP_NAME
|
"Your password for %s has been changed" % APP_NAME
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Upgrade checks
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
# Check for new versions of the application?
|
||||||
|
UPGRADE_CHECK_ENABLED = True
|
||||||
|
|
||||||
|
# Where should we get the data from?
|
||||||
|
UPGRADE_CHECK_URL = 'http://www.pgadmin.org/versions.json'
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Local config settings
|
# Local config settings
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -12,12 +12,20 @@ from pgadmin import current_blueprint
|
||||||
from pgadmin.utils import PgAdminModule
|
from pgadmin.utils import PgAdminModule
|
||||||
from pgadmin.utils.ajax import make_json_response
|
from pgadmin.utils.ajax import make_json_response
|
||||||
from pgadmin.settings import get_setting
|
from pgadmin.settings import get_setting
|
||||||
from flask import current_app, render_template, url_for, make_response
|
from flask import current_app, render_template, url_for, make_response, \
|
||||||
|
Response, flash
|
||||||
from flask.ext.security import login_required
|
from flask.ext.security import login_required
|
||||||
from flask.ext.login import current_user
|
from flask.ext.login import current_user
|
||||||
from flask.ext.babel import gettext
|
from flask.ext.babel import gettext
|
||||||
from flask_gravatar import Gravatar
|
from flask_gravatar import Gravatar
|
||||||
import six
|
import json, six
|
||||||
|
|
||||||
|
import config
|
||||||
|
|
||||||
|
try:
|
||||||
|
import urllib.request as urlreq
|
||||||
|
except:
|
||||||
|
import urllib as urlreq
|
||||||
|
|
||||||
MODULE_NAME = 'browser'
|
MODULE_NAME = 'browser'
|
||||||
|
|
||||||
|
@ -280,6 +288,34 @@ def index():
|
||||||
force_default=False,
|
force_default=False,
|
||||||
use_ssl=False,
|
use_ssl=False,
|
||||||
base_url=None)
|
base_url=None)
|
||||||
|
|
||||||
|
# Get the current version info from the website, and flash a message if
|
||||||
|
# the user is out of date, and the check is enabled.
|
||||||
|
if config.UPGRADE_CHECK_ENABLED:
|
||||||
|
data = None
|
||||||
|
url = '%s?version=%s' % (config.UPGRADE_CHECK_URL, config.APP_VERSION)
|
||||||
|
current_app.logger.debug('Checking version data at: %s' % url)
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = urlreq.urlopen(url)
|
||||||
|
current_app.logger.debug('Version check HTTP response code: %d' % response.getcode())
|
||||||
|
|
||||||
|
if response.getcode() == 200:
|
||||||
|
data = json.load(response)
|
||||||
|
current_app.logger.debug('Response data: %s' % data)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if data != None:
|
||||||
|
if data['pgadmin4']['version'] != config.APP_VERSION:
|
||||||
|
msg = render_template(MODULE_NAME + "/upgrade.html",
|
||||||
|
current_version=config.APP_VERSION,
|
||||||
|
upgrade_version=data['pgadmin4']['version'],
|
||||||
|
product_name=config.APP_NAME,
|
||||||
|
download_url=data['pgadmin4']['download_url'])
|
||||||
|
|
||||||
|
flash(msg, 'warning')
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
MODULE_NAME + "/index.html",
|
MODULE_NAME + "/index.html",
|
||||||
username=current_user.email,
|
username=current_user.email,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% for category, message in messages %}
|
{% for category, message in messages %}
|
||||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
{{ message }}
|
{{ message|safe }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<p>{{ _('You are currently running version {0} of {1}, however the current version is {2}.').format(current_version, product_name, upgrade_version) }}</p>
|
||||||
|
<p>{{ _('Please click <a class="alert-link" href="{0}" target="_new">here</a> for more information.').format(download_url) }}</p>
|
Loading…
Reference in New Issue