Ejemplo n.º 1
0
from waitlist.utility.settings import sget_resident_mail, sget_tbadge_mail, sget_other_mail, sget_other_topic, \
    sget_tbadge_topic, sget_resident_topic
from waitlist.utility.utils import get_random_token
from typing import Callable, Any
import gevent
import time
from gevent.threading import Lock
from flask_babel import gettext, lazy_gettext
from waitlist.utility.outgate.exceptions import ApiException
from sqlalchemy.exc import InvalidRequestError
from esipy.exceptions import APIException

bp = Blueprint('accounts', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('include_in_accountlist')
perm_manager.define_permission('accounts_edit')
perm_manager.define_permission('settings_access')
perm_manager.define_permission('admin')
perm_manager.define_permission('accounts_download_list')


@bp.route("/", methods=["GET", "POST"])
@login_required
@perm_manager.require('accounts_edit')
def accounts():
    if request.method == "POST":
        acc_name = request.form['account_name']

        acc_roles = request.form.getlist('account_roles')
Ejemplo n.º 2
0
    :return: the amount of time some one accessed this
    """
    if user_id in access_duration_track:
        first_access, last_access = access_duration_track[user_id]
        if (access_now - last_access) > limit:  # reset
            access_duration_track[user_id] = (access_now, access_now)
            return timedelta(minutes=0)
        else:
            access_duration_track[user_id] = (first_access, access_now)
            return access_now - first_access
    else:
        access_duration_track[user_id] = (access_now, access_now)
        return timedelta(minutes=0)


perm_manager.define_permission('notification_send')
perm_manager.define_permission('comphistory_view')
perm_manager.define_permission('comphistory_unlimited')
perm_manager.define_permission('trainee')
perm_manager.define_permission('fits_approve')
perm_manager.define_permission('fits_view')
perm_manager.define_permission('comphistory_view_240')

perm_notify_send = perm_manager.get_permission('notification_send')
perm_comp_view = perm_manager.get_permission('comphistory_view')
perm_comp_unlimited = perm_manager.get_permission('comphistory_unlimited')
perm_trainee = perm_manager.get_permission('trainee')
perm_approve = perm_manager.get_permission('fits_approve')
perm_fits_view = perm_manager.get_permission('fits_view')

Ejemplo n.º 3
0
from waitlist.permissions import perm_manager
from waitlist.utility.settings import sget_resident_mail,\
    sget_tbadge_mail, sset_tbadge_mail, sset_resident_mail, sset_resident_topic,\
    sset_tbadge_topic, sset_other_mail, sset_other_topic, sget_tbadge_topic,\
    sget_other_mail, sget_resident_topic, sget_other_topic
from flask.globals import request
from flask.helpers import flash, url_for
from werkzeug.utils import redirect
from waitlist.base import app
from flask_babel import gettext, lazy_gettext

bp = Blueprint('settings_mail', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('welcome_mail_edit')
perm_edit = perm_manager.get_permission('welcome_mail_edit')


@app.context_processor
def inject_data():
    return dict()


@bp.route("/")
@login_required
@perm_edit.require()
def index():
    mails = {
        'resident': [sget_resident_mail(),
                     sget_resident_topic()],
Ejemplo n.º 4
0
from flask.blueprints import Blueprint
import logging
from waitlist.permissions import perm_manager
from flask_login import login_required
from flask.globals import request
from waitlist import db
from waitlist.storage.database import HistoryEntry, Character, Account
from flask import jsonify
from waitlist.utility.json import make_history_json
from datetime import datetime

bp = Blueprint('api_history', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('comphistory_search')


@bp.route('/comp', methods=['GET'])
@login_required
@perm_manager.require('comphistory_search')
def get_comp_history():
    f_acc_names = request.args.get('accs')
    f_char_names = request.args.get('chars')
    f_time_start = request.args.get('start')
    f_time_end = request.args.get('end')
    f_actions = request.args.get('actions')
    query = db.session.query(HistoryEntry)
    if f_acc_names is not None:
        a_names = f_acc_names.split('|')
        condition = None
        for a in a_names:
Ejemplo n.º 5
0
from flask import Blueprint
from flask import render_template
from flask_login import login_required
from gevent import Greenlet
from sqlalchemy import and_, or_, func

from waitlist import db
from waitlist.blueprints.settings import add_menu_entry
from waitlist.permissions import perm_manager
from waitlist.storage.database import InvType, Character, Shipfit, HistoryEntry, HistoryFits, Account

bp = Blueprint('settings_overview', __name__)
logger = logging.getLogger(__name__)


perm_manager.define_permission('settings_access')

perm_access = perm_manager.get_permission('settings_access')


class StatCache(object):
    def __init__(self) -> None:
        self.__data: Dict[str, Any] = {}

    def has_cache_item(self, key: str) -> bool:
        if key not in self.__data:
            return False

        if self.__data[key]['datetime'] < datetime.utcnow():
            return False
        return True
Ejemplo n.º 6
0
import flask
from flask import Blueprint, Response, render_template, request,\
    url_for, redirect
from flask_babel import gettext, lazy_gettext
from flask_login import login_required, current_user
from waitlist.base import db
from waitlist.permissions import perm_manager
from waitlist.storage.database import ShipCheckCollection, WaitlistGroup, ShipCheck,\
    InvType, InvGroup, MarketGroup
from waitlist.blueprints.settings import add_menu_entry
from waitlist.utility.constants import check_types

bp = Blueprint('ship_assignment', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('ship_assignment_edit')


@bp.route('/', methods=['GET'])
@login_required
@perm_manager.require('ship_assignment_edit')
def ship_assignments():
    checks = db.session.query(ShipCheckCollection).all()
    wl_groups = db.session.query(WaitlistGroup).all()
    # TODO: this site needs the forms for adding a collection
    # and removing one, only has edit for now
    return render_template('settings/ship_assignment/collection_list.html',
                           checks=checks,
                           groups=wl_groups)

Ejemplo n.º 7
0
from waitlist.permissions import perm_manager
from waitlist.utility import config
from flask import Blueprint
from flask import render_template
from flask_login import current_user, login_required

from waitlist import db
from waitlist.storage.database import WaitlistGroup, Account, IncursionLayout, Station, SolarSystem, Constellation, \
    WaitlistEntry
from waitlist.utility.eve_id_utils import get_constellation, get_system, get_station
from waitlist.utility.fleet import member_info

bp = Blueprint('fleetoptions', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('fleet_management')
perm_manager.define_permission('fleet_custom_status')
perm_manager.define_permission('fleet_location_edit')
perm_manager.define_permission('fleet_custom_display_name')
perm_manager.define_permission('fleet_custom_display_name_all')

perm_management = perm_manager.get_permission('fleet_management')
perm_custom_status = perm_manager.get_permission('fleet_custom_status')
perm_fleetlocation_edit = perm_manager.get_permission('fleet_location_edit')


@bp.route('/')
@login_required
@perm_management.require(http_exception=401)
def fleet() -> Response:
    groups = db.session.query(WaitlistGroup).all()
Ejemplo n.º 8
0
from flask import url_for
from flask_login import login_required

from waitlist.base import db
from waitlist.blueprints.settings import add_menu_entry
from waitlist.permissions import perm_manager
from waitlist.storage.database import TeamspeakDatum
from waitlist.ts3.connection import change_connection
from waitlist.utility.settings import sget_active_ts_id, sset_active_ts_id
from waitlist.utility.config import disable_teamspeak
from flask_babel import gettext, lazy_gettext

bp = Blueprint('teamspeak', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('teamspeak_change')
perm_manager.define_permission('teamspeak_view')
perm_manager.define_permission('teamspeak_edit')

perm_change_server = perm_manager.get_permission('teamspeak_change')\
    .union(perm_manager.get_permission('teamspeak_edit'))
perm_view_server = perm_change_server
perm_edit_server = perm_manager.get_permission('teamspeak_edit')


@bp.route("/ts", methods=["GET"])
@login_required
@perm_view_server.require()
def teamspeak():
    active_ts_setting_id = sget_active_ts_id()
    active_ts_setting = None
Ejemplo n.º 9
0
from waitlist.utility import fleet as fleet_utils
from waitlist.utility.fleet import member_info
from waitlist.utility.json.fleetdata import FleetMemberEncoder
from waitlist.utility.outgate.character.info import get_character_fleet_id
from waitlist.utility.swagger import esi_scopes
from waitlist.utility.swagger.eve.fleet import EveFleetEndpoint
from waitlist.utility.swagger.eve.fleet.models import FleetMember
from waitlist.utility.swagger.eve import ESIResponse
from waitlist.utility.swagger.eve.fleet.responses import EveFleet
from waitlist.signal import send_added_first_fleet
from flask_babel import gettext

bp = Blueprint('fleet', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('fleet_management')
perm_manager.define_permission('developer_tools')

fleets_manage = perm_manager.get_permission('fleet_management')
perm_dev = perm_manager.get_permission('developer_tools')


@login_required
@fleets_manage.require(http_exception=401)
def handle_new_fleet_token(tokens):
    add_token(tokens)
    return redirect(url_for('fleet.take_over_fleet'))


'''
register sso handler
Ejemplo n.º 10
0
from werkzeug.utils import redirect
from flask.helpers import url_for
from flask.templating import render_template
from datetime import datetime, timedelta
from waitlist import db
from waitlist.data.sse import subscriptions, EntryAddedSSE, \
    send_server_sent_event, FitAddedSSE, FitRemovedSSE, EntryRemovedSSE
import flask
from sqlalchemy.sql.expression import desc
from waitlist.utility.history_utils import create_history_object
from waitlist.blueprints.api import fittings as fit_api

bp_waitlist = Blueprint('fittings', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('fleet_management')
perm_manager.define_permission('fits_approve')
perm_manager.define_permission('developer_tools')
perm_manager.define_permission('comphistory_view')
perm_manager.define_permission('comphistory_unlimited')

perm_fleet_manage = perm_manager.get_permission('fleet_management')

perm_dev = perm_manager.get_permission('developer_tools')

perm_comp_view = perm_manager.get_permission('comphistory_view')
perm_comp_unlimited = perm_manager.get_permission('comphistory_unlimited')


@bp_waitlist.route("/move_to_waitlist", methods=["POST"])
@login_required
Ejemplo n.º 11
0
from flask import request
from flask import url_for
from flask_login import login_required
from os import path

from werkzeug.utils import secure_filename, redirect

from waitlist.blueprints.settings import add_menu_entry
from waitlist import app
from waitlist.permissions import perm_manager
from waitlist.utility import sde

bp = Blueprint('sde', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('static_data_import')
perm_manager.define_permission('developer_tools')

perm_access = perm_manager.get_permission('static_data_import')
perm_developer = perm_manager.get_permission('developer_tools')


@bp.route("/sde/update/typeids", methods=["POST"])
@login_required
@perm_access.require(http_exception=401)
def update_type_ids():
    f = request.files['file']
    if f and (f.filename.rsplit('.', 1)[1] == "bz2"
              or f.filename.rsplit('.', 1)[1] == "yaml"):
        filename = secure_filename(f.filename)
        dest_name = path.join(app.config['UPLOAD_FOLDER'], filename)
Ejemplo n.º 12
0
from sqlalchemy import asc

from waitlist.utility import outgate
from waitlist.base import db
from waitlist.blueprints.settings import add_menu_entry
from waitlist.permissions import perm_manager
from waitlist.storage.database import Ban, Whitelist, Character, CharacterTypes
from waitlist.utility.eve_id_utils import get_character_by_name, get_char_corp_all_name_by_id_and_type
from waitlist.utility.utils import get_info_from_ban
from flask_babel import lazy_gettext, gettext
from waitlist.utility.outgate.exceptions import ApiException

bp = Blueprint('bans', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('bans_edit')
perm_manager.define_permission('bans_edit_multiple')
perm_manager.define_permission('bans_custom_name')
perm_manager.define_permission('bans_custom_reason')

perm_custom_name = perm_manager.get_permission('bans_custom_name')
perm_custom_reason = perm_manager.get_permission('bans_custom_reason')


@bp.route("/", methods=["GET"])
@login_required
@perm_manager.require('bans_edit')
def bans():
    db_bans = db.session.query(Ban).all()

    return render_template("settings/bans.html", bans=db_bans)
Ejemplo n.º 13
0
from waitlist.blueprints.settings import add_menu_entry
from waitlist.permissions import perm_manager

perm_manager.define_permission('calendar_event_add')

add_menu_entry('calendar_settings.get_index', 'Events',
               perm_manager.get_permission('calendar_event_add').can)
Ejemplo n.º 14
0
import logging
import flask
from waitlist.data.sse import FitAddedSSE, EntryAddedSSE, EntryRemovedSSE,\
    FitRemovedSSE, GongSSE, Subscription, add_subscription,\
    remove_subscription,\
    InviteMissedSSE, StatusChangedSSE, ReloadPageSSE
from flask.wrappers import Response

from waitlist.permissions import perm_manager
from waitlist.base import db
from time import sleep

bp = Blueprint('api_sse', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('fits_view')

perm_fits_view = perm_manager.get_permission('fits_view')


def event_gen(sub: Subscription):
    if not isinstance(sub, Subscription):
        raise TypeError("Not a Subscription Object")
    add_subscription(sub)
    try:
        while True:
            event = sub.get()
            logger.debug("Event " + sub.encode(event))
            yield sub.encode(event)
    finally:
        remove_subscription(sub)
Ejemplo n.º 15
0
import logging
from flask.blueprints import Blueprint
from waitlist.permissions import perm_manager
from flask_login import login_required, current_user
from waitlist import db
from waitlist.storage.database import Account, AccountNote
from flask.templating import render_template
import flask
from flask.globals import request
from werkzeug.utils import redirect
from flask.helpers import url_for
bp = Blueprint('accounts_profile', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('view_profile')
perm_manager.define_permission('profile_notes_add')
perm_manager.define_permission('view_notes_high')  # >= 500
perm_manager.define_permission('view_notes_low')  # < 100
perm_manager.define_permission('view_notes_med')  # < 200
perm_manager.define_permission('view_notes_all')
perm_manager.define_permission('view_notes')


@bp.route("/<int:accountid>", methods=["GET"])
@login_required
@perm_manager.require('view_profile')
def profile(accountid):
    account = db.session.query(Account).get(accountid)
    if account is None:
        flask.abort(404, "Account not found!")
Ejemplo n.º 16
0
from waitlist.utility.swagger.eve import make_error_response, ESIResponse
from waitlist.utility.swagger.evemail import send_mail
from flask.helpers import make_response, url_for
import json
from waitlist.permissions import perm_manager
from werkzeug.utils import redirect
from waitlist.blueprints.fc_sso import add_sso_handler, get_sso_redirect
from waitlist.storage.database import Account, AccountNote, SSOToken
from sqlalchemy import or_
from waitlist.base import db
from waitlist.utility.constants import account_notes
from waitlist.signal.handler import account
bp = Blueprint('api_mail', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('send_mail')


@bp.route('/', methods=['POST'])
@login_required
@perm_manager.require('send_mail')
def send_esi_mail():
    """
    Sends mails to characters.
    mailRecipients => JSON String recipients=[{"recipient_id": 0, "recipient_type": "character|alliance"}]
    mailBody => String
    mailSubject => String
    """

    token: SSOToken = current_user.get_a_sso_token_with_scopes(
        esi_scopes.mail_scopes)
Ejemplo n.º 17
0
from flask import Response, request, make_response, jsonify
from flask_login import login_required

from waitlist.base import db
from waitlist.blueprints.swagger_api.characters import bp_v1
from waitlist.blueprints.swagger_api.models import errors
from waitlist.permissions import perm_manager
from waitlist.storage.database import Character

perm_manager.define_permission('change_character_data')
perm_change_character_data = perm_manager.get_permission(
    'change_character_data')


@login_required
@perm_change_character_data.require()
@bp_v1.route('/<int:character_id>/', methods=['PUT'])
def character_put_v1(character_id: int) -> Response:
    """
    file: character_put_v1.yml
    """
    owner_hash = request.form.get('owner_hash')
    character: Character = db.session.query(Character).get(character_id)
    if character is None:
        resp: Response = jsonify(
            errors.error_404(
                f'Character with id={character_id} does not exist.'))
        resp.status_code = 404
        return resp

    character.owner_hash = owner_hash
Ejemplo n.º 18
0
from typing import Iterable, Sequence

from waitlist.permissions import perm_manager
from waitlist.storage.database import AccountNote, RoleChangeEntry
from waitlist import db
from waitlist.storage.database import Role, Account
from sqlalchemy.sql.expression import or_
from waitlist.signal.signals import roles_changed_sig, roles_added_sig

perm_manager.define_permission('trainee')

perm_trainee = perm_manager.get_permission('trainee')


# noinspection PyUnusedLocal
@roles_changed_sig.connect
def on_roles_changed(sender, to_id: int, by_id: int, added_roles: Sequence[str],
                     removed_roles: Sequence[str], note: str) -> None:
    if len(added_roles) <= 0 and len(removed_roles) <= 0 and note == "":
        return
    history_entry = AccountNote(accountID=to_id, byAccountID=by_id, note=note)
    if len(added_roles) > 0:
        db_roles = db.session.query(Role).filter(or_(Role.name == name for name in added_roles)).all()
        for role in db_roles:
            # get role from db
            role_change = RoleChangeEntry(added=True, role=role)
            history_entry.role_changes.append(role_change)
        
    if len(removed_roles) > 0:
        db_roles = db.session.query(Role).filter(or_(Role.name == name for name in removed_roles)).all()
        for role in db_roles:
Ejemplo n.º 19
0
import logging

from flask import Blueprint, jsonify
from flask import abort
from flask import request
from flask_login import login_required

from waitlist.permissions import perm_manager
from waitlist.permissions.manager import StaticPermissions

bp = Blueprint('api_permission', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission(StaticPermissions.ADMIN)


@bp.route('/change', methods=['POST'])
@login_required
@perm_manager.require(StaticPermissions.ADMIN)
def change():
    perm_name: str = request.form.get('perm_name', None)
    role_name: str = request.form.get('role_name', None)
    perm_state_str: str = request.form.get('state', None)

    if perm_name is None or role_name is None or perm_state_str is None:
        abort(400, "A required parameter is missing or incorrect")
        return

    if not (perm_state_str == "true" or perm_state_str == "false"):
        abort(
            400,
Ejemplo n.º 20
0
from flask.blueprints import Blueprint
import logging
from flask_login import login_required
from flask.templating import render_template

from waitlist.permissions import perm_manager
from waitlist.storage.database import CCVote, Account
from waitlist import db
from sqlalchemy.sql.functions import func

bp = Blueprint('settings_ccvote', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('ccvot_result_view')


@bp.route("/")
@login_required
@perm_manager.require('ccvot_result_view')
def index():
    fc_results = db.session.query(Account.username, func.count('*')).join(
        CCVote,
        Account.id == CCVote.fcvoteID).group_by(Account.username).order_by(
            func.count('*')).all()
    lm_results = db.session.query(Account.username, func.count('*')).join(
        CCVote,
        Account.id == CCVote.lmvoteID).group_by(Account.username).order_by(
            func.count('*')).all()

    # unique votes
    unique_votes_query_fc = db.session.query(CCVote.voterID.label("voterID"), CCVote.fcvoteID.label("fcvoteID")) \
Ejemplo n.º 21
0
from flask import make_response
from flask import redirect
from flask import render_template
from flask import url_for
from flask.globals import request
from flask_login import login_required, current_user
from sqlalchemy import or_

from waitlist import db
from waitlist.permissions import perm_manager
from waitlist.storage.database import Account, CalendarEvent, CalendarEventCategory

bp = Blueprint('calendar_settings', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('calendar_event_see_all')
perm_manager.define_permission('calendar_event_delete_other')


@bp.route("/", methods=['GET'])
@login_required
@perm_manager.require('commandcore')
def get_index():
    # noinspection PyPep8
    accounts: Sequence[Account] = db.session.query(Account).filter(
        Account.disabled == False).all()

    event_query = db.session.query(CalendarEvent).filter(
        CalendarEvent.eventTime > datetime.utcnow())
    if not perm_manager.get_permission('calendar_event_see_all').can():
        event_query = event_query \
Ejemplo n.º 22
0
from flask_login import login_required
from flask.templating import render_template

from waitlist.blueprints.settings import add_menu_entry
from waitlist.utility.settings import sget_insert, sset_insert
from flask.blueprints import Blueprint
import logging
from flask.globals import request
from flask.helpers import flash, url_for
from werkzeug.utils import redirect
from waitlist.permissions import perm_manager

bp = Blueprint('settings_inserts', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('inserts_edit')


@bp.route("/")
@login_required
@perm_manager.require('inserts_edit')
def index() -> Response:
    data = {'header': sget_insert('header')}
    return render_template("settings/inserts.html", inserts=data)


@bp.route("/change/<string:type_>", methods=["POST"])
@login_required
@perm_manager.require('inserts_edit')
def change(type_) -> Response:
    if type_ == "header":
Ejemplo n.º 23
0
from flask.templating import render_template

from waitlist.permissions import perm_manager
from waitlist.utility.settings import sget_motd_hq, sget_motd_vg,\
    sset_motd_hq, sset_motd_vg
from flask.blueprints import Blueprint
import logging
from flask.globals import request
from flask.helpers import flash, url_for
from werkzeug.utils import redirect
from flask_babel import gettext, lazy_gettext
bp = Blueprint('settings_fmotds', __name__)
logger = logging.getLogger(__name__)


perm_manager.define_permission('change_fleet_motd')


def get_permission():
    return perm_manager.get_permission('change_fleet_motd')


perm = get_permission()


@bp.route("/")
@login_required
@perm.require()
def index():
    motds = {
        'hq': sget_motd_hq(),
Ejemplo n.º 24
0
from flask.helpers import flash, url_for, make_response

from waitlist.blueprints.settings import add_menu_entry
from waitlist.permissions import perm_manager
from waitlist.storage.database import Ticket
from waitlist.base import db
import flask
from datetime import datetime, timedelta
from sqlalchemy.sql.expression import desc
from flask_babel import gettext, lazy_gettext

logger = logging.getLogger(__name__)

feedback = Blueprint('feedback', __name__)

perm_manager.define_permission('feedback_view')
perm_manager.define_permission('feedback_edit')

perm_view = perm_manager.get_permission('feedback_view')
perm_edit = perm_manager.get_permission('feedback_edit')


@feedback.route("/", methods=["GET"])
@login_required
def index() -> Response:
    # get old feedback and input data back
    char_id = current_user.get_eve_id()
    tickets = db.session.query(Ticket).filter(
        Ticket.characterID == char_id).all()
    return render_template("feedback/index.html", tickets=tickets)
Ejemplo n.º 25
0
from flask_login import login_required

from werkzeug.utils import redirect
from flask.globals import request, session, _app_ctx_stack
from flask_seasurf import randrange
import hashlib

from waitlist.permissions import perm_manager
from waitlist.utility.config import crest_return_url, crest_client_id
import flask
from urllib.parse import urlencode

bp = Blueprint('fc_sso', __name__)
logger = logging.getLogger(__name__)

perm_manager.define_permission('fleet_management')

perm_fleet_manage = perm_manager.get_permission('fleet_management')

sso_handler = {}


def add_sso_handler(key: str, handler):
    sso_handler[key] = handler


def remove_handler(key: str):
    sso_handler.pop(key, None)


@bp.route("/login")
Ejemplo n.º 26
0
from flask_login import login_required

from waitlist.base import db
from waitlist.permissions import perm_manager
from waitlist.storage.database import Account, Character
from waitlist.utility.eve_id_utils import get_character_by_id,\
    get_character_by_name
from waitlist.blueprints.swagger_api.models import errors

from . import bp_v1
from waitlist.signal.signals import send_alt_link_removed, send_alt_link_added
from flask_login.utils import current_user

logger = logging.getLogger(__name__)

perm_manager.define_permission('change_character_links')
perm_change_links = perm_manager.get_permission('change_character_links')

perm_manager.define_permission('accounts_download_list')
perm_manager.define_permission('accounts_download_list')


@login_required
@perm_change_links.require()
@bp_v1.route('/<int:account_id>/links/<int:character_id>', methods=['DELETE'])
def links_delete_v1(account_id: int, character_id: int) -> Response:
    """
    file: links_delete_v1.yml
    """
    acc: Account = db.session.query(Account).get(account_id)
    if acc is None: