Bulk rename URL resolution should fail silently

This commit is contained in:
Jeremy Stretch 2025-07-01 09:27:55 -04:00
parent 1333b964d9
commit 2927b8dae1
2 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,5 @@
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
from django.utils.translation import gettext as _
from core.models import ObjectType
@ -42,7 +43,10 @@ class ObjectAction:
kwargs = {
kwarg: getattr(obj, kwarg) for kwarg in cls.url_kwargs
}
return reverse(viewname, kwargs=kwargs)
try:
return reverse(viewname, kwargs=kwargs)
except NoReverseMatch:
return
@classmethod
def get_context(cls, context, obj):

View File

@ -1,3 +1,5 @@
<button type="submit" name="_rename" {% formaction %}="{{ url }}" class="btn btn-yellow">
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
</button>
{% if url %}
<button type="submit" name="_rename" {% formaction %}="{{ url }}" class="btn btn-yellow">
<i class="mdi mdi-pencil" aria-hidden="true"></i> {{ label }}
</button>
{% endif %}