-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ccbead
commit f3ec32a
Showing
5 changed files
with
55 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import logging | ||
|
||
from django.contrib import messages | ||
from django.contrib.auth.decorators import login_required | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.utils import timezone | ||
from django.views.decorators.http import require_POST | ||
|
||
from itou.job_applications.models import JobApplication | ||
from itou.utils.auth import check_user | ||
from itou.utils.perms.company import get_current_company_or_404 | ||
from itou.utils.urls import get_safe_url | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@login_required | ||
@check_user(lambda user: user.is_employer) | ||
@require_POST | ||
def archive(request): | ||
company = get_current_company_or_404(request) | ||
application_ids = request.POST.getlist("application_ids") | ||
archived_ids = [ | ||
application.pk | ||
for application in company.job_applications_received.filter(pk__in=application_ids).select_for_update() | ||
if application.can_be_archived | ||
] | ||
archived_nb = JobApplication.objects.filter(pk__in=archived_ids).update( | ||
archived_at=timezone.now(), | ||
archived_by=request.user, | ||
) | ||
|
||
if archived_nb > 1: | ||
messages.info(request, f"{archived_nb} candidatures archivées avec succès.", extra_tags="toast") | ||
else: | ||
messages.info(request, f"{archived_nb} candidature archivée avec succès.", extra_tags="toast") | ||
next_url = get_safe_url(request, "next_url", fallback_url=reverse("apply:list_for_siae")) | ||
logger.info( | ||
"user=%s batch archived %s applications: %s", | ||
request.user.pk, | ||
archived_nb, | ||
",".join(str(app_uid) for app_uid in archived_ids), | ||
) | ||
return HttpResponseRedirect(next_url) | ||
Check warning Code scanning / CodeQL URL redirection from remote source Medium
Untrusted URL redirection depends on a
user-provided value Error loading related location Loading |
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