Commit 5fc259cd authored by msempere's avatar msempere

Sorting by modified date

parent 2323b5e0
...@@ -4,6 +4,7 @@ import platform ...@@ -4,6 +4,7 @@ import platform
import re import re
import shutil import shutil
from datetime import datetime
from operator import itemgetter from operator import itemgetter
from werkzeug import secure_filename from werkzeug import secure_filename
...@@ -459,7 +460,7 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -459,7 +460,7 @@ class FileAdmin(BaseView, ActionsMixin):
rel_path = op.join(path, f) rel_path = op.join(path, f)
if self.is_accessible_path(rel_path): if self.is_accessible_path(rel_path):
items.append((f, rel_path, op.isdir(fp), op.getsize(fp))) items.append((f, rel_path, op.isdir(fp), op.getsize(fp), op.getmtime(fp)))
# Sort by name # Sort by name
items.sort(key=itemgetter(0)) items.sort(key=itemgetter(0))
...@@ -467,6 +468,9 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -467,6 +468,9 @@ class FileAdmin(BaseView, ActionsMixin):
# Sort by type # Sort by type
items.sort(key=itemgetter(2), reverse=True) items.sort(key=itemgetter(2), reverse=True)
# Sort by modified date
items.sort(key=lambda (v1, v2, v3, v4, v5): (v1, v2, v3, v4, datetime.fromtimestamp(v5)), reverse=True)
# Generate breadcrumbs # Generate breadcrumbs
accumulator = [] accumulator = []
breadcrumbs = [] breadcrumbs = []
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
{% endblock %} {% endblock %}
</tr> </tr>
</thead> </thead>
{% for name, path, is_dir, size in items %} {% for name, path, is_dir, size, date in items %}
<tr> <tr>
{% block list_row scoped %} {% block list_row scoped %}
{% if actions %} {% if actions %}
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
{% endblock %} {% endblock %}
</tr> </tr>
</thead> </thead>
{% for name, path, is_dir, size in items %} {% for name, path, is_dir, size, date in items %}
<tr> <tr>
{% block list_row scoped %} {% block list_row scoped %}
{% if actions %} {% if actions %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment