changes in task list API and add special character in password for added junior

This commit is contained in:
jain
2023-09-04 15:02:47 +05:30
parent 7b75a3233c
commit 20fa6e43da
4 changed files with 48 additions and 10 deletions

View File

@ -1,6 +1,6 @@
"""Account utils"""
from celery import shared_task
import random
"""Import django"""
from django.conf import settings
from rest_framework import viewsets, status
@ -289,3 +289,27 @@ def get_user_full_name(user_obj):
to get user's full name
"""
return f"{user_obj.first_name} {user_obj.last_name}" if user_obj.first_name or user_obj.last_name else "User"
def make_special_password(length=10):
# Define character sets
lowercase_letters = string.ascii_lowercase
uppercase_letters = string.ascii_uppercase
digits = string.digits
special_characters = '!@#$%^&*()_-+=<>?/[]{}|'
# Combine character sets
all_characters = lowercase_letters + uppercase_letters + digits + special_characters
# Create a password with random characters
password = (
random.choice(lowercase_letters) +
random.choice(uppercase_letters) +
random.choice(digits) +
random.choice(special_characters) +
''.join(random.choice(all_characters) for _ in range(length - 4))
)
# Shuffle the characters to make it more random
password_list = list(password)
random.shuffle(password_list)
return ''.join(password_list)