UnisKB/apps/users/views/common.py

33 lines
786 B
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# coding=utf-8
"""
@project: MaxKB
@Author
@file common.py
@date2025/3/25 16:46
@desc:
"""
from common.util.common import encryption
from users.models import User
from django.db.models import QuerySet
def get_user_operation_object(user_id):
user_model = QuerySet(model=User).filter(id=user_id).first()
if user_model is not None:
return {
"name": user_model.username
}
return {}
def get_re_password_details(request):
path = request.path
body = request.data
query = request.query_params
return {
'path': path,
'body': {**body, 'password': encryption(body.get('password', '')),
're_password': encryption(body.get('re_password', ''))},
'query': query
}