mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Add undelete button to edit library/user modal
This commit is contained in:
parent
f41ed9953a
commit
24ed63e07c
5 changed files with 93 additions and 55 deletions
|
@ -21,6 +21,7 @@ parent_count Returns the parent item count for the library.
|
||||||
child_count Returns the child item count for the library.
|
child_count Returns the child item count for the library.
|
||||||
do_notify Returns bool value for whether to send notifications for the library.
|
do_notify Returns bool value for whether to send notifications for the library.
|
||||||
keep_history Returns bool value for whether to keep history for the library.
|
keep_history Returns bool value for whether to keep history for the library.
|
||||||
|
deleted_section Returns bool value for whether the library is marked as deleted.
|
||||||
|
|
||||||
DOCUMENTATION :: END
|
DOCUMENTATION :: END
|
||||||
</%doc>
|
</%doc>
|
||||||
|
@ -59,6 +60,12 @@ DOCUMENTATION :: END
|
||||||
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this library. This is permanent!</p>
|
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this library. This is permanent!</p>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
% if data['deleted_section']:
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-bright" id="undelete-library">Undelete</button>
|
||||||
|
<p class="help-block">Click to re-add the library to the Tautulli libraries list.</p>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -100,6 +107,12 @@ DOCUMENTATION :: END
|
||||||
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#undelete-library').click(function () {
|
||||||
|
var msg = 'Are you sure you want to undelete this user?';
|
||||||
|
var url = 'undelete_library';
|
||||||
|
confirmAjaxCall(url, msg, { section_id: '${data["section_id"]}' }, null, function () { location.reload(); });
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Move #confirm-modal to parent container
|
// Move #confirm-modal to parent container
|
||||||
if (!($('#edit-library-modal').next().is('#confirm-modal-purge'))) {
|
if (!($('#edit-library-modal').next().is('#confirm-modal-purge'))) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ is_restricted Returns bool value for whether the user account is restricte
|
||||||
do_notify Returns bool value for whether to send notifications for the user.
|
do_notify Returns bool value for whether to send notifications for the user.
|
||||||
keep_history Returns bool value for whether to keep history for the user.
|
keep_history Returns bool value for whether to keep history for the user.
|
||||||
allow_guest Returns bool value for whether to allow guest access for the user.
|
allow_guest Returns bool value for whether to allow guest access for the user.
|
||||||
|
deleted_user Returns bool value for whether the user is marked as deleted.
|
||||||
|
|
||||||
DOCUMENTATION :: END
|
DOCUMENTATION :: END
|
||||||
</%doc>
|
</%doc>
|
||||||
|
@ -74,6 +75,12 @@ DOCUMENTATION :: END
|
||||||
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this user. This is permanent!</p>
|
<p class="help-block">DANGER ZONE! Click the purge button to remove all history logged for this user. This is permanent!</p>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
% if data['deleted_user']:
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-bright" id="undelete-user">Undelete</button>
|
||||||
|
<p class="help-block">Click to re-add the user to the Tautulli users list.</p>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -122,6 +129,12 @@ DOCUMENTATION :: END
|
||||||
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#undelete-user').click(function () {
|
||||||
|
var msg = 'Are you sure you want to undelete this user?';
|
||||||
|
var url = 'undelete_user';
|
||||||
|
confirmAjaxCall(url, msg, { user_id: '${data["user_id"]}' }, null, function () { location.reload(); });
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Move #confirm-modal-purge to parent container
|
// Move #confirm-modal-purge to parent container
|
||||||
if (!($('#edit-user-modal').next().is('#confirm-modal-purge'))) {
|
if (!($('#edit-user-modal').next().is('#confirm-modal-purge'))) {
|
||||||
|
|
|
@ -690,7 +690,8 @@ class Libraries(object):
|
||||||
'child_count': 0,
|
'child_count': 0,
|
||||||
'do_notify': 0,
|
'do_notify': 0,
|
||||||
'do_notify_created': 0,
|
'do_notify_created': 0,
|
||||||
'keep_history': 1
|
'keep_history': 1,
|
||||||
|
'deleted_section': 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if not section_id:
|
if not section_id:
|
||||||
|
@ -703,7 +704,7 @@ class Libraries(object):
|
||||||
if str(section_id).isdigit():
|
if str(section_id).isdigit():
|
||||||
query = 'SELECT section_id, section_name, section_type, count, parent_count, child_count, ' \
|
query = 'SELECT section_id, section_name, section_type, count, parent_count, child_count, ' \
|
||||||
'thumb AS library_thumb, custom_thumb_url AS custom_thumb, art, ' \
|
'thumb AS library_thumb, custom_thumb_url AS custom_thumb, art, ' \
|
||||||
'do_notify, do_notify_created, keep_history ' \
|
'do_notify, do_notify_created, keep_history, deleted_section ' \
|
||||||
'FROM library_sections ' \
|
'FROM library_sections ' \
|
||||||
'WHERE section_id = ? '
|
'WHERE section_id = ? '
|
||||||
result = monitor_db.select(query, args=[section_id])
|
result = monitor_db.select(query, args=[section_id])
|
||||||
|
@ -733,7 +734,8 @@ class Libraries(object):
|
||||||
'child_count': item['child_count'],
|
'child_count': item['child_count'],
|
||||||
'do_notify': item['do_notify'],
|
'do_notify': item['do_notify'],
|
||||||
'do_notify_created': item['do_notify_created'],
|
'do_notify_created': item['do_notify_created'],
|
||||||
'keep_history': item['keep_history']
|
'keep_history': item['keep_history'],
|
||||||
|
'deleted_section': item['deleted_section']
|
||||||
}
|
}
|
||||||
return library_details
|
return library_details
|
||||||
|
|
||||||
|
@ -924,7 +926,8 @@ class Libraries(object):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
query = 'SELECT section_id, section_name, section_type, agent FROM library_sections WHERE deleted_section = 0'
|
query = 'SELECT section_id, section_name, section_type, agent ' \
|
||||||
|
'FROM library_sections WHERE deleted_section = 0'
|
||||||
result = monitor_db.select(query=query)
|
result = monitor_db.select(query=query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"Tautulli Libraries :: Unable to execute database query for get_sections: %s." % e)
|
logger.warn(u"Tautulli Libraries :: Unable to execute database query for get_sections: %s." % e)
|
||||||
|
@ -1001,23 +1004,31 @@ class Libraries(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if section_id and section_id.isdigit():
|
if section_id and section_id.isdigit():
|
||||||
|
query = 'SELECT * FROM library_sections WHERE section_id = ?'
|
||||||
|
result = monitor_db.select(query=query, args=[section_id])
|
||||||
|
if result:
|
||||||
logger.info(u"Tautulli Libraries :: Re-adding library with id %s to database." % section_id)
|
logger.info(u"Tautulli Libraries :: Re-adding library with id %s to database." % section_id)
|
||||||
monitor_db.action('UPDATE library_sections SET deleted_section = 0 WHERE section_id = ?', [section_id])
|
monitor_db.action('UPDATE library_sections SET deleted_section = 0 WHERE section_id = ?', [section_id])
|
||||||
monitor_db.action('UPDATE library_sections SET keep_history = 1 WHERE section_id = ?', [section_id])
|
monitor_db.action('UPDATE library_sections SET keep_history = 1 WHERE section_id = ?', [section_id])
|
||||||
monitor_db.action('UPDATE library_sections SET do_notify = 1 WHERE section_id = ?', [section_id])
|
monitor_db.action('UPDATE library_sections SET do_notify = 1 WHERE section_id = ?', [section_id])
|
||||||
monitor_db.action('UPDATE library_sections SET do_notify_created = 1 WHERE section_id = ?', [section_id])
|
monitor_db.action('UPDATE library_sections SET do_notify_created = 1 WHERE section_id = ?', [section_id])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
return 'Re-added library with id %s.' % section_id
|
|
||||||
elif section_name:
|
elif section_name:
|
||||||
|
query = 'SELECT * FROM library_sections WHERE section_name = ?'
|
||||||
|
result = monitor_db.select(query=query, args=[section_name])
|
||||||
|
if result:
|
||||||
logger.info(u"Tautulli Libraries :: Re-adding library with name %s to database." % section_name)
|
logger.info(u"Tautulli Libraries :: Re-adding library with name %s to database." % section_name)
|
||||||
monitor_db.action('UPDATE library_sections SET deleted_section = 0 WHERE section_name = ?', [section_name])
|
monitor_db.action('UPDATE library_sections SET deleted_section = 0 WHERE section_name = ?', [section_name])
|
||||||
monitor_db.action('UPDATE library_sections SET keep_history = 1 WHERE section_name = ?', [section_name])
|
monitor_db.action('UPDATE library_sections SET keep_history = 1 WHERE section_name = ?', [section_name])
|
||||||
monitor_db.action('UPDATE library_sections SET do_notify = 1 WHERE section_name = ?', [section_name])
|
monitor_db.action('UPDATE library_sections SET do_notify = 1 WHERE section_name = ?', [section_name])
|
||||||
monitor_db.action('UPDATE library_sections SET do_notify_created = 1 WHERE section_name = ?', [section_name])
|
monitor_db.action('UPDATE library_sections SET do_notify_created = 1 WHERE section_name = ?', [section_name])
|
||||||
|
return True
|
||||||
return 'Re-added library with section_name %s.' % section_name
|
|
||||||
else:
|
else:
|
||||||
return 'Unable to re-add library, section_id or section_name not valid.'
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"Tautulli Libraries :: Unable to execute database query for undelete: %s." % e)
|
logger.warn(u"Tautulli Libraries :: Unable to execute database query for undelete: %s." % e)
|
||||||
|
|
||||||
|
|
|
@ -668,21 +668,29 @@ class Users(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if user_id and str(user_id).isdigit():
|
if user_id and str(user_id).isdigit():
|
||||||
|
query = 'SELECT * FROM users WHERE user_id = ?'
|
||||||
|
result = monitor_db.select(query=query, args=[user_id])
|
||||||
|
if result:
|
||||||
logger.info(u"Tautulli Users :: Re-adding user with id %s to database." % user_id)
|
logger.info(u"Tautulli Users :: Re-adding user with id %s to database." % user_id)
|
||||||
monitor_db.action('UPDATE users SET deleted_user = 0 WHERE user_id = ?', [user_id])
|
monitor_db.action('UPDATE users SET deleted_user = 0 WHERE user_id = ?', [user_id])
|
||||||
monitor_db.action('UPDATE users SET keep_history = 1 WHERE user_id = ?', [user_id])
|
monitor_db.action('UPDATE users SET keep_history = 1 WHERE user_id = ?', [user_id])
|
||||||
monitor_db.action('UPDATE users SET do_notify = 1 WHERE user_id = ?', [user_id])
|
monitor_db.action('UPDATE users SET do_notify = 1 WHERE user_id = ?', [user_id])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
return 'Re-added user with id %s.' % user_id
|
|
||||||
elif username:
|
elif username:
|
||||||
|
query = 'SELECT * FROM users WHERE username = ?'
|
||||||
|
result = monitor_db.select(query=query, args=[username])
|
||||||
|
if result:
|
||||||
logger.info(u"Tautulli Users :: Re-adding user with username %s to database." % username)
|
logger.info(u"Tautulli Users :: Re-adding user with username %s to database." % username)
|
||||||
monitor_db.action('UPDATE users SET deleted_user = 0 WHERE username = ?', [username])
|
monitor_db.action('UPDATE users SET deleted_user = 0 WHERE username = ?', [username])
|
||||||
monitor_db.action('UPDATE users SET keep_history = 1 WHERE username = ?', [username])
|
monitor_db.action('UPDATE users SET keep_history = 1 WHERE username = ?', [username])
|
||||||
monitor_db.action('UPDATE users SET do_notify = 1 WHERE username = ?', [username])
|
monitor_db.action('UPDATE users SET do_notify = 1 WHERE username = ?', [username])
|
||||||
|
return True
|
||||||
return 'Re-added user with username %s.' % username
|
|
||||||
else:
|
else:
|
||||||
return 'Unable to re-add user, user_id or username not valid.'
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"Tautulli Users :: Unable to execute database query for undelete: %s." % e)
|
logger.warn(u"Tautulli Users :: Unable to execute database query for undelete: %s." % e)
|
||||||
|
|
||||||
|
|
|
@ -761,6 +761,7 @@ class WebInterface(object):
|
||||||
json:
|
json:
|
||||||
{"child_count": null,
|
{"child_count": null,
|
||||||
"count": 887,
|
"count": 887,
|
||||||
|
"deleted_section": 0,
|
||||||
"do_notify": 1,
|
"do_notify": 1,
|
||||||
"do_notify_created": 1,
|
"do_notify_created": 1,
|
||||||
"keep_history": 1,
|
"keep_history": 1,
|
||||||
|
@ -949,19 +950,14 @@ class WebInterface(object):
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
library_data = libraries.Libraries()
|
library_data = libraries.Libraries()
|
||||||
|
result = library_data.undelete(section_id=section_id, section_name=section_name)
|
||||||
|
if result:
|
||||||
if section_id:
|
if section_id:
|
||||||
delete_row = library_data.undelete(section_id=section_id)
|
msg ='section_id %s' % section_id
|
||||||
|
|
||||||
if delete_row:
|
|
||||||
return {'message': delete_row}
|
|
||||||
elif section_name:
|
elif section_name:
|
||||||
delete_row = library_data.undelete(section_name=section_name)
|
msg = 'section_name %s' % section_name
|
||||||
|
return {'result': 'success', 'message': 'Re-added library with %s.' % msg}
|
||||||
if delete_row:
|
return {'result': 'error', 'message': 'Unable to re-add library. Invalid section_id or section_name.'}
|
||||||
return {'message': delete_row}
|
|
||||||
else:
|
|
||||||
return {'message': 'no data received'}
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
|
@ -1559,18 +1555,15 @@ class WebInterface(object):
|
||||||
None
|
None
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
user_data = users.Users()
|
||||||
|
result = user_data.undelete(user_id=user_id, username=username)
|
||||||
|
if result:
|
||||||
if user_id:
|
if user_id:
|
||||||
user_data = users.Users()
|
msg ='user_id %s' % user_id
|
||||||
delete_row = user_data.undelete(user_id=user_id)
|
|
||||||
if delete_row:
|
|
||||||
return {'message': delete_row}
|
|
||||||
elif username:
|
elif username:
|
||||||
user_data = users.Users()
|
msg = 'username %s' % username
|
||||||
delete_row = user_data.undelete(username=username)
|
return {'result': 'success', 'message': 'Re-added user with %s.' % msg}
|
||||||
if delete_row:
|
return {'result': 'error', 'message': 'Unable to re-add user. Invalid user_id or username.'}
|
||||||
return {'message': delete_row}
|
|
||||||
else:
|
|
||||||
return {'message': 'no data received'}
|
|
||||||
|
|
||||||
|
|
||||||
##### History #####
|
##### History #####
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue