2020-03-27 11:06:11 +00:00
|
|
|
from ..models import Corpus, CorpusFile
|
2019-11-06 09:07:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def delete_corpus_(app, corpus_id):
|
|
|
|
with app.app_context():
|
2019-11-15 12:09:12 +00:00
|
|
|
corpus = Corpus.query.get(corpus_id)
|
2019-11-06 09:07:34 +00:00
|
|
|
if corpus is None:
|
2020-04-21 08:27:42 +00:00
|
|
|
# raise Exception('Corpus {} not found!'.format(corpus_id))
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
corpus.delete()
|
2019-11-06 09:07:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def delete_corpus_file_(app, corpus_file_id):
|
|
|
|
with app.app_context():
|
2019-11-15 12:09:12 +00:00
|
|
|
corpus_file = CorpusFile.query.get(corpus_file_id)
|
2019-11-06 09:07:34 +00:00
|
|
|
if corpus_file is None:
|
2020-04-21 08:27:42 +00:00
|
|
|
# raise Exception('Corpus file {} not found!'.format(corpus_file_id))
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
corpus_file.delete()
|
2019-11-06 09:07:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def edit_corpus_file_(app, corpus_file_id):
|
|
|
|
with app.app_context():
|
2019-11-15 12:09:12 +00:00
|
|
|
corpus_file = CorpusFile.query.get(corpus_file_id)
|
2019-11-06 09:07:34 +00:00
|
|
|
if corpus_file is None:
|
|
|
|
raise Exception('Corpus file {} not found!'.format(corpus_file_id))
|
2020-04-21 08:27:42 +00:00
|
|
|
else:
|
|
|
|
corpus_file.insert_metadata()
|