mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-30 13:55:41 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 4m12s
- Updated the `reverse_dhivehi_string` function to correct the range for combining characters. - Added new device handling in the health check view and integrated the `add_new_devices_to_omada` task. - Improved date handling in `CreateTemporaryUserView` to ensure proper string conversion. - Enhanced OTP sending by converting mobile numbers to strings. - Implemented MAC address validation in the `Device` model using a custom validator. - Removed unnecessary fields from the `CreateDeviceSerializer`. - Normalized MAC address format in the `DeviceListCreateAPIView`. - Updated the `djangopasswordlessknox` package to improve code consistency and readability. - Added migration to enforce MAC address validation in the database.
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from django.contrib import admin
|
|
from django.urls import reverse
|
|
from djangopasswordlessknox.models import CallbackToken
|
|
|
|
|
|
class UserLinkMixin(object):
|
|
"""
|
|
A mixin to add a linkable list_display user field.
|
|
"""
|
|
|
|
LINK_TO_USER_FIELD = "link_to_user"
|
|
|
|
def link_to_user(self, obj):
|
|
link = reverse("admin:users_user_change", args=[obj.user.id])
|
|
return "<a href={}>{}</a>".format(link, obj.user.username)
|
|
|
|
link_to_user.allow_tags = True
|
|
link_to_user.short_description = "User"
|
|
|
|
|
|
class AbstractCallbackTokenInline(admin.StackedInline):
|
|
max_num = 0
|
|
extra = 0
|
|
readonly_fields = ("created_at", "key", "is_active")
|
|
fields = ("created_at", "user", "key", "is_active")
|
|
|
|
|
|
class CallbackInline(AbstractCallbackTokenInline):
|
|
model = CallbackToken
|
|
|
|
|
|
class AbstractCallbackTokenAdmin(UserLinkMixin, admin.ModelAdmin):
|
|
readonly_fields = ("created_at", "user", "key")
|
|
list_display = ("created_at", UserLinkMixin.LINK_TO_USER_FIELD, "key", "is_active")
|
|
fields = ("created_at", "user", "key", "is_active")
|
|
extra = 0
|