Renome to_jsonifyable method to to_dict

This commit is contained in:
Patrick Jentsch 2019-08-16 14:53:59 +02:00
parent 22f6c6b4b6
commit 6d0096c2cc
2 changed files with 10 additions and 10 deletions

View File

@ -20,7 +20,7 @@ def admin_corpora():
return abort(404)
jsonifyable_corpora = []
for corpus in corpora:
jsonifyable_corpora.append(corpus.to_jsonifyable())
jsonifyable_corpora.append(corpus.to_dict())
return jsonify(jsonifyable_corpora)
@ -30,7 +30,7 @@ def admin_corpora():
def admin_coprus(corpus_id):
corpus = Corpus.query.filter_by(id=corpus_id).first()
if corpus:
return jsonify(corpus.to_jsonifyable())
return jsonify(corpus.to_dict())
else:
return abort(404)
@ -50,7 +50,7 @@ def admin_jobs():
return abort(404)
jsonifyable_jobs = []
for job in jobs:
jsonifyable_jobs.append(job.to_jsonifyable())
jsonifyable_jobs.append(job.to_dict())
return jsonify(jsonifyable_jobs)
@ -60,7 +60,7 @@ def admin_jobs():
def admin_job(job_id):
job = Job.query.filter_by(id=job_id).first()
if job:
return jsonify(job.to_jsonifyable())
return jsonify(job.to_dict())
else:
return abort(404)
@ -70,7 +70,7 @@ def admin_job(job_id):
def corpora():
jsonifyable_corpora = []
for corpus in current_user.corpora.all():
jsonifyable_corpora.append(corpus.to_jsonifyable())
jsonifyable_corpora.append(corpus.to_dict())
return jsonify(jsonifyable_corpora)
@ -79,7 +79,7 @@ def corpora():
def corpus(corpus_id):
corpus = current_user.corpora.filter_by(id=corpus_id).first()
if corpus:
return jsonify(corpus.to_jsonifyable())
return jsonify(corpus.to_dict())
else:
return abort(404)
@ -89,7 +89,7 @@ def corpus(corpus_id):
def jobs():
jsonifyable_jobs = []
for job in current_user.jobs.all():
jsonifyable_jobs.append(job.to_jsonifyable())
jsonifyable_jobs.append(job.to_dict())
return jsonify(jsonifyable_jobs)
@ -98,6 +98,6 @@ def jobs():
def job(job_id):
job = current_user.jobs.filter_by(id=job_id).first()
if job:
return jsonify(job.to_jsonifyable())
return jsonify(job.to_dict())
else:
return abort(404)

View File

@ -247,7 +247,7 @@ class Job(db.Model):
"""
return '<Job %r>' % self.title
def to_jsonifyable(self):
def to_dict(self):
return {'id': self.id,
'creation_date': self.creation_date.timestamp(),
'description': self.description,
@ -284,7 +284,7 @@ class Corpus(db.Model):
"""
return '<Corpus %r>' % self.title
def to_jsonifyable(self):
def to_dict(self):
return {'id': self.id,
'creation_date': self.creation_date,
'description': self.description,