- Changes to the list views - now using tabulator with filtering and sorting, client-side pagination, ...
- Adaptation of all list views in the app
This commit is contained in:
@@ -105,6 +105,12 @@ class Document(db.Model):
|
||||
# Relations
|
||||
versions = db.relationship('DocumentVersion', backref='document', lazy=True)
|
||||
|
||||
@property
|
||||
def latest_version(self):
|
||||
"""Returns the latest document version (the one with highest id)"""
|
||||
from sqlalchemy import desc
|
||||
return DocumentVersion.query.filter_by(doc_id=self.id).order_by(desc(DocumentVersion.id)).first()
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Document {self.id}: {self.name}>"
|
||||
|
||||
|
||||
@@ -12,7 +12,16 @@ def prefixed_url_for(endpoint, **values):
|
||||
|
||||
if external:
|
||||
path, query, fragment = urlsplit(generated_url)[2:5]
|
||||
new_path = prefix + path
|
||||
# Check if the prefix is already present in the path
|
||||
if prefix and not path.startswith(prefix):
|
||||
new_path = prefix + path
|
||||
else:
|
||||
new_path = path
|
||||
return urlunsplit((scheme, host, new_path, query, fragment))
|
||||
else:
|
||||
return prefix + generated_url
|
||||
# Check if the prefix is already present in the generated URL
|
||||
if prefix and not generated_url.startswith(prefix):
|
||||
return prefix + generated_url
|
||||
else:
|
||||
return generated_url
|
||||
|
||||
|
||||
Reference in New Issue
Block a user