Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ MEDIA_CHOOSER_MODAL_ONLOAD_HANDLERS = {
dataType: 'text',
success: modal.loadResponseText,
error: function(response, textStatus, errorThrown) {
message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
const message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' +
'<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>');
Expand Down Expand Up @@ -186,10 +186,7 @@ MEDIA_CHOOSER_MODAL_ONLOAD_HANDLERS = {
},
'select_format': function(modal) {
$('form', modal.body).on('submit', function() {
var formdata = new FormData(this);

$.post(this.action, $(this).serialize(), modal.loadResponseText, 'text');

return false;
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/wagtailmedia/views/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def index(request):

# Filter by collection
current_collection = None
collection_id = request.GET.get("collection_id")
if collection_id:
if collection_id := request.GET.get("collection_id"):
try:
current_collection = Collection.objects.get(id=collection_id)
media = media.filter(collection=current_collection)
except (ValueError, Collection.DoesNotExist):
# Ignore invalid or unknown collection_id
pass

# Search
Expand Down
4 changes: 2 additions & 2 deletions src/wagtailmedia/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def register_media_permissions_panel():

@hooks.register("describe_collection_contents")
def describe_collection_media(collection):
media_count = get_media_model().objects.filter(collection=collection).count()
if media_count:
if media_count := get_media_model().objects.filter(collection=collection).count():
url = reverse("wagtailmedia:index") + f"?collection_id={collection.id}"
return {
"count": media_count,
Expand All @@ -104,6 +103,7 @@ def describe_collection_media(collection):
% {"count": media_count},
"url": url,
}
return None


class MediaAdminURLFinder(ModelAdminURLFinder):
Expand Down
2 changes: 0 additions & 2 deletions tests/testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ROOT_URLCONF = "testapp.urls"

STATIC_URL = "/static/"
STATIC_ROOT = STATIC_ROOT

STATICFILES_FINDERS = ("django.contrib.staticfiles.finders.AppDirectoriesFinder",)

Expand All @@ -44,7 +43,6 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.template.context_processors.request",
"wagtail.contrib.settings.context_processors.settings",
],
"debug": True,
Expand Down
Loading