Add field to set new profile pic url. Support retrieving only.

This commit is contained in:
James Royal 2015-08-14 23:33:16 -05:00
parent b7baf1a05d
commit 7a7c92191d
3 changed files with 19 additions and 5 deletions

View file

@ -37,6 +37,15 @@ DOCUMENTATION :: END
</div>
<p class="help-block">Replace all occurances of the username with this name.</p>
</div>
<div class="form-group">
<label for="profile_url">Profile Picture URL</label>
<div class="row">
<div class="col-xs-6">
<input type="text" class="form-control" id="profile_url" name="profile_url" value="${data['thumb']}">
</div>
</div>
<p class="help-block">Change the users profile picture in plexpy. You should save the URL if you would like to go back as this replaces the existing one.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="do_notify" name="do_notify" value="1" ${data['do_notify']}> Enable notifications
@ -63,6 +72,7 @@ DOCUMENTATION :: END
// Set new friendly name
$("#save_user_name").click(function() {
var friendly_name = $("#friendly_name").val();
var thumb = $("#profile_url").val();
var do_notify = 0;
var keep_history = 0;
if ($("#do_notify").is(":checked")) {
@ -75,7 +85,7 @@ DOCUMENTATION :: END
% if data['user_id']:
$.ajax({
url: 'edit_user',
data: {user_id: '${data['user_id']}', friendly_name: friendly_name, do_notify: do_notify, keep_history: keep_history},
data: {user_id: '${data['user_id']}', friendly_name: friendly_name, do_notify: do_notify, keep_history: keep_history, thumb: thumb},
cache: false,
async: true,
success: function(data) {
@ -88,7 +98,7 @@ DOCUMENTATION :: END
% else:
$.ajax({
url: 'edit_user',
data: {user: '${data['user']}', friendly_name: friendly_name, do_notify: do_notify, keep_history: keep_history},
data: {user: '${data['user']}', friendly_name: friendly_name, do_notify: do_notify, keep_history: keep_history, thumb: thumb},
cache: false,
async: true,
success: function(data) {

View file

@ -253,13 +253,14 @@ class DataFactory(object):
monitor_db = database.MonitorDatabase()
query = 'select username, ' \
'(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
'do_notify, keep_history ' \
'do_notify, keep_history, thumb ' \
'FROM users WHERE user_id = ?'
result = monitor_db.select(query, args=[user_id])
if result:
user_detail = {'user_id': user_id,
'user': result[0][0],
'friendly_name': result[0][1],
'thumb': result[0][4],
'do_notify': helpers.checked(result[0][2]),
'keep_history': helpers.checked(result[0][3])
}
@ -269,19 +270,21 @@ class DataFactory(object):
'user': '',
'friendly_name': '',
'do_notify': '',
'thumb': '',
'keep_history': ''}
return user_detail
elif user:
monitor_db = database.MonitorDatabase()
query = 'select user_id, ' \
'(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
'do_notify, keep_history ' \
'do_notify, keep_history, thumb ' \
'FROM users WHERE username = ?'
result = monitor_db.select(query, args=[user])
if result:
user_detail = {'user_id': result[0][0],
'user': user,
'friendly_name': result[0][1],
'thumb': result[0][4],
'do_notify': helpers.checked(result[0][2]),
'keep_history': helpers.checked(result[0][3])}
return user_detail
@ -290,6 +293,7 @@ class DataFactory(object):
'user': user,
'friendly_name': '',
'do_notify': '',
'thumb': '',
'keep_history': ''}
return user_detail

View file

@ -173,7 +173,7 @@ class WebInterface(object):
else:
result = None
status_message = 'An error occured.'
print result
return serve_template(templatename="edit_user.html", title="Edit User", data=result, status_message=status_message)
@cherrypy.expose