Skip to content
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

Feat/can access flag #1537

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ def test_academy_student__post__with_user_and_cohort_in_data(self):
"last_name": "McKornick",
"phone": "",
"status": "INVITED",
"id": 2,
}

self.assertEqual(json, expected)
Expand Down Expand Up @@ -1166,6 +1167,7 @@ def test_academy_student__post__with_user__it_ignore_the_param_plans(self):
"last_name": "McKornick",
"phone": "",
"status": "INVITED",
"id": 2,
}

self.assertEqual(json, expected)
Expand Down Expand Up @@ -1269,6 +1271,7 @@ def test_academy_student__post__without_user_in_data(self):
"last_name": "McKornick",
"phone": "",
"status": "INVITED",
"id": 2,
}

self.assertEqual(json, expected)
Expand Down Expand Up @@ -1407,6 +1410,7 @@ def test_academy_student__post__without_user_in_data__with_plan(self):
"first_name": "Kenny",
"last_name": "McKornick",
"phone": "",
"id": 2,
"status": "INVITED",
}

Expand Down Expand Up @@ -1569,6 +1573,7 @@ def test_academy_student__post__without_user_in_data__invite_already_exists__dif
"first_name": "Kenny",
"last_name": "McKornick",
"phone": "",
"id": 2,
"status": "INVITED",
}

Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_academy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_academy")

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_academy_id", kwargs={"academy_id": 1})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_city.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_city")

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_city_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_city_id", kwargs={"city_id": 1})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_country")

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_country_id", kwargs={"country_id": 1})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_student.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_student")

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_student_id", kwargs={"user_id_or_email": 1})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand All @@ -108,14 +108,14 @@ def test_location_url_(
url = reverse_lazy("v2:authenticate:app_student_id", kwargs={"user_id_or_email": "a"})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_user")

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
4 changes: 2 additions & 2 deletions breathecode/authenticate/tests/urls/v2/tests_app_user_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def test_location_url(
url = reverse_lazy("v2:authenticate:app_user_id", kwargs={"user_id": 1})

model = database.create(
app={
linked_services__app={
"require_an_agreement": False,
"slug": "rigobot",
**get_app_signature(),
},
)

service.sign_jwt(client, model.app)
service.sign_jwt(client, model.linked_services__app)
response = client.get(url)

json = response.json()
Expand Down
8 changes: 4 additions & 4 deletions breathecode/feedback/tests/tasks/tests_send_cohort_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_when_student_not_found(self):
"nps_survey",
model.user.email,
{
"SUBJECT": "How has been your experience at 4Geeks so far?",
"SUBJECT": "We need your feedback",
"MESSAGE": "Please take 5 minutes to give us feedback about your experience at the academy so far.",
"TRACKER_URL": f"https://hello.com/v1/feedback/survey/{model.survey.id}/tracker.png",
"BUTTON": "Answer the question",
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_when_an_email_is_sent(self):
"nps_survey",
model.user.email,
{
"SUBJECT": "How has been your experience at 4Geeks so far?",
"SUBJECT": "We need your feedback",
"MESSAGE": "Please take 5 minutes to give us feedback about your experience at the academy so far.",
"TRACKER_URL": f"https://hello.com/v1/feedback/survey/{model.survey.id}/tracker.png",
"BUTTON": "Answer the question",
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_when_an_email_is_sent_with_slack_team_and_user(self):
model.slack_user,
model.slack_team,
data={
"SUBJECT": "How has been your experience at 4Geeks so far?",
"SUBJECT": "We need your feedback",
"MESSAGE": "Please take 5 minutes to give us feedback about your experience at the academy so far.",
"TRACKER_URL": f"https://hello.com/v1/feedback/survey/{model.survey.id}/tracker.png",
"BUTTON": "Answer the question",
Expand All @@ -284,7 +284,7 @@ def test_when_an_email_is_sent_with_slack_team_and_user(self):
"nps_survey",
model.user.email,
{
"SUBJECT": "How has been your experience at 4Geeks so far?",
"SUBJECT": "We need your feedback",
"MESSAGE": "Please take 5 minutes to give us feedback about your experience at the academy so far.",
"TRACKER_URL": f"https://hello.com/v1/feedback/survey/{model.survey.id}/tracker.png",
"BUTTON": "Answer the question",
Expand Down
20 changes: 19 additions & 1 deletion breathecode/mentorship/permissions/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


def mentorship_service_by_url_param(context: ServiceContext, args: tuple, kwargs: dict) -> tuple[dict, tuple, dict]:

context["price"] = 0
request = context["request"]
consumable = None
Expand Down Expand Up @@ -72,6 +71,25 @@ def mentorship_service_by_url_param(context: ServiceContext, args: tuple, kwargs
)
)

if (
mentor_profile.user.id != request.user.id
and feature.is_enabled(
"payments.can_access",
context=feature.context(to="mentorship-service", user=request.user, mentorship_service=mentorship_service),
default=True,
)
is False
):
raise ValidationException(
translation(
lang,
en="You have been blocked from accessing this mentorship service",
es="Has sido bloqueado de acceder a este servicio de mentoría",
slug="mentorship-service-blocked",
),
code=403,
)

context["consumables"] = context["consumables"].filter(
mentorship_service_set__mentorship_services=mentorship_service
)
Expand Down
Loading
Loading