Skip to content

Commit

Permalink
Модель OTPDevice скрыта.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeWazowskyi committed Sep 5, 2023
1 parent be6cdc7 commit afa7d69
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import Group, Permission
from django.utils.translation import gettext_lazy as _
from django_otp.plugins.otp_email.models import EmailDevice

from .forms import UserChangeForm, UserCreationForm
from .models import User
Expand Down Expand Up @@ -80,6 +81,17 @@ def reset_password(self, request, queryset):
admin.site.unregister(Group)


class OTPDevice(admin.ModelAdmin):
"""Empty class to hide OTPDevice model."""

def get_model_perms(self, request):
"""Return empty perms dict thus hiding the model from admin."""
return {}


admin.site.register(EmailDevice, OTPDevice)


def permissions_new_unicode(self):
"""Translate default permissions."""
class_name = str(self.content_type)
Expand Down

0 comments on commit afa7d69

Please sign in to comment.