mirror of https://gitlab.com/litecord/litecord.git
add draft for features_admin and add guilds_admin
This commit is contained in:
parent
a04b3acfaa
commit
073f47e0f5
|
|
@ -18,5 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .voice import bp as voice
|
from .voice import bp as voice
|
||||||
|
from .features import bp as features
|
||||||
|
from .guilds import bp as guilds
|
||||||
|
|
||||||
__all__ = ['voice']
|
__all__ = ['voice', 'features', 'guilds']
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
Litecord
|
||||||
|
Copyright (C) 2018-2019 Luna Mendes
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, version 3 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from quart import Blueprint, current_app as app
|
||||||
|
|
||||||
|
from litecord.auth import admin_check
|
||||||
|
from litecord.errors import BadRequest
|
||||||
|
|
||||||
|
bp = Blueprint('features_admin', __name__)
|
||||||
|
|
||||||
|
FEATURES = [
|
||||||
|
''
|
||||||
|
]
|
||||||
|
|
||||||
|
@bp.route('/<int:guild_id>/<feature>', methods=['PUT'])
|
||||||
|
async def insert_feature(guild_id: int, feature: str):
|
||||||
|
"""Insert a feature on a guild."""
|
||||||
|
await admin_check()
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
if feature not in FEATURES:
|
||||||
|
raise BadRequest('invalid feature')
|
||||||
|
|
||||||
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/<int:guild_id>/<feature>', methods=['DELETE'])
|
||||||
|
async def remove_feature(guild_id: int, feature: str):
|
||||||
|
"""Remove a feature from a guild"""
|
||||||
|
await admin_check()
|
||||||
|
# TODO
|
||||||
|
await app.db
|
||||||
|
return '', 204
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
Litecord
|
||||||
|
Copyright (C) 2018-2019 Luna Mendes
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, version 3 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from quart import Blueprint, jsonify, current_app as app
|
||||||
|
|
||||||
|
from litecord.auth import admin_check
|
||||||
|
|
||||||
|
bp = Blueprint('guilds_admin', __name__)
|
||||||
|
|
||||||
|
@bp.route('/<int:guild_id>', methods=['GET'])
|
||||||
|
async def get_guild(guild_id: int):
|
||||||
|
"""Get a basic guild payload."""
|
||||||
|
await admin_check()
|
||||||
|
|
||||||
|
return jsonify(
|
||||||
|
await app.storage.get_guild(guild_id)
|
||||||
|
)
|
||||||
7
run.py
7
run.py
|
|
@ -57,7 +57,8 @@ from litecord.blueprints.user import (
|
||||||
from litecord.blueprints.user.billing_job import payment_job
|
from litecord.blueprints.user.billing_job import payment_job
|
||||||
|
|
||||||
from litecord.blueprints.admin_api import (
|
from litecord.blueprints.admin_api import (
|
||||||
voice as voice_admin
|
voice as voice_admin, features as features_admin,
|
||||||
|
guilds as guilds_admin
|
||||||
)
|
)
|
||||||
|
|
||||||
from litecord.blueprints.admin_api.voice import guild_region_check
|
from litecord.blueprints.admin_api.voice import guild_region_check
|
||||||
|
|
@ -143,7 +144,9 @@ def set_blueprints(app_):
|
||||||
nodeinfo: -1,
|
nodeinfo: -1,
|
||||||
static: -1,
|
static: -1,
|
||||||
|
|
||||||
voice_admin: '/admin/voice'
|
voice_admin: '/admin/voice',
|
||||||
|
features_admin: '/admin/features',
|
||||||
|
guilds_admin: '/admin/guilds'
|
||||||
}
|
}
|
||||||
|
|
||||||
for bp, suffix in bps.items():
|
for bp, suffix in bps.items():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue