feat(config): Moved delete_allowed
to [bot] section,
Now it works for both command and web interface. Implemented #293.
This commit is contained in:
parent
a034d2a85d
commit
81b78fa8e3
@ -1148,6 +1148,11 @@ def cmd_shortlist(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
def cmd_delete_from_library(bot, user, text, command, parameter):
|
def cmd_delete_from_library(bot, user, text, command, parameter):
|
||||||
global song_shortlist, log
|
global song_shortlist, log
|
||||||
|
|
||||||
|
if not var.config.getboolean("bot", "delete_allowed", fallback=True):
|
||||||
|
bot.mumble.users[text.actor].send_text_message(tr('not_admin'))
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
indexes = [int(i) for i in parameter.split(" ")]
|
indexes = [int(i) for i in parameter.split(" ")]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -95,6 +95,11 @@ port = 64738
|
|||||||
#allow_other_channel_message = False
|
#allow_other_channel_message = False
|
||||||
#allow_private_message = True
|
#allow_private_message = True
|
||||||
|
|
||||||
|
# 'delete_allowed': Allow users to delete a file from the library (hard disk).
|
||||||
|
# Works both for command and web interface. After enabling this option, only
|
||||||
|
# admins are allowed to delete files.
|
||||||
|
#delete_allowded = True
|
||||||
|
|
||||||
# 'save_music_library': If this is set True, the bot will save the metadata of music into the database.
|
# 'save_music_library': If this is set True, the bot will save the metadata of music into the database.
|
||||||
#save_music_library = True
|
#save_music_library = True
|
||||||
|
|
||||||
@ -166,12 +171,11 @@ port = 64738
|
|||||||
# !! YOU NEED TO CHANGE IT IF auth_method IS 'token'!!
|
# !! YOU NEED TO CHANGE IT IF auth_method IS 'token'!!
|
||||||
# flask_secret = ChangeThisPassword
|
# flask_secret = ChangeThisPassword
|
||||||
|
|
||||||
# 'upload_enabled': Enable the upload function of the web interface.
|
# 'upload_enabled': Enable the upload function of the web interface. If disabled,
|
||||||
|
# only admins can upload files.
|
||||||
# 'maximum_upload_file_size': Unit can be 'B', 'KB', 'MB', 'GB', 'TB'.
|
# 'maximum_upload_file_size': Unit can be 'B', 'KB', 'MB', 'GB', 'TB'.
|
||||||
# 'delete_allowed': Allow users to delete a file from the library(hard disk).
|
|
||||||
#upload_enabled = True
|
#upload_enabled = True
|
||||||
#max_upload_file_size = 30MB
|
#max_upload_file_size = 30MB
|
||||||
#delete_allowded = True
|
|
||||||
|
|
||||||
# [debug] stores some debug settings.
|
# [debug] stores some debug settings.
|
||||||
[debug]
|
[debug]
|
||||||
|
@ -563,8 +563,8 @@ def library_info():
|
|||||||
|
|
||||||
return jsonify(dict(
|
return jsonify(dict(
|
||||||
dirs=get_all_dirs(),
|
dirs=get_all_dirs(),
|
||||||
upload_enabled=var.config.getboolean("webinterface", "upload_enabled", fallback=True),
|
upload_enabled=var.config.getboolean("webinterface", "upload_enabled", fallback=True) or var.bot.is_admin(user),
|
||||||
delete_allowed=var.config.getboolean("webinterface", "delete_allowed", fallback=True),
|
delete_allowed=var.config.getboolean("bot", "delete_allowed", fallback=True) or var.bot.is_admin(user),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
max_upload_file_size=max_upload_file_size
|
max_upload_file_size=max_upload_file_size
|
||||||
))
|
))
|
||||||
@ -609,7 +609,7 @@ def library():
|
|||||||
|
|
||||||
return redirect("./", code=302)
|
return redirect("./", code=302)
|
||||||
elif payload['action'] == 'delete':
|
elif payload['action'] == 'delete':
|
||||||
if var.config.getboolean("webinterface", "delete_allowed", fallback=True):
|
if var.config.getboolean("bot", "delete_allowed", fallback=True):
|
||||||
items = dicts_to_items(var.music_db.query_music(condition))
|
items = dicts_to_items(var.music_db.query_music(condition))
|
||||||
for item in items:
|
for item in items:
|
||||||
var.playlist.remove_by_id(item.id)
|
var.playlist.remove_by_id(item.id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user