mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
Merge pull request #303 from KiwiTechLLC/sprint6-bugs
handle scenerio for task after disassociate
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
{% extends "templated_email/email_base.email" %}
|
||||
|
||||
{% block subject %}
|
||||
{{subject}}
|
||||
Support Mail
|
||||
{% endblock %}
|
||||
|
||||
{% block plain %}
|
||||
|
@ -167,7 +167,7 @@ def user_device_details(user, device_id):
|
||||
return False
|
||||
|
||||
|
||||
def send_support_email(name, sender, subject, message):
|
||||
def send_support_email(name, sender, message):
|
||||
"""Send otp on email with template"""
|
||||
to_email = [settings.EMAIL_FROM_ADDRESS]
|
||||
from_email = settings.DEFAULT_ADDRESS
|
||||
@ -179,7 +179,6 @@ def send_support_email(name, sender, subject, message):
|
||||
context={
|
||||
'name': name.title(),
|
||||
'sender': sender,
|
||||
'subject': subject,
|
||||
'message': message
|
||||
}
|
||||
)
|
||||
|
@ -689,11 +689,10 @@ class SendSupportEmail(views.APIView):
|
||||
def post(self, request):
|
||||
name = request.data.get('name')
|
||||
sender = request.data.get('email')
|
||||
subject = request.data.get('subject')
|
||||
message = request.data.get('message')
|
||||
if name and sender and subject and message:
|
||||
if name and sender and message:
|
||||
try:
|
||||
send_support_email(name, sender, subject, message)
|
||||
send_support_email(name, sender, message)
|
||||
return custom_response(SUCCESS_CODE['3019'], response_status=status.HTTP_200_OK)
|
||||
except Exception as e:
|
||||
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
||||
|
@ -111,7 +111,10 @@ ERROR_CODE = {
|
||||
"2080": "Can not add App version",
|
||||
"2081": "A junior can only be associated with a maximum of 3 guardian",
|
||||
# guardian code not exist
|
||||
"2082": "Guardian code does not exist"
|
||||
"2082": "Guardian code does not exist",
|
||||
"2083": "You can not start this task because guardian is not associate with you",
|
||||
"2084": "You can not complete this task because guardian is not associate with you",
|
||||
"2085": "You can not take action on this task because junior is not associate with you"
|
||||
|
||||
}
|
||||
"""Success message code"""
|
||||
|
@ -237,6 +237,7 @@ class TaskSerializer(serializers.ModelSerializer):
|
||||
tasks_created = []
|
||||
|
||||
for junior_id in junior_data:
|
||||
# create task
|
||||
task_data = validated_data.copy()
|
||||
task_data['guardian'] = guardian
|
||||
task_data['default_image'] = images
|
||||
|
@ -208,7 +208,8 @@ class CreateTaskAPIView(viewsets.ModelViewSet):
|
||||
else:
|
||||
filename = f"images/{image}"
|
||||
if image and image.size == NUMBER['zero']:
|
||||
return custom_error_response(ERROR_CODE['2035'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
return custom_error_response(ERROR_CODE['2035'],
|
||||
response_status=status.HTTP_400_BAD_REQUEST)
|
||||
image_url = upload_image_to_alibaba(image, filename)
|
||||
image_data = image_url
|
||||
data.pop('default_image')
|
||||
@ -357,6 +358,8 @@ class ApproveTaskAPIView(viewsets.ModelViewSet):
|
||||
task_queryset = JuniorTask.objects.filter(id=self.request.data.get('task_id'),
|
||||
guardian=guardian,
|
||||
junior=self.request.data.get('junior_id')).last()
|
||||
if task_queryset and guardian.guardian_code not in task_queryset.junior.guardian_code:
|
||||
return custom_error_response(ERROR_CODE['2084'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
if task_queryset and (task_queryset.junior.is_deleted or not task_queryset.junior.is_active):
|
||||
return custom_error_response(ERROR_CODE['2072'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
# use ApproveJuniorSerializer serializer
|
||||
|
@ -409,10 +409,12 @@ class CompleteJuniorTaskAPIView(views.APIView):
|
||||
task_queryset = JuniorTask.objects.filter(id=task_id, junior__auth__email=self.request.user
|
||||
).select_related('guardian', 'junior').last()
|
||||
if task_queryset:
|
||||
if task_queryset.junior.is_deleted or not task_queryset.junior.is_active:
|
||||
if task_queryset.guardian.guardian_code not in task_queryset.junior.guardian_code:
|
||||
return custom_error_response(ERROR_CODE['2085'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
elif task_queryset.junior.is_deleted or not task_queryset.junior.is_active:
|
||||
return custom_error_response(ERROR_CODE['2074'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
# use CompleteTaskSerializer serializer
|
||||
if task_queryset.task_status in [str(NUMBER['four']), str(NUMBER['five'])]:
|
||||
elif task_queryset.task_status in [str(NUMBER['four']), str(NUMBER['five'])]:
|
||||
"""Already request send """
|
||||
return custom_error_response(ERROR_CODE['2049'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
serializer = CompleteTaskSerializer(task_queryset, data={'image': image_url}, partial=True)
|
||||
@ -517,7 +519,10 @@ class StartTaskAPIView(views.APIView):
|
||||
try:
|
||||
task_id = self.request.data.get('task_id')
|
||||
task_queryset = JuniorTask.objects.filter(id=task_id, junior__auth__email=self.request.user).last()
|
||||
print("task_queryset==>",task_queryset)
|
||||
if task_queryset and task_queryset.task_status == str(NUMBER['one']):
|
||||
if task_queryset.guardian.guardian_code not in task_queryset.junior.guardian_code:
|
||||
return custom_error_response(ERROR_CODE['2083'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||
# use StartTaskSerializer serializer
|
||||
serializer = StartTaskSerializer(task_queryset, data=request.data, partial=True)
|
||||
if serializer.is_valid():
|
||||
|
@ -22,7 +22,7 @@ ARTICLE_REWARD_POINTS = 17
|
||||
REMOVE_JUNIOR = 18
|
||||
|
||||
TEST_NOTIFICATION = 99
|
||||
|
||||
# notification dictionary
|
||||
NOTIFICATION_DICT = {
|
||||
REGISTRATION: {
|
||||
"title": "Successfully registered!",
|
||||
|
Reference in New Issue
Block a user