Aggiorno dall'upstream
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
__all__ = ["admin"]
|
||||
__all__ = ["admin", "confirm_action"]
|
||||
from .admin import AdminConfirmMixin # noqa
|
||||
from .admin import confirm_action # noqa
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import functools
|
||||
from typing import Dict
|
||||
from django.contrib.admin.exceptions import DisallowedModelAdminToField
|
||||
from django.contrib.admin.utils import flatten_fieldsets, unquote
|
||||
@@ -5,11 +6,11 @@ from django.core.cache import cache
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.template.response import TemplateResponse
|
||||
from django.contrib.admin.options import TO_FIELD_VAR
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.translation import gettext as _
|
||||
from django.contrib.admin import helpers
|
||||
from django.db.models import Model, ManyToManyField, FileField, ImageField
|
||||
from django.forms import ModelForm
|
||||
from django.utils.decorators import method_decorator
|
||||
from admin_confirm.utils import (
|
||||
log,
|
||||
get_admin_change_url,
|
||||
@@ -433,6 +434,7 @@ class AdminConfirmMixin:
|
||||
"app_label": opts.app_label,
|
||||
"model_name": opts.model_name,
|
||||
"opts": opts,
|
||||
"obj": obj,
|
||||
"changed_data": changed_data,
|
||||
"add": add,
|
||||
"save_as_new": SAVE_AS_NEW in request.POST,
|
||||
@@ -454,6 +456,7 @@ def confirm_action(func):
|
||||
return to the changelist without performing action.
|
||||
"""
|
||||
|
||||
@functools.wraps(func)
|
||||
def func_wrapper(modeladmin, request, queryset):
|
||||
# First called by `Go` which would not have confirm_action in params
|
||||
if request.POST.get("_confirm_action"):
|
||||
|
||||
@@ -106,5 +106,9 @@ class FileCache(object):
|
||||
|
||||
def delete_all(self):
|
||||
"Delete all cached file data from cache."
|
||||
self.cache.delete_many(self.cached_keys)
|
||||
self.cached_keys = []
|
||||
# Issue #46 Redis Cache errs if we call delete_many with an empty list - fixed in Django 4.2
|
||||
# Note: set_many() should check for empty data in redis too.
|
||||
# See: https://github.com/django/django/commit/608ab043f75f1f9c094de57d2fd678f522bb8243
|
||||
if self.cached_keys:
|
||||
self.cache.delete_many(self.cached_keys)
|
||||
self.cached_keys = []
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</tr>
|
||||
{% for field, values in changed_data.items %}
|
||||
<tr>
|
||||
<td>{{ field }}</td>
|
||||
<td>{% verbose_name obj field %}</td>
|
||||
<td>{{ values.0|format_change_data_field_value }}</td>
|
||||
<td>{{ values.1|format_change_data_field_value }}</td>
|
||||
</tr>
|
||||
|
||||
@@ -17,3 +17,9 @@ def format_change_data_field_value(field_value):
|
||||
return mark_safe(output)
|
||||
except Exception:
|
||||
return field_value
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def verbose_name(obj, fieldname):
|
||||
if obj:
|
||||
return obj._meta.get_field(fieldname).verbose_name
|
||||
|
||||
Reference in New Issue
Block a user