mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +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):
|
def path(self):
|
||||||
return os.path.join(self.creator.path, 'corpora', str(self.id))
|
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):
|
def to_dict(self):
|
||||||
return {'id': self.id,
|
return {'url': self.url,
|
||||||
|
'id': self.id,
|
||||||
'user_id': self.user_id,
|
'user_id': self.user_id,
|
||||||
'creation_date': self.creation_date.timestamp(),
|
'creation_date': self.creation_date.timestamp(),
|
||||||
'description': self.description,
|
'description': self.description,
|
||||||
@ -600,17 +605,28 @@ class QueryResult(db.Model):
|
|||||||
query_metadata = db.Column(db.JSON())
|
query_metadata = db.Column(db.JSON())
|
||||||
title = db.Column(db.String(32))
|
title = db.Column(db.String(32))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def download_url(self):
|
||||||
|
return url_for('corpora.download_query_result',
|
||||||
|
query_result_id=self.id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
self.creator.path, 'query_results', str(self.id), self.filename)
|
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):
|
def delete(self):
|
||||||
shutil.rmtree(self.path, ignore_errors=True)
|
shutil.rmtree(self.path, ignore_errors=True)
|
||||||
db.session.delete(self)
|
db.session.delete(self)
|
||||||
|
|
||||||
def to_dict(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,
|
'user_id': self.user_id,
|
||||||
'description': self.description,
|
'description': self.description,
|
||||||
'filename': self.filename,
|
'filename': self.filename,
|
||||||
|
Loading…
Reference in New Issue
Block a user