Show changelog on update

This commit is contained in:
JonnyWong16 2016-09-24 11:22:33 -07:00 committed by JonnyWong16
parent ef85fba2e5
commit 354700fcbb
5 changed files with 77 additions and 7 deletions

View file

@ -67,6 +67,23 @@
% endif % endif
% endfor % endfor
</div> </div>
% if _session['user_group'] == 'admin' and config['update_show_changelog']:
<div id="changelog-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="changelog-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title">Changelog</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<input type="button" class="btn btn-bright" data-dismiss="modal" value="Close">
</div>
</div>
</div>
</div>
% endif
</%def> </%def>
<%def name="javascriptIncludes()"> <%def name="javascriptIncludes()">
@ -411,4 +428,21 @@
}); });
</script> </script>
% endif % endif
% if _session['user_group'] == 'admin' and config['update_show_changelog']:
<script>
$.ajax({
url: 'get_changelog',
data: {
latest_only: true,
update_shown: true
},
cache: false,
async: true,
complete: function (xhr, status) {
$("#changelog-modal .modal-body").html(xhr.responseText);
$('#changelog-modal').modal();
}
});
</script>
% endif
</%def> </%def>

View file

@ -4,7 +4,7 @@
import sys import sys
import plexpy import plexpy
from plexpy import common, notifiers, versioncheck from plexpy import common, notifiers
from plexpy.helpers import anon_url from plexpy.helpers import anon_url
available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['name']) available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['name'])
@ -56,7 +56,7 @@
<div role="tabpanel" class="tab-pane active" id="tabs-0"> <div role="tabpanel" class="tab-pane active" id="tabs-0">
% if common.VERSION_NUMBER: % if common.VERSION_NUMBER:
<div class="padded-header"> <div class="padded-header">
<h3>Version ${common.VERSION_NUMBER} <small><a href="#changelog-modal" data-toggle="modal"><i class="fa fa-info-circle"></i> Changelog</a></small></h3> <h3>Version ${common.VERSION_NUMBER} <small><a id="changelog-modal-link" href="#"><i class="fa fa-info-circle"></i> Changelog</a></small></h3>
</div> </div>
% endif % endif
<div class="padded-header"> <div class="padded-header">
@ -2105,9 +2105,9 @@
<h4 class="modal-title">Changelog</h4> <h4 class="modal-title">Changelog</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
${versioncheck.read_changelog() | n}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<input type="button" class="btn btn-bright" data-dismiss="modal" value="Close">
</div> </div>
</div> </div>
</div> </div>
@ -2270,6 +2270,19 @@ $(document).ready(function() {
getConfigurationTable(); getConfigurationTable();
getSchedulerTable(); getSchedulerTable();
$('#changelog-modal-link').on('click', function (e) {
e.preventDefault();
$.ajax({
url: 'get_changelog',
cache: false,
async: true,
complete: function(xhr, status) {
$("#changelog-modal .modal-body").html(xhr.responseText);
$('#changelog-modal').modal();
}
});
});
$("#backup_config").click(function () { $("#backup_config").click(function () {
var msg = 'Are you sure you want to create a backup of the PlexPy config?'; var msg = 'Are you sure you want to create a backup of the PlexPy config?';
var url = 'backup_config'; var url = 'backup_config';

View file

@ -562,6 +562,7 @@ _CONFIG_DEFINITIONS = {
'TWITTER_ON_NEWDEVICE': (int, 'Twitter', 0), 'TWITTER_ON_NEWDEVICE': (int, 'Twitter', 0),
'UPDATE_DB_INTERVAL': (int, 'General', 24), 'UPDATE_DB_INTERVAL': (int, 'General', 24),
'UPDATE_SECTION_IDS': (int, 'General', 1), 'UPDATE_SECTION_IDS': (int, 'General', 1),
'UPDATE_SHOW_CHANGELOG': (int, 'General', 1),
'UPDATE_LABELS': (int, 'General', 1), 'UPDATE_LABELS': (int, 'General', 1),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1), 'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),

View file

@ -246,7 +246,7 @@ def update():
) )
return return
def read_changelog(): def read_changelog(latest_only=False):
changelog_file = os.path.join(plexpy.PROG_DIR, 'CHANGELOG.md') changelog_file = os.path.join(plexpy.PROG_DIR, 'CHANGELOG.md')
@ -260,10 +260,19 @@ def read_changelog():
output = '' output = ''
lines = logfile.readlines() lines = logfile.readlines()
previous_line = '' previous_line = ''
latest_version_found = False
for line in lines: for line in lines:
if line[:2] == '# ': if line[:2] == '# ':
output += '<h3>' + line[2:] + '</h3>' #output += '<h3>' + line[2:] + '</h3>'
pass
elif line[:3] == '## ': elif line[:3] == '## ':
if latest_version_found:
break
elif latest_only:
output += '<h4>PlexPy ' + line[3:] + '</h4>'
latest_version_found = True
else:
output += '<h4>' + line[3:] + '</h4>' output += '<h4>' + line[3:] + '</h4>'
elif line[:2] == '* ' and previous_line.strip() == '': elif line[:2] == '* ' and previous_line.strip() == '':
output += '<ul><li>' + line[2:] + '</li>' output += '<ul><li>' + line[2:] + '</li>'

View file

@ -175,7 +175,8 @@ class WebInterface(object):
"home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS, "home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS,
"home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS, "home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS,
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER, "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
"pms_name": plexpy.CONFIG.PMS_NAME "pms_name": plexpy.CONFIG.PMS_NAME,
"update_show_changelog": plexpy.CONFIG.UPDATE_SHOW_CHANGELOG
} }
return serve_template(templatename="index.html", title="Home", config=config) return serve_template(templatename="index.html", title="Home", config=config)
@ -3235,8 +3236,20 @@ class WebInterface(object):
@cherrypy.expose @cherrypy.expose
@requireAuth(member_of("admin")) @requireAuth(member_of("admin"))
def update(self, **kwargs): def update(self, **kwargs):
# Show changelog after updating
plexpy.CONFIG.__setattr__('UPDATE_SHOW_CHANGELOG', 1)
plexpy.CONFIG.write()
return self.do_state_change('update', 'Updating', 120) return self.do_state_change('update', 'Updating', 120)
@cherrypy.expose
@requireAuth(member_of("admin"))
def get_changelog(self, latest_only=False, update_shown=False, **kwargs):
latest_only = True if latest_only == 'true' else False
# Set update changelog shown status
if update_shown == 'true':
plexpy.CONFIG.__setattr__('UPDATE_SHOW_CHANGELOG', 0)
plexpy.CONFIG.write()
return versioncheck.read_changelog(latest_only=latest_only)
##### Info ##### ##### Info #####