mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] journal list correctly list available journals
This commit is contained in:
parent
0668c7e350
commit
a6d89f8ea1
1 changed files with 17 additions and 1 deletions
|
@ -50,7 +50,23 @@ def journals_list():
|
||||||
if not os.path.exists(JOURNALS_PATH):
|
if not os.path.exists(JOURNALS_PATH):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
return {}
|
result = {}
|
||||||
|
|
||||||
|
for category in os.listdir(JOURNALS_PATH):
|
||||||
|
result[category] = []
|
||||||
|
for journal in filter(lambda x: x.endswith(".journal"), os.listdir(os.path.join(JOURNALS_PATH, category))):
|
||||||
|
|
||||||
|
journal = journal[:-len(".journal")]
|
||||||
|
journal = journal.split("_")
|
||||||
|
journal_datetime = datetime.strptime(" ".join(journal[-2:]), "%Y-%m-%d %H-%M-%S")
|
||||||
|
result[category].append({
|
||||||
|
"started_at": journal_datetime,
|
||||||
|
"name": " ".join(journal[:-2]),
|
||||||
|
})
|
||||||
|
|
||||||
|
result[category] = list(reversed(sorted(result[category], key=lambda x: x["started_at"])))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Journal(object):
|
class Journal(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue