mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 17:25:44 +00:00
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from .. import db
|
|
from ..decorators import background
|
|
from ..models import Corpus, CorpusFile
|
|
|
|
|
|
@background
|
|
def build_corpus(corpus_id, *args, **kwargs):
|
|
app = kwargs['app']
|
|
with app.app_context():
|
|
corpus = Corpus.query.get(corpus_id)
|
|
if corpus is None:
|
|
raise Exception('Corpus {} not found'.format(corpus_id))
|
|
corpus.build()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def delete_corpus(corpus_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
corpus = Corpus.query.get(corpus_id)
|
|
if corpus is None:
|
|
raise Exception('Corpus {} not found'.format(corpus_id))
|
|
corpus.delete()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def delete_corpus_file(corpus_file_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
corpus_file = CorpusFile.query.get(corpus_file_id)
|
|
if corpus_file is None:
|
|
raise Exception('Corpus file {} not found'.format(corpus_file_id))
|
|
corpus_file.delete()
|
|
db.session.commit()
|