From cbcdac5b04167f24f7fbf85847a63d68efa711dc Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sun, 18 Feb 2018 08:28:44 -0800 Subject: [PATCH] Update message to show release instead of commits for master and beta --- data/interfaces/default/base.html | 26 ++++++++++++++++++-------- plexpy/__init__.py | 1 + plexpy/notification_handler.py | 1 + plexpy/versioncheck.py | 2 ++ plexpy/webserve.py | 29 +++++++++++++++++++++++------ 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html index e3f7923b..9496dc0f 100644 --- a/data/interfaces/default/base.html +++ b/data/interfaces/default/base.html @@ -47,10 +47,16 @@ You are running an unknown version of Tautulli.
Update or Dismiss - % 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: + + % elif plexpy.CONFIG.CHECK_GITHUB and plexpy.COMMITS_BEHIND > 0 and plexpy.CURRENT_VERSION != plexpy.LATEST_VERSION and plexpy.INSTALL_TYPE != 'win': @@ -311,17 +317,21 @@ ${next.modalIncludes()} complete: function (xhr, status) { var result = $.parseJSON(xhr.responseText); var msg = ''; - if (result.update === true) { - msg = 'A newer version is available!
' + + if (result.update === null) { + msg = 'You are running an unknown version of Tautulli.
' + + 'Update or Dismiss'; + $('#updatebar').html(msg).fadeIn(); + } else if (result.update === true && result.release === true) { + msg = 'A new release (' + result.latest_release + ') of Tautulli is available!
' + + 'Update or Dismiss'; + $('#updatebar').html(msg).fadeIn(); + } else if (result.update === true && result.release === false) { + msg = 'A newer version of Tautulli is available!
' + 'You are '+ result.commits_behind + ' commits behind.
' + 'Update or Dismiss'; $('#updatebar').html(msg).fadeIn(); } else if (result.update === false) { showMsg(' ' + result.message, false, true, 2000); - } else if (result.update === null) { - msg = 'You are running an unknown version of Tautulli.
' + - 'Update or Dismiss'; - $('#updatebar').html(msg).fadeIn(); } if (_callback) { diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 169f8756..2212dc0a 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -85,6 +85,7 @@ CURRENT_VERSION = None LATEST_VERSION = None COMMITS_BEHIND = None PREV_RELEASE = None +LATEST_RELEASE = None UMASK = None diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 288bc253..04ae4810 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -907,6 +907,7 @@ def build_server_notify_params(notify_action=None, **kwargs): 'update_changelog_fixed': pms_download_info['changelog_fixed'], # Tautulli update parameters '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_zip': plexpy_download_info['zipball_url'], 'tautulli_update_commit': kwargs.pop('plexpy_update_commit', ''), diff --git a/plexpy/versioncheck.py b/plexpy/versioncheck.py index 6decab1d..6421f6ba 100644 --- a/plexpy/versioncheck.py +++ b/plexpy/versioncheck.py @@ -196,6 +196,8 @@ def checkGithub(auto_update=False): else: release = releases[0] + plexpy.LATEST_RELEASE = release['tag_name'] + plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_plexpyupdate', 'plexpy_download_info': release, 'plexpy_update_commit': plexpy.LATEST_VERSION, 'plexpy_update_behind': plexpy.COMMITS_BEHIND}) diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 5cbfbeda..82c131e5 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -3543,14 +3543,30 @@ class WebInterface(object): if not plexpy.CURRENT_VERSION: 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 \ - plexpy.COMMITS_BEHIND > 0 and plexpy.INSTALL_TYPE != 'win': + elif plexpy.COMMITS_BEHIND > 0 and plexpy.common.BRANCH in ('master', 'beta') and \ + plexpy.common.VERSION_NUMBER != plexpy.LATEST_RELEASE: return {'result': 'success', '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, 'commits_behind': plexpy.COMMITS_BEHIND, 'compare_url': helpers.anon_url( @@ -3564,7 +3580,8 @@ class WebInterface(object): else: return {'result': 'success', 'update': False, - 'message': 'Tautulli is up to date.'} + 'message': 'Tautulli is up to date.' + } @cherrypy.expose @requireAuth(member_of("admin"))