Skip to content

Commit

Permalink
Remove now useless @login_required decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Dec 12, 2024
1 parent 8b72762 commit ca11dc5
Show file tree
Hide file tree
Showing 19 changed files with 8 additions and 193 deletions.
3 changes: 0 additions & 3 deletions itou/www/apply/views/edit_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
Expand All @@ -12,7 +11,6 @@
from itou.www.apply.forms import EditHiringDateForm


@login_required
def edit_contract_start_date(request, job_application_id, template_name="apply/edit_contract_start_date.html"):
"""
Update contract start date:
Expand Down Expand Up @@ -51,7 +49,6 @@ def edit_contract_start_date(request, job_application_id, template_name="apply/e
return render(request, template_name, context)


@login_required
@require_POST
def archive_view(request, job_application_id, *, action):
extra_filters = {}
Expand Down
8 changes: 0 additions & 8 deletions itou/www/apply/views/list_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from collections import defaultdict

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.db import models
from django.db.models import Count, Exists, F, OuterRef, Q, Subquery
from django.shortcuts import render
Expand Down Expand Up @@ -102,7 +101,6 @@ def _add_administrative_criteria(job_applications):
job_application.preloaded_administrative_criteria_extra_nb = extra_nb


@login_required
@check_user(lambda u: u.is_job_seeker)
def list_for_job_seeker(request, template_name="apply/list_for_job_seeker.html"):
"""
Expand Down Expand Up @@ -179,7 +177,6 @@ def annotate_title(base_title, archived_choice):
raise ValueError(archived_choice)


@login_required
@check_user(lambda u: u.is_prescriber or u.is_employer)
def list_prescriptions(request, template_name="apply/list_prescriptions.html"):
"""
Expand Down Expand Up @@ -227,7 +224,6 @@ def list_prescriptions(request, template_name="apply/list_prescriptions.html"):
)


@login_required
@check_user(lambda u: u.is_prescriber or u.is_employer)
def list_prescriptions_exports(request, template_name="apply/list_of_available_exports.html"):
"""
Expand All @@ -248,7 +244,6 @@ def list_prescriptions_exports(request, template_name="apply/list_of_available_e
return render(request, template_name, context)


@login_required
@check_user(lambda u: u.is_prescriber or u.is_employer)
def list_prescriptions_exports_download(request, month_identifier=None):
"""
Expand All @@ -267,7 +262,6 @@ def list_prescriptions_exports_download(request, month_identifier=None):
return stream_xlsx_export(job_applications, filename, request_user=request.user)


@login_required
def list_for_siae(request, template_name="apply/list_for_siae.html"):
"""
List of applications for an SIAE.
Expand Down Expand Up @@ -356,7 +350,6 @@ def list_for_siae(request, template_name="apply/list_for_siae.html"):
)


@login_required
def list_for_siae_exports(request, template_name="apply/list_of_available_exports.html"):
"""
List of applications for a SIAE, sorted by month, displaying the count of applications per month
Expand All @@ -378,7 +371,6 @@ def list_for_siae_exports(request, template_name="apply/list_of_available_export
return render(request, template_name, context)


@login_required
def list_for_siae_exports_download(request, month_identifier=None):
"""
List of applications for a SIAE for a given month identifier (YYYY-mm),
Expand Down
15 changes: 0 additions & 15 deletions itou/www/apply/views/process_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sentry_sdk
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.db import transaction
Expand Down Expand Up @@ -82,7 +81,6 @@ def _get_geiq_eligibility_diagnosis(job_application, only_prescriber):
).first()


@login_required
def details_for_jobseeker(request, job_application_id, template_name="apply/process_details.html"):
"""
Detail of an application for a JOBSEEKER
Expand Down Expand Up @@ -160,7 +158,6 @@ def details_for_jobseeker(request, job_application_id, template_name="apply/proc
return render(request, template_name, context)


@login_required
def details_for_company(request, job_application_id, template_name="apply/process_details_company.html"):
"""
Detail of an application for an SIAE with the ability:
Expand Down Expand Up @@ -273,7 +270,6 @@ def details_for_company(request, job_application_id, template_name="apply/proces
return render(request, template_name, context)


@login_required
@check_user(lambda u: u.is_prescriber or u.is_employer)
def details_for_prescriber(request, job_application_id, template_name="apply/process_details.html"):
"""
Expand Down Expand Up @@ -355,7 +351,6 @@ def details_for_prescriber(request, job_application_id, template_name="apply/pro
return render(request, template_name, context)


@login_required
@require_POST
def process(request, job_application_id):
queryset = JobApplication.objects.is_active_company_member(request.user)
Expand Down Expand Up @@ -496,7 +491,6 @@ def get_step_url(self, step):
return reverse(f"apply:{self.url_name}", kwargs={"job_application_id": self.job_application.pk, "step": step})


@login_required
def postpone(request, job_application_id, template_name="apply/process_postpone.html"):
queryset = JobApplication.objects.is_active_company_member(request.user)
job_application = get_object_or_404(queryset, id=job_application_id)
Expand Down Expand Up @@ -529,7 +523,6 @@ def postpone(request, job_application_id, template_name="apply/process_postpone.
return render(request, template_name, context)


@login_required
def accept(request, job_application_id, template_name="apply/process_accept.html"):
"""
Trigger the `accept` transition.
Expand Down Expand Up @@ -595,7 +588,6 @@ class ReloadJobDescriptionFields(AcceptHTMXFragmentView):
NO_ERROR_FIELDS = ("appellation", "location")


@login_required
@require_POST
def cancel(request, job_application_id):
"""
Expand All @@ -619,7 +611,6 @@ def cancel(request, job_application_id):
return HttpResponseRedirect(next_url)


@login_required
def transfer(request, job_application_id):
queryset = JobApplication.objects.is_active_company_member(request.user)
job_application = get_object_or_404(queryset, pk=job_application_id)
Expand Down Expand Up @@ -879,7 +870,6 @@ def get_context_data(self, **kwargs):
}


@login_required
@require_POST
def send_diagoriente_invite(request, job_application_id):
"""
Expand All @@ -900,7 +890,6 @@ def send_diagoriente_invite(request, job_application_id):
return HttpResponseRedirect(redirect_url)


@login_required
def eligibility(request, job_application_id, template_name="apply/process_eligibility.html"):
"""
Check eligibility (as an SIAE).
Expand All @@ -923,7 +912,6 @@ def eligibility(request, job_application_id, template_name="apply/process_eligib
)


@login_required
def geiq_eligibility(request, job_application_id, template_name="apply/process_geiq_eligibility.html"):
queryset = JobApplication.objects.is_active_company_member(request.user)
# Check GEIQ eligibility during job application process
Expand All @@ -946,7 +934,6 @@ def geiq_eligibility(request, job_application_id, template_name="apply/process_g
)


@login_required
def geiq_eligibility_criteria(
request,
job_application_id,
Expand Down Expand Up @@ -999,7 +986,6 @@ def delete_prior_action(request, job_application_id, prior_action_id):
return HttpResponse(content)


@login_required
def add_or_modify_prior_action(request, job_application_id, prior_action_id=None):
queryset = JobApplication.objects.is_active_company_member(request.user)
job_application = get_object_or_404(
Expand Down Expand Up @@ -1099,7 +1085,6 @@ def add_or_modify_prior_action(request, job_application_id, prior_action_id=None
return render(request, "apply/includes/job_application_prior_action_form.html", context)


@login_required
@require_POST
def rdv_insertion_invite(request, job_application_id, for_detail=False):
if not request.user.is_employer:
Expand Down
5 changes: 0 additions & 5 deletions itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import uuid

from dateutil.relativedelta import relativedelta
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.core.files.storage import storages
from django.forms import ValidationError
Expand Down Expand Up @@ -782,7 +781,6 @@ def get_context_data(self, **kwargs):
}


@login_required
def eligibility_for_hire(
request,
company_pk,
Expand Down Expand Up @@ -817,7 +815,6 @@ def eligibility_for_hire(
)


@login_required
def geiq_eligibility_for_hire(
request,
company_pk,
Expand Down Expand Up @@ -854,7 +851,6 @@ def geiq_eligibility_for_hire(
)


@login_required
def geiq_eligibility_criteria_for_hire(request, company_pk, job_seeker_public_id):
company = get_object_or_404(
Company.objects.member_required(request.user).filter(kind=CompanyKind.GEIQ), pk=company_pk
Expand All @@ -867,7 +863,6 @@ def geiq_eligibility_criteria_for_hire(request, company_pk, job_seeker_public_id
)


@login_required
def hire_confirmation(
request,
company_pk,
Expand Down
10 changes: 0 additions & 10 deletions itou/www/approvals_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from datetime import timedelta

from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import UserPassesTestMixin
from django.core.exceptions import PermissionDenied
from django.core.files.storage import default_storage
Expand Down Expand Up @@ -74,7 +73,6 @@ def get_context_data(self, **kwargs):


# TODO(xfernandez): remove this redirect view in a few weeks
@login_required
def approval_detail_redirect_to_employee_view(request, pk):
siae = get_current_company_or_404(request)

Expand Down Expand Up @@ -308,7 +306,6 @@ def prolongation_back_url(request):
return get_safe_url(request, "back_url", fallback_url=reverse("dashboard:index"))


@login_required
def declare_prolongation(request, approval_id, template_name="approvals/declare_prolongation.html"):
"""
Declare a prolongation for the given approval.
Expand Down Expand Up @@ -468,7 +465,6 @@ class CheckContactDetailsView(DeclareProlongationHTMXFragmentView):
clear_errors = ("contact_email", "contact_phone")


@login_required
def prolongation_requests_list(request, template_name="approvals/prolongation_requests/list.html"):
current_organization = get_current_org_or_404(request)
if not current_organization.is_authorized:
Expand All @@ -491,7 +487,6 @@ def prolongation_requests_list(request, template_name="approvals/prolongation_re


@require_safe
@login_required
def prolongation_request_report_file(request, prolongation_request_id):
prolongation_request = get_object_or_404(
ProlongationRequest,
Expand Down Expand Up @@ -588,7 +583,6 @@ def get_step_url(self, step):
return reverse(self.url_name, kwargs={"prolongation_request_id": self.prolongation_request.pk, "step": step})


@login_required
def suspend(request, approval_id, template_name="approvals/suspend.html"):
siae = get_current_company_or_404(request)
approval = get_object_or_404(Approval, pk=approval_id)
Expand Down Expand Up @@ -623,7 +617,6 @@ def suspend(request, approval_id, template_name="approvals/suspend.html"):
return render(request, template_name, context)


@login_required()
def suspension_action_choice(request, suspension_id, template_name="approvals/suspension_action_choice.html"):
siae = get_current_company_or_404(request)
suspension = get_object_or_404(
Expand Down Expand Up @@ -666,7 +659,6 @@ def suspension_action_choice(request, suspension_id, template_name="approvals/su
return render(request, template_name, context)


@login_required
def suspension_update(request, suspension_id, template_name="approvals/suspension_update.html"):
"""
Edit the given suspension.
Expand Down Expand Up @@ -705,7 +697,6 @@ def suspension_update(request, suspension_id, template_name="approvals/suspensio
return render(request, template_name, context)


@login_required()
def suspension_update_enddate(request, suspension_id, template_name="approvals/suspension_update_enddate.html"):
siae = get_current_company_or_404(request)
suspension = get_object_or_404(
Expand Down Expand Up @@ -748,7 +739,6 @@ def suspension_update_enddate(request, suspension_id, template_name="approvals/s
return render(request, template_name, context)


@login_required
def suspension_delete(request, suspension_id, template_name="approvals/suspension_delete.html"):
"""
Delete the given suspension.
Expand Down
3 changes: 1 addition & 2 deletions itou/www/autocomplete/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from django.contrib.auth.decorators import login_not_required, login_required
from django.contrib.auth.decorators import login_not_required
from django.db.models import F, Q, Value
from django.db.models.functions import Least, Lower, NullIf, StrIndex
from django.http import JsonResponse
Expand Down Expand Up @@ -126,7 +126,6 @@ def communes_autocomplete(request):
return JsonResponse({"results": communes}, safe=False)


@login_required
@check_user(is_allowed_to_use_gps_advanced_features)
def gps_users_autocomplete(request):
"""
Expand Down
Loading

0 comments on commit ca11dc5

Please sign in to comment.