mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +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 . import main
|
||||||
from .forms import CreateCorpusForm
|
from .forms import CreateCorpusForm
|
||||||
from .. import db
|
from .. import db
|
||||||
from ..models import Corpus, Job
|
from ..models import Corpus, CorpusFile, Job
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@ -86,6 +86,14 @@ def dashboard():
|
|||||||
else:
|
else:
|
||||||
for file in create_corpus_form.files.data:
|
for file in create_corpus_form.files.data:
|
||||||
file.save(os.path.join(dir, file.filename))
|
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!')
|
flash('Corpus created!')
|
||||||
return redirect(url_for('main.dashboard'))
|
return redirect(url_for('main.dashboard'))
|
||||||
|
|
||||||
|
@ -258,6 +258,7 @@ class JobInput(db.Model):
|
|||||||
# Primary key
|
# Primary key
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
filename = db.Column(db.String(255))
|
filename = db.Column(db.String(255))
|
||||||
|
dir = db.Column(db.String(255))
|
||||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||||
# Relationships
|
# Relationships
|
||||||
results = db.relationship('JobResult',
|
results = db.relationship('JobResult',
|
||||||
@ -285,6 +286,7 @@ class JobResult(db.Model):
|
|||||||
# Primary key
|
# Primary key
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
filename = db.Column(db.String(255))
|
filename = db.Column(db.String(255))
|
||||||
|
dir = db.Column(db.String(255))
|
||||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||||
job_input_id = db.Column(db.Integer, db.ForeignKey('job_inputs.id'))
|
job_input_id = db.Column(db.Integer, db.ForeignKey('job_inputs.id'))
|
||||||
|
|
||||||
@ -398,6 +400,7 @@ class CorpusFile(db.Model):
|
|||||||
# Primary key
|
# Primary key
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
filename = db.Column(db.String(255))
|
filename = db.Column(db.String(255))
|
||||||
|
dir = db.Column(db.String(255))
|
||||||
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user