Update message to show release instead of commits for master and beta

This commit is contained in:
JonnyWong16 2018-02-18 08:28:44 -08:00
parent d473bb3058
commit cbcdac5b04
5 changed files with 45 additions and 14 deletions

View file

@ -47,10 +47,16 @@
You are running an unknown version of Tautulli.<br /> You are running an unknown version of Tautulli.<br />
<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a> <a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>
</div> </div>
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win': % elif plexpy.CONFIG.CHECK_GITHUB and plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and plexpy.common.VERSION_NUMBER != plexpy.LATEST_RELEASE:
<div id="updatebar" style="display: none;">
A <a href="${anon_url('https://github.com/%s/%s/releases/tag/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.LATEST_RELEASE))}" target="_blank">
new release (${plexpy.LATEST_RELEASE})</a> of Tautulli is available!<br />
<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>
</div>
% elif plexpy.CONFIG.CHECK_GITHUB and plexpy.COMMITS_BEHIND > 0 and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.INSTALL_TYPE != 'win':
<div id="updatebar" style="display: none;"> <div id="updatebar" style="display: none;">
A <a href="${anon_url('https://github.com/%s/%s/compare/%s...%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION, plexpy.LATEST_VERSION))}" target="_blank"> A <a href="${anon_url('https://github.com/%s/%s/compare/%s...%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION, plexpy.LATEST_VERSION))}" target="_blank">
newer version</a> is available!<br /> newer version</a> of Tautulli is available!<br />
You are ${plexpy.COMMITS_BEHIND} commits behind.<br /> You are ${plexpy.COMMITS_BEHIND} commits behind.<br />
<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a> <a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>
</div> </div>
@ -311,17 +317,21 @@ ${next.modalIncludes()}
complete: function (xhr, status) { complete: function (xhr, status) {
var result = $.parseJSON(xhr.responseText); var result = $.parseJSON(xhr.responseText);
var msg = ''; var msg = '';
if (result.update === true) { if (result.update === null) {
msg = 'A <a href="' + result.compare_url + '" target="_blank">newer version</a> is available!<br />' + msg = 'You are running an unknown version of Tautulli.<br />' +
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>';
$('#updatebar').html(msg).fadeIn();
} else if (result.update === true && result.release === true) {
msg = 'A <a href="' + result.release_url + '" target="_blank">new release (' + result.latest_release + ')</a> of Tautulli is available!<br />' +
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>';
$('#updatebar').html(msg).fadeIn();
} else if (result.update === true && result.release === false) {
msg = 'A <a href="' + result.compare_url + '" target="_blank">newer version</a> of Tautulli is available!<br />' +
'You are '+ result.commits_behind + ' commits behind.<br />' + 'You are '+ result.commits_behind + ' commits behind.<br />' +
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>'; '<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>';
$('#updatebar').html(msg).fadeIn(); $('#updatebar').html(msg).fadeIn();
} else if (result.update === false) { } else if (result.update === false) {
showMsg('<i class="fa fa-check"></i> ' + result.message, false, true, 2000); showMsg('<i class="fa fa-check"></i> ' + result.message, false, true, 2000);
} else if (result.update === null) {
msg = 'You are running an unknown version of Tautulli.<br />' +
'<a href="update">Update</a> or <a href="#" id="updateDismiss">Dismiss</a>';
$('#updatebar').html(msg).fadeIn();
} }
if (_callback) { if (_callback) {

View file

@ -85,6 +85,7 @@ CURRENT_VERSION = None
LATEST_VERSION = None LATEST_VERSION = None
COMMITS_BEHIND = None COMMITS_BEHIND = None
PREV_RELEASE = None PREV_RELEASE = None
LATEST_RELEASE = None
UMASK = None UMASK = None

View file

@ -907,6 +907,7 @@ def build_server_notify_params(notify_action=None, **kwargs):
'update_changelog_fixed': pms_download_info['changelog_fixed'], 'update_changelog_fixed': pms_download_info['changelog_fixed'],
# Tautulli update parameters # Tautulli update parameters
'tautulli_update_version': plexpy_download_info['tag_name'], 'tautulli_update_version': plexpy_download_info['tag_name'],
'tautulli_update_release_url': plexpy_download_info['html_url'],
'tautulli_update_tar': plexpy_download_info['tarball_url'], 'tautulli_update_tar': plexpy_download_info['tarball_url'],
'tautulli_update_zip': plexpy_download_info['zipball_url'], 'tautulli_update_zip': plexpy_download_info['zipball_url'],
'tautulli_update_commit': kwargs.pop('plexpy_update_commit', ''), 'tautulli_update_commit': kwargs.pop('plexpy_update_commit', ''),

View file

@ -196,6 +196,8 @@ def checkGithub(auto_update=False):
else: else:
release = releases[0] release = releases[0]
plexpy.LATEST_RELEASE = release['tag_name']
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_plexpyupdate', 'plexpy_download_info': release, plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_plexpyupdate', 'plexpy_download_info': release,
'plexpy_update_commit': plexpy.LATEST_VERSION, 'plexpy_update_behind': plexpy.COMMITS_BEHIND}) 'plexpy_update_commit': plexpy.LATEST_VERSION, 'plexpy_update_behind': plexpy.COMMITS_BEHIND})

View file

@ -3543,14 +3543,30 @@ class WebInterface(object):
if not plexpy.CURRENT_VERSION: if not plexpy.CURRENT_VERSION:
return {'result': 'error', return {'result': 'error',
'message': 'You are running an unknown version of Tautulli.', 'update': None,
'update': None} 'message': 'You are running an unknown version of Tautulli.'
}
elif plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and \ elif plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and \
plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win': plexpy.common.VERSION_NUMBER != plexpy.LATEST_RELEASE:
return {'result': 'success', return {'result': 'success',
'update': True, 'update': True,
'message': 'An update for Tautulli is available.', 'release': True,
'message': 'A new release (%) of Tautulli is available.' % plexpy.LATEST_RELEASE,
'latest_release': plexpy.LATEST_RELEASE,
'release_url': helpers.anon_url(
'https://github.com/%s/%s/releases/tag/%s'
% (plexpy.CONFIG.GIT_USER,
plexpy.CONFIG.GIT_REPO,
plexpy.LATEST_RELEASE))
}
elif plexpy.COMMITS_BEHIND > 0 and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and \
plexpy.INSTALL_TYPE != 'win':
return {'result': 'success',
'update': True,
'release': False,
'message': 'A newer version of Tautulli is available.',
'latest_version': plexpy.LATEST_VERSION, 'latest_version': plexpy.LATEST_VERSION,
'commits_behind': plexpy.COMMITS_BEHIND, 'commits_behind': plexpy.COMMITS_BEHIND,
'compare_url': helpers.anon_url( 'compare_url': helpers.anon_url(
@ -3564,7 +3580,8 @@ class WebInterface(object):
else: else:
return {'result': 'success', return {'result': 'success',
'update': False, 'update': False,
'message': 'Tautulli is up to date.'} 'message': 'Tautulli is up to date.'
}
@cherrypy.expose @cherrypy.expose
@requireAuth(member_of("admin")) @requireAuth(member_of("admin"))