mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Add url properties to db models
This commit is contained in:
parent
29dbdc9f94
commit
a2102a48ca
@ -533,8 +533,13 @@ class Corpus(db.Model):
|
||||
def path(self):
|
||||
return os.path.join(self.creator.path, 'corpora', str(self.id))
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return url_for('corpora.corpus', corpus_id=self.id)
|
||||
|
||||
def to_dict(self):
|
||||
return {'id': self.id,
|
||||
return {'url': self.url,
|
||||
'id': self.id,
|
||||
'user_id': self.user_id,
|
||||
'creation_date': self.creation_date.timestamp(),
|
||||
'description': self.description,
|
||||
@ -600,17 +605,28 @@ class QueryResult(db.Model):
|
||||
query_metadata = db.Column(db.JSON())
|
||||
title = db.Column(db.String(32))
|
||||
|
||||
@property
|
||||
def download_url(self):
|
||||
return url_for('corpora.download_query_result',
|
||||
query_result_id=self.id)
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return os.path.join(
|
||||
self.creator.path, 'query_results', str(self.id), self.filename)
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return url_for('corpora.query_result', query_result_id=self.id)
|
||||
|
||||
def delete(self):
|
||||
shutil.rmtree(self.path, ignore_errors=True)
|
||||
db.session.delete(self)
|
||||
|
||||
def to_dict(self):
|
||||
return {'id': self.id,
|
||||
return {'download_url': self.download_url,
|
||||
'url': self.url,
|
||||
'id': self.id,
|
||||
'user_id': self.user_id,
|
||||
'description': self.description,
|
||||
'filename': self.filename,
|
||||
|
Loading…
Reference in New Issue
Block a user