Skip to content

Commit

Permalink
fix: only 1 application for position per user enforced
Browse files Browse the repository at this point in the history
  • Loading branch information
magsyg committed Dec 16, 2024
1 parent b82cc8b commit 7cb4bb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ def clean(self, *args: tuple, **kwargs: dict) -> None: # noqa: C901
current_application = RecruitmentApplication.objects.filter(
pk=self.pk).first()
# validates if there are not two applications for same user and same recruitmentposition
if not current_application and RecruitmentApplication.objects.filter(user=self.user, recruitment=self.recruitment, recruitment_position=self.recruitment_position).first():
if not current_application and RecruitmentApplication.objects.filter(
user=self.user,
recruitment=self.recruitment,
recruitment_position=self.recruitment_position).first():
errors['recruitment_position'].append(self.ALREADY_APPLIED_ERROR)
# If there is max applications, check if applicant have applied to not to many
if self.recruitment.max_applications:
Expand Down
2 changes: 1 addition & 1 deletion backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from django.shortcuts import get_object_or_404
from django.contrib.auth import login, logout, update_session_auth_hash
from django.utils.encoding import force_bytes
from django.core.exceptions import ValidationError
from django.middleware.csrf import get_token
from django.utils.decorators import method_decorator
from django.core.exceptions import ValidationError
from django.contrib.auth.models import Group, Permission
from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie

Expand Down

0 comments on commit 7cb4bb5

Please sign in to comment.