diff --git a/links/file_views.py b/links/file_views.py index c3cb588..877e54a 100644 --- a/links/file_views.py +++ b/links/file_views.py @@ -66,7 +66,20 @@ class FileUploadView(View): results = [] for f in uploaded: record = _save_uploaded_file(f) - results.append({'id': str(record.pk), 'name': record.name, 'size': record.size}) + results.append({ + 'id': str(record.pk), + 'name': record.name, + 'mime_type': record.mime_type, + 'size': record.size, + 'formatted_size': record.formatted_size(), + 'is_public': record.is_public, + 'public_url': record.public_url, + 'expires_at': record.expires_at.isoformat() if record.expires_at else None, + 'download_count': record.download_count, + 'created_at': record.created_at.isoformat(), + 'download_url': record.download_url, + 'is_image': record.is_image, + }) if is_ajax: return JsonResponse({'uploaded': results}) return redirect('file-list') @@ -90,6 +103,8 @@ class FileDeleteView(View): if os.path.exists(record.file_path): os.remove(record.file_path) record.delete() + if request.headers.get('X-Requested-With') == 'XMLHttpRequest': + return JsonResponse({'deleted': str(pk)}) return redirect('file-list') diff --git a/links/templates/links/files/list.html b/links/templates/links/files/list.html index a3a967b..cc2b869 100644 --- a/links/templates/links/files/list.html +++ b/links/templates/links/files/list.html @@ -3,21 +3,22 @@ {% load static %} {% block extra_css %} + {% endblock %} {% block content %} -
| {% trans "Name" %} | - -{% trans "Size" %} | - -{% trans "Public" %} | - -{% trans "Actions" %} | -
|---|---|---|---|
|
-
- |
-
-
-
- {{ file.formatted_size }} | - - - -
-
-
- ● {% trans "Public" %}
-
-
- ○ {% trans "Private" %}
-
+
+
+
+
+
|
-
-
-
-
-
-
-
+
- |
-
{% trans "No files yet" %}
-{% trans "Drag files anywhere on this page, or click Upload Files above." %}
-{% trans "No files yet" %}
+{% trans "Drag files anywhere on this page, or click Upload Files above." %}
+{% trans "Unfortunately, we can't preview this file." %}
{% trans "But you can click the link below to download it." %}
-