mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Add CurpusFile result relation to Corpus
This commit is contained in:
parent
488baf0b67
commit
afac42464a
@ -5,7 +5,7 @@ from flask_login import current_user, login_required
|
||||
from . import main
|
||||
from .forms import CreateCorpusForm
|
||||
from .. import db
|
||||
from ..models import Corpus, Job
|
||||
from ..models import Corpus, CorpusFile, Job
|
||||
import os
|
||||
import threading
|
||||
|
||||
@ -86,6 +86,14 @@ def dashboard():
|
||||
else:
|
||||
for file in create_corpus_form.files.data:
|
||||
file.save(os.path.join(dir, file.filename))
|
||||
dir = os.path.join(str(corpus.user_id),
|
||||
'corpora',
|
||||
str(corpus.id))
|
||||
corpus_file = CorpusFile(filename=file.filename,
|
||||
corpus_id=corpus.id,
|
||||
dir=dir)
|
||||
db.session.add(corpus_file)
|
||||
db.session.commit()
|
||||
flash('Corpus created!')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
|
@ -258,6 +258,7 @@ class JobInput(db.Model):
|
||||
# Primary key
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
filename = db.Column(db.String(255))
|
||||
dir = db.Column(db.String(255))
|
||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||
# Relationships
|
||||
results = db.relationship('JobResult',
|
||||
@ -285,6 +286,7 @@ class JobResult(db.Model):
|
||||
# Primary key
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
filename = db.Column(db.String(255))
|
||||
dir = db.Column(db.String(255))
|
||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||
job_input_id = db.Column(db.Integer, db.ForeignKey('job_inputs.id'))
|
||||
|
||||
@ -398,6 +400,7 @@ class CorpusFile(db.Model):
|
||||
# Primary key
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
filename = db.Column(db.String(255))
|
||||
dir = db.Column(db.String(255))
|
||||
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user