-
Notifications
You must be signed in to change notification settings - Fork 1
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
1481 implement similar positions on recruitmentapplicationformpage #1596
Open
Snorre98
wants to merge
14
commits into
master
Choose a base branch
from
1481-implement-similar-positions-on-recruitmentapplicationformpage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b43514b
adds view to fetch positions by tags
Snorre98 2895c79
adds tag field and norwegian applicants only to recruitment position …
Snorre98 9a2ebf8
removes TODO comment
Snorre98 82a1272
adds ulr routes
Snorre98 858f478
modifies seed script to use more realistic tags for positions
Snorre98 292df20
creates api call to fetch positions by tags
Snorre98 8bb851b
fetches similar positions on recruitment position page
Snorre98 36523f1
rrruff
Snorre98 9631bfb
moves useState
Snorre98 7329e78
removes duplicate backend route
Snorre98 520e311
adds tests for fetching positions by tags
Snorre98 2e4eb5e
changed persmission class so that positions by same tags can be viewe…
Snorre98 50c1499
removes test for authentication user
Snorre98 06f8a30
removes duplicate route
Snorre98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
import csv | ||
import hmac | ||
import hashlib | ||
import operator | ||
from typing import Any | ||
from functools import reduce | ||
|
||
from guardian.shortcuts import get_objects_for_user | ||
|
||
|
@@ -1342,3 +1344,52 @@ def post(self, request: Request) -> Response: | |
form=purchase_model, | ||
) | ||
return Response(status=status.HTTP_201_CREATED, data={'message': 'Feedback submitted successfully!'}) | ||
|
||
|
||
class PositionByTagsView(ListAPIView): | ||
""" | ||
Fetches recruitment positions by common tags for a specific recruitment. | ||
Expects tags as query parameter in format: ?tags=tag1,tag2,tag3 | ||
Optionally accepts position_id parameter to exclude current position | ||
""" | ||
|
||
permission_classes = [AllowAny] | ||
serializer_class = RecruitmentPositionForApplicantSerializer | ||
|
||
def get_queryset(self) -> QuerySet: | ||
recruitment_id = self.kwargs.get('id') | ||
tags_param = self.request.query_params.get('tags') | ||
Comment on lines
+1360
to
+1361
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funker det ikke å bruke getlist her? |
||
current_position_id = self.request.query_params.get('position_id') | ||
|
||
if not tags_param: | ||
return RecruitmentPosition.objects.none() | ||
|
||
# Split and clean the tags | ||
tags = [tag.strip() for tag in tags_param.split(',') if tag.strip()] | ||
|
||
if not tags: | ||
return RecruitmentPosition.objects.none() | ||
|
||
# Create Q objects for each tag to search in the tags field | ||
tag_queries = [Q(tags__icontains=tag) for tag in tags] | ||
|
||
# Combine queries with OR operator | ||
combined_query = reduce(operator.or_, tag_queries) | ||
|
||
# Base queryset with recruitment and tag filtering | ||
queryset = RecruitmentPosition.objects.filter(combined_query, recruitment_id=recruitment_id).select_related('gang') | ||
|
||
# Exclude current position if position_id is provided | ||
if current_position_id: | ||
queryset = queryset.exclude(id=current_position_id) | ||
|
||
return queryset | ||
|
||
def list(self, request: Request, *args: Any, **kwargs: Any) -> Response: | ||
if not request.query_params.get('tags'): | ||
return Response({'message': 'No tags provided in query parameters'}, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
queryset = self.get_queryset() | ||
serializer = self.get_serializer(queryset, many=True) | ||
|
||
return Response({'count': len(serializer.data), 'positions': serializer.data}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kan kanskje være litt forvirrende om navn og tags ikke stemmer? Ikke så farlig for meg assa