from flask import request, url_for
from app.models import Corpus


def corpus_endpoint_arguments_constructor():
    return {'corpus_id': request.view_args['corpus_id']}


def corpus_dynamic_list_constructor():
    corpus_id = request.view_args['corpus_id']
    corpus = Corpus.query.get_or_404(corpus_id)
    return [
        {
            'text': f'<i class="material-icons left">book</i>{corpus.title}',
            'url': url_for('.corpus', corpus_id=corpus_id)
        }
    ]
