Code review improvements to BulkRenameView label selector
- Use _meta.fields (concrete fields only) instead of _meta.get_fields() to check for label field presence; avoids iterating reverse relations - Simplify template column headers via blocktrans + field_name|title instead of duplicated if/else blocks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a2d0034789
commit
6c58b4e8c0
|
|
@ -894,7 +894,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
|
|||
"""
|
||||
if self.field_name != 'name':
|
||||
return []
|
||||
model_field_names = {f.name for f in self.queryset.model._meta.get_fields()}
|
||||
model_field_names = {f.name for f in self.queryset.model._meta.fields}
|
||||
if 'label' not in model_field_names:
|
||||
return []
|
||||
return [('name', _('Name')), ('label', _('Label'))]
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ Context:
|
|||
<div class="col col-md-7">
|
||||
<table class="table">
|
||||
<thead>
|
||||
{% with field_label=field_name|title %}
|
||||
<tr>
|
||||
<th>{% if field_name == 'label' %}{% trans "Current Label" %}{% else %}{% trans "Current Name" %}{% endif %}</th>
|
||||
<th>{% if field_name == 'label' %}{% trans "New Label" %}{% else %}{% trans "New Name" %}{% endif %}</th>
|
||||
<th>{% blocktrans %}Current {{ field_label }}{% endblocktrans %}</th>
|
||||
<th>{% blocktrans %}New {{ field_label }}{% endblocktrans %}</th>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for obj in selected_objects %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue