Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updation in resume functionaliy. #60

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 12 additions & 62 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,18 +703,27 @@ def reupload_documents(self, request, pk=None):
# Resume re-upload
resume_data = request.FILES.get("resume")
if resume_data:
# Delete the previous resume if it exists
if user.resume:
user.resume.delete()
user.resume = resume_data
user.save()

# Profile Picture re-upload
profile_picture_data = request.FILES.get("profile_picture")
if profile_picture_data:
# Delete the previous profile picture if it exists
if user.profile_picture:
user.profile_picture.delete()
user.profile_picture = profile_picture_data
user.save()

# Cover Letter re-upload
cover_letter_data = request.FILES.get("cover_letter")
if cover_letter_data:
# Delete the previous cover letter if it exists
if user.cover_letter:
user.cover_letter.delete()
user.cover_letter = cover_letter_data
user.save()

Expand All @@ -738,11 +747,11 @@ def download_documents(self, request, pk=None):
file_path = None

# Determine the file path based on the requested document type
if document_type == "resume":
if document_type == values.RESUME_DOCUMENT_TYPE:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the changes for these constants ?

file_path = user.resume.path
elif document_type == "profile_picture":
elif document_type == values.PROFILE_PICTURE_DOCUMENT_TYPE:
file_path = user.profile_picture.path
elif document_type == "cover_letter":
elif document_type == values.COVER_LETTER_DOCUMENT_TYPE:
file_path = user.cover_letter.path

if not file_path or not os.path.exists(file_path):
Expand All @@ -753,65 +762,6 @@ def download_documents(self, request, pk=None):
# Serve the file using Django FileResponse
return FileResponse(open(file_path, "rb"), as_attachment=True)

@action(detail=True, methods=["delete"])
def remove_documents(self, request, pk=None):
"""
API: /api/v1/user/{pk}/remove-documents
Allows users to remove their documents (resume, profile picture, cover letter).
"""
user = User.objects.get(user_id=pk)
if not user:
return response.create_response(
"User does not exist", status.HTTP_404_NOT_FOUND
)

document_type = request.query_params.get("document_type", "")
if not document_type:
return response.create_response(
"Please provide a valid document_type query parameter",
status.HTTP_400_BAD_REQUEST,
)

# Remove the document based on the requested document type
if document_type == "resume":
user.resume = None
elif document_type == "profile_picture":
user.profile_picture = None
elif document_type == "cover_letter":
user.cover_letter = None

user.save()

return response.create_response(
f"{document_type.capitalize()} removed successfully", status.HTTP_200_OK
)

@action(detail=False, methods=["post"])
def retrive_users(self, request):
"""
to retrive user as per the filters in the post body.
"""

data = request.data
qualification = data.get("qualification", None)
experience = data.get("experience", None)
location = data.get("location", None)

queryset = User.objects.all()

if qualification:
queryset = queryset.filter(qualification__icontains=qualification)

if experience is not None:
queryset = queryset.filter(experience=experience)

if location:
queryset = queryset.filter(address__icontains=location)

serialized_data = UserSerializer(queryset, many=True)
return Response(serialized_data.data, status=status.HTTP_200_OK)


class CompanyViewSets(viewsets.ModelViewSet):
"""
Company object viewsets
Expand Down