mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-23 21:47:04 +01:00
Partially implement Database Cleanup button in the admin Panel
This commit is contained in:
parent
eaf55ba027
commit
5da55cc66b
@ -1,4 +1,4 @@
|
||||
from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers, KeyValueProperties, GuildMembers, Messages, get_channel_messages, list_all_guild_members
|
||||
from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers, KeyValueProperties, GuildMembers, Messages, get_channel_messages, list_all_guild_members, get_administrators_list
|
||||
from titanembeds.decorators import valid_session_required, discord_users_only
|
||||
from titanembeds.utils import check_guild_existance, guild_accepts_visitors, guild_query_unauth_users_bool, get_client_ipaddr, discord_api, rate_limiter, channel_ratelimit_key, guild_ratelimit_key
|
||||
from titanembeds.oauth import user_has_permission, generate_avatar_url, check_user_can_administrate_guild
|
||||
@ -499,9 +499,17 @@ def create_authenticated_user():
|
||||
response.status_code = 403
|
||||
return response
|
||||
|
||||
def canCleanupDB():
|
||||
canclean = False
|
||||
if request.form.get("secret", None) == config['app-secret']:
|
||||
canclean = True
|
||||
if 'user_id' in session:
|
||||
if session['user_id'] in get_administrators_list():
|
||||
canclean = True
|
||||
return canclean
|
||||
@api.route("/cleanup-db", methods=["DELETE"])
|
||||
def cleanup_keyval_db():
|
||||
if request.form.get("secret", None) == config["app-secret"]:
|
||||
if canCleanupDB():
|
||||
db.session.query(KeyValueProperties).filter(KeyValueProperties.expiration < datetime.datetime.now()).delete()
|
||||
db.session.commit()
|
||||
|
||||
|
@ -20,5 +20,12 @@
|
||||
<a class="waves-effect waves-light btn" href="{{ url_for('admin.guilds') }}">Manage</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12">
|
||||
<div class="card-panel indigo lighten-5 z-depth-3 hoverable black-text">
|
||||
<h4>Cleanup DB</h4>
|
||||
<p class="flow-text">Clean up the database</p>
|
||||
SoonTM
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user