mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-04-28 19:34:53 +00:00
26 lines
851 B
Python
26 lines
851 B
Python
from rest_framework.response import Response
|
|
from rest_framework import status
|
|
from django.db.models import Model
|
|
from django.utils import translation
|
|
|
|
from audits.const import ActionChoices
|
|
from audits.handler import create_or_update_operate_log
|
|
|
|
|
|
class AccountRecordViewLogMixin(object):
|
|
get_object: callable
|
|
model: Model
|
|
|
|
def retrieve(self, request, *args, **kwargs):
|
|
retrieve_func = getattr(super(), 'retrieve')
|
|
if not callable(retrieve_func):
|
|
return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED)
|
|
response = retrieve_func(request, *args, **kwargs)
|
|
with translation.override('en'):
|
|
create_or_update_operate_log(
|
|
ActionChoices.view, self.model._meta.verbose_name,
|
|
force=True, resource=self.get_object(),
|
|
)
|
|
return response
|
|
|