Skip to content
Snippets Groups Projects
Commit d860a5d2 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Set backrefs correctly.

parent 1e1ef8f9
No related branches found
No related tags found
No related merge requests found
...@@ -24,16 +24,17 @@ def corpora(corpus): ...@@ -24,16 +24,17 @@ def corpora(corpus):
@login_required @login_required
def dashboard(): def dashboard():
create_corpus_form = CreateCorpusForm() create_corpus_form = CreateCorpusForm()
print(current_user.corpora.all())
print(current_user.jobs.all())
if create_corpus_form.validate_on_submit(): if create_corpus_form.validate_on_submit():
app = current_app._get_current_object() app = current_app._get_current_object()
corpus = Corpus() corpus = Corpus(creator=current_user._get_current_object(),
corpus.creation_date = datetime.utcnow() description=create_corpus_form.description.data,
corpus.description = create_corpus_form.description.data title=create_corpus_form.title.data)
corpus.title = create_corpus_form.title.data
corpus.user_id = current_user.id
db.session.add(corpus) db.session.add(corpus)
db.session.commit() db.session.commit()
dir = os.path.join(app.config['OPAQUE_STORAGE'], dir = os.path.join(app.config['OPAQUE_STORAGE'],
str(corpus.user_id), str(corpus.user_id),
'corpora', 'corpora',
......
...@@ -113,8 +113,8 @@ class User(UserMixin, db.Model): ...@@ -113,8 +113,8 @@ class User(UserMixin, db.Model):
role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
username = db.Column(db.String(64), unique=True, index=True) username = db.Column(db.String(64), unique=True, index=True)
# Relationships # Relationships
corpora = db.relationship('Corpus', backref='corpus', lazy='dynamic') corpora = db.relationship('Corpus', backref='creator', lazy='dynamic')
jobs = db.relationship('Job', backref='job', lazy='dynamic') jobs = db.relationship('Job', backref='creator', lazy='dynamic')
def __repr__(self): def __repr__(self):
""" """
......
...@@ -17,19 +17,17 @@ def ocr(): ...@@ -17,19 +17,17 @@ def ocr():
new_ocr_job_form = NewOCRJobForm() new_ocr_job_form = NewOCRJobForm()
if new_ocr_job_form.validate_on_submit(): if new_ocr_job_form.validate_on_submit():
app = current_app._get_current_object() app = current_app._get_current_object()
ocr_job = Job() ocr_job = Job(creator=current_user._get_current_object(),
ocr_job.title = new_ocr_job_form.title.data description=new_ocr_job_form.description.data,
ocr_job.description = new_ocr_job_form.description.data service="ocr",
ocr_job.user_id = current_user.id ressources=json.dumps({"n_cores": 2,
ocr_job.creation_date = datetime.utcnow() "mem_mb": 4096}),
ocr_job.service = "ocr" service_args=json.dumps({"args": ["--keep-intermediates",
ocr_job.ressources = json.dumps({"n_cores": 2, "--skip-binarisation"],
"mem_mb": 4096}) "lang": new_ocr_job_form.language.data,
ocr_job.service_args = json.dumps({"args": ["--keep-intermediates", "version": new_ocr_job_form.version.data}),
"--skip-binarisation"], status="queued",
"lang": new_ocr_job_form.language.data, title=new_ocr_job_form.title.data)
"version": new_ocr_job_form.version.data})
ocr_job.status = "queued"
db.session.add(ocr_job) db.session.add(ocr_job)
db.session.commit() db.session.commit()
...@@ -69,18 +67,16 @@ def nlp(): ...@@ -69,18 +67,16 @@ def nlp():
new_nlp_job_form = NewNLPJobForm() new_nlp_job_form = NewNLPJobForm()
if new_nlp_job_form.validate_on_submit(): if new_nlp_job_form.validate_on_submit():
app = current_app._get_current_object() app = current_app._get_current_object()
nlp_job = Job() nlp_job = Job(creator=current_user._get_current_object(),
nlp_job.title = new_nlp_job_form.title.data description=new_nlp_job_form.description.data,
nlp_job.description = new_nlp_job_form.description.data service="nlp",
nlp_job.user_id = current_user.id ressources=json.dumps({"n_cores": 1,
nlp_job.creation_date = datetime.utcnow() "mem_mb": 2048}),
nlp_job.service = "nlp" service_args=json.dumps({"args": [],
nlp_job.ressources = json.dumps({"n_cores": 2, "lang": new_nlp_job_form.language.data,
"mem_mb": 4096}) "version": new_nlp_job_form.version.data}),
nlp_job.service_args = json.dumps({"args": [], status="queued",
"lang": new_nlp_job_form.language.data, title=new_nlp_job_form.title.data)
"version": new_nlp_job_form.version.data})
nlp_job.status = "queued"
db.session.add(nlp_job) db.session.add(nlp_job)
db.session.commit() db.session.commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment