Skip to content
Open
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
8 changes: 0 additions & 8 deletions docs/developer/admin-utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ it easy to copy the fields contents.

Useful for auto-generated fields such as UUIDs, secret keys, tokens, etc.

Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing UUIDAdmin, this section no longer documents how to replicate the common “copy UUID” behavior. Consider adding a brief note here explaining that CopyableFieldsAdmin can replace UUIDAdmin by setting copyable_fields = ('uuid',) and defining a uuid() display method (as done in tests/test_project/admin.py).

Suggested change
To replicate the common "copy UUID" behavior previously provided by
``UUIDAdmin``, you can use ``CopyableFieldsAdmin`` by setting
``copyable_fields = ("uuid",)`` and defining a ``uuid()`` display method,
for example:
.. code-block:: python
from django.contrib import admin
from openwisp_utils.admin import CopyableFieldsAdmin
from .models import MyModel
@admin.register(MyModel)
class MyModelAdmin(CopyableFieldsAdmin):
copyable_fields = ("uuid",)
readonly_fields = ("uuid",)
def uuid(self, obj):
return obj.uuid
uuid.short_description = "UUID"

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemesifier is it necesaary to put this , or we can leave ?

``openwisp_utils.admin.UUIDAdmin``
----------------------------------

This class is a subclass of ``CopyableFieldsAdmin`` which sets ``uuid`` as
the only copyable field. This class is kept for backward compatibility and
convenience, since different models of various OpenWISP modules show
``uuid`` as the only copyable field.

``openwisp_utils.admin.ReceiveUrlAdmin``
----------------------------------------

Expand Down
16 changes: 0 additions & 16 deletions openwisp_utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ class Media:
js = ("admin/js/jquery.init.js", "openwisp-utils/js/copyable.js")


class UUIDAdmin(CopyableFieldsAdmin):
"""Sets `uuid` as copyable field.

Subclass of `CopyableFieldsAdmin`. This class is kept for backward
compatibility and convenience, since different models of various
OpenWISP modules show `uuid` as the only copyable field.
"""

copyable_fields = ("uuid",)

def uuid(self, obj):
return obj.pk

uuid.short_description = _("UUID")


class ReceiveUrlAdmin(ModelAdmin):
"""Adds a receive_url field.

Expand Down
10 changes: 8 additions & 2 deletions tests/test_project/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from django.utils.translation import gettext_lazy as _
from openwisp_utils.admin import (
AlwaysHasChangedMixin,
CopyableFieldsAdmin,
HelpTextStackedInline,
ReadOnlyAdmin,
ReceiveUrlAdmin,
TimeReadonlyAdminMixin,
UUIDAdmin,
)
from openwisp_utils.admin_theme.filters import (
AutocompleteFilter,
Expand Down Expand Up @@ -80,12 +80,18 @@ class OperatorInline(HelpTextStackedInline):


@admin.register(Project)
class ProjectAdmin(UUIDAdmin, ReceiveUrlAdmin):
class ProjectAdmin(CopyableFieldsAdmin, ReceiveUrlAdmin):
inlines = [OperatorInline]
list_display = ("name",)
fields = ("uuid", "name", "key", "receive_url")
readonly_fields = ("uuid", "receive_url")
receive_url_name = "receive_project"
copyable_fields = ("uuid",)

def uuid(self, obj):
return obj.pk

uuid.short_description = _("UUID")


class ShelfFilter(SimpleInputFilter):
Expand Down
Loading