Skip to content

Commit

Permalink
apply: use request.organizations
Browse files Browse the repository at this point in the history
instead of member_required since we already have the membership info
  • Loading branch information
xavfernandez committed Dec 16, 2024
1 parent 350e5e8 commit bfbcc0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 3 additions & 1 deletion itou/www/apply/views/process_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ class AcceptHTMXFragmentView(TemplateView):
def setup(self, request, company_pk=None, *args, **kwargs):
super().setup(request, *args, **kwargs)

company = get_object_or_404(Company.objects.member_required(request.user), pk=company_pk)
company = get_object_or_404(
Company.objects.filter(pk__in={org.pk for org in request.organizations}), pk=company_pk
)
self.form_accept = AcceptForm(company=company, data=request.POST or None)

def get_context_data(self, **kwargs):
Expand Down
12 changes: 8 additions & 4 deletions itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,9 @@ def eligibility_for_hire(
job_seeker_public_id,
template_name="apply/submit/eligibility_for_hire.html",
):
company = get_object_or_404(Company.objects.member_required(request.user), pk=company_pk)
company = get_object_or_404(
Company.objects.filter(pk__in={org.pk for org in request.organizations}), pk=company_pk
)
job_seeker = get_object_or_404(User.objects.filter(kind=UserKind.JOB_SEEKER), public_id=job_seeker_public_id)
_check_job_seeker_approval(request, job_seeker, company)
next_url = reverse(
Expand Down Expand Up @@ -852,7 +854,7 @@ def geiq_eligibility_for_hire(
template_name="apply/submit/geiq_eligibility_for_hire.html",
):
company = get_object_or_404(
Company.objects.member_required(request.user).filter(kind=CompanyKind.GEIQ), pk=company_pk
Company.objects.filter(pk__in={org.pk for org in request.organizations}, kind=CompanyKind.GEIQ), pk=company_pk
)
job_seeker = get_object_or_404(User.objects.filter(kind=UserKind.JOB_SEEKER), public_id=job_seeker_public_id)
next_url = reverse(
Expand Down Expand Up @@ -884,7 +886,7 @@ 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
Company.objects.filter(pk__in={org.pk for org in request.organizations}, kind=CompanyKind.GEIQ), pk=company_pk
)
job_seeker = get_object_or_404(User.objects.filter(kind=UserKind.JOB_SEEKER), public_id=job_seeker_public_id)
return common_views._geiq_eligibility_criteria(
Expand All @@ -901,7 +903,9 @@ def hire_confirmation(
job_seeker_public_id,
template_name="apply/submit/hire_confirmation.html",
):
company = get_object_or_404(Company.objects.member_required(request.user), pk=company_pk)
company = get_object_or_404(
Company.objects.filter(pk__in={org.pk for org in request.organizations}), pk=company_pk
)
job_seeker = get_object_or_404(
User.objects.filter(kind=UserKind.JOB_SEEKER).select_related("jobseeker_profile"),
public_id=job_seeker_public_id,
Expand Down
10 changes: 1 addition & 9 deletions tests/www/apply/__snapshots__/test_submit.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,7 @@
"companies_company"."rdv_solidarites_id"
FROM "companies_company"
WHERE (NOT ("companies_company"."siret" = %s)
AND EXISTS
(SELECT %s AS "a"
FROM "companies_companymembership" U0
INNER JOIN "users_user" U2 ON (U0."user_id" = U2."id")
WHERE (U0."company_id" = ("companies_company"."id")
AND U0."is_active"
AND U0."user_id" = %s
AND U2."is_active")
LIMIT 1)
AND "companies_company"."id" IN (%s)
AND "companies_company"."id" = %s)
LIMIT 21
''',
Expand Down

0 comments on commit bfbcc0d

Please sign in to comment.