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

fix: Portal 2361 #2371

Merged
merged 5 commits into from
Oct 22, 2024
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
22 changes: 16 additions & 6 deletions portal/templates/portal/coding_club.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,22 @@ <h4 class="mt-0">Python coding club</h4>
</p>
</div>
<div>
<form method="post", action="{% url 'download_student_pack' 4 %}" class="non-styled--form">
{% csrf_token %}
<button id="python_pack" download type="submit" class="button button--primary button--icon">
Download the Python coding club pack<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</button>
</form>
<!-- TODO: improve responsiveness -->
<div style="margin-bottom: 10px;">
<a id="grass_snakes_pack" download class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FKsC7tdyT6htj5JX1ig28%2FGrass%20Snakes%20Club.zip?alt=media&token=1f6e6f0e-1a10-4bef-a8f8-a20b0a59e4c0">
Lvl 1: Grass Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
</div>
<div style="margin-bottom: 10px;">
<a id="tiger_snakes_pack" download type="submit" class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FSIeSsvz348nXjNMcVPxx%2FTiger%20Snakes%20Club.zip?alt=media&token=872b383f-a209-4864-a0e0-26d7ba3a8d74">
Lvl 2: Tiger Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
</div>
<div>
<a id="cobra_snakes_pack" download type="submit" class="button button--primary button--icon" href="https://3289537671-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS5kw31UTGL8CPHU9skBS%2Fuploads%2FITTbTC8DVwr8LdCkN82d%2FCobra%20Club.zip?alt=media&token=bfd94842-cba9-45c7-892b-331bc82c33e9">
Lvl 3: Cobra Snakes<span class="iconify" data-icon="mdi:tray-arrow-down"></span>
</a>
</div>
</div>
</div>
</div>
Expand Down
41 changes: 0 additions & 41 deletions portal/tests/test_daily_activities.py

This file was deleted.

69 changes: 16 additions & 53 deletions portal/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@
)
from portal.strings.coding_club import CODING_CLUB_BANNER
from portal.strings.home_learning import HOME_LEARNING_BANNER
from portal.strings.ten_year_map import (
TEN_YEAR_MAP_BANNER,
TEN_YEAR_MAP_HEADLINE,
)
from portal.strings.ten_year_map import TEN_YEAR_MAP_BANNER, TEN_YEAR_MAP_HEADLINE
from portal.templatetags.app_tags import cloud_storage
from portal.views.teacher.teach import (
DownloadType,
count_student_pack_downloads_click,
)
from portal.views.teacher.teach import DownloadType, count_student_pack_downloads_click

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -71,15 +65,11 @@
invalid_form = False

teacher_signup_form = TeacherSignupForm(prefix="teacher_signup")
independent_student_signup_form = IndependentStudentSignupForm(
prefix="independent_student_signup"
)
independent_student_signup_form = IndependentStudentSignupForm(prefix="independent_student_signup")

if request.method == "POST":
if "teacher_signup-teacher_email" in request.POST:
teacher_signup_form = TeacherSignupForm(
request.POST, prefix="teacher_signup"
)
teacher_signup_form = TeacherSignupForm(request.POST, prefix="teacher_signup")

if not captcha.CAPTCHA_ENABLED:
remove_captcha_from_forms(teacher_signup_form)
Expand Down Expand Up @@ -133,15 +123,11 @@
[email],
personalization_values={
"EMAIL": email,
"LOGIN_URL": request.build_absolute_uri(
reverse("teacher_login")
),
"LOGIN_URL": request.build_absolute_uri(reverse("teacher_login")),
},
)
else:
LOGGER.warn(
f"Ratelimit teacher {RATELIMIT_USER_ALREADY_REGISTERED_EMAIL_GROUP}: {email}"
)
LOGGER.warn(f"Ratelimit teacher {RATELIMIT_USER_ALREADY_REGISTERED_EMAIL_GROUP}: {email}")
else:
teacher = Teacher.objects.factory(
first_name=data["teacher_first_name"],
Expand All @@ -152,9 +138,7 @@

send_verification_email(request, teacher.user.user, data)

TotalActivity.objects.update(
teacher_registrations=F("teacher_registrations") + 1
)
TotalActivity.objects.update(teacher_registrations=F("teacher_registrations") + 1)

return render(
request,
Expand Down Expand Up @@ -182,15 +166,11 @@
[email],
personalization_values={
"EMAIL": email,
"LOGIN_URL": request.build_absolute_uri(
reverse("independent_student_login")
),
"LOGIN_URL": request.build_absolute_uri(reverse("independent_student_login")),
},
)
else:
LOGGER.warning(
f"Ratelimit independent {RATELIMIT_USER_ALREADY_REGISTERED_EMAIL_GROUP}: {email}"
)
LOGGER.warning(f"Ratelimit independent {RATELIMIT_USER_ALREADY_REGISTERED_EMAIL_GROUP}: {email}")
return render(
request,
"portal/email_verification_needed.html",
Expand All @@ -208,9 +188,7 @@

send_verification_email(request, student.new_user, data, age=age)

TotalActivity.objects.update(
independent_registrations=F("independent_registrations") + 1
)
TotalActivity.objects.update(independent_registrations=F("independent_registrations") + 1)

return render(
request,
Expand All @@ -221,10 +199,7 @@


def is_developer(request):
return (
hasattr(request.user, "userprofile")
and request.user.userprofile.developer
)
return hasattr(request.user, "userprofile") and request.user.userprofile.developer

Check warning on line 202 in portal/views/home.py

View check run for this annotation

Codecov / codecov/patch

portal/views/home.py#L202

Added line #L202 was not covered by tests


def redirect_teacher_to_correct_page(request, teacher):
Expand Down Expand Up @@ -254,14 +229,10 @@
# tests where the first Selenium test passes, but any following test
# fails because it cannot find the Maintenance banner instance.
try:
maintenance_banner = DynamicElement.objects.get(
name="Maintenance banner"
)
maintenance_banner = DynamicElement.objects.get(name="Maintenance banner")

if maintenance_banner.active:
messages.info(
request, format_html(maintenance_banner.text), extra_tags="safe"
)
messages.info(request, format_html(maintenance_banner.text), extra_tags="safe")

Check warning on line 235 in portal/views/home.py

View check run for this annotation

Codecov / codecov/patch

portal/views/home.py#L235

Added line #L235 was not covered by tests
except ObjectDoesNotExist:
pass

Expand All @@ -279,19 +250,13 @@


def coding_club(request):
return render(
request, "portal/coding_club.html", {"BANNER": CODING_CLUB_BANNER}
)
return render(request, "portal/coding_club.html", {"BANNER": CODING_CLUB_BANNER})

Check warning on line 253 in portal/views/home.py

View check run for this annotation

Codecov / codecov/patch

portal/views/home.py#L253

Added line #L253 was not covered by tests


def download_student_pack(request, student_pack_type):
if request.method == "POST":
count_student_pack_downloads_click(int(student_pack_type))
link = (
cloud_storage("club_packs/PythonCodingClub.zip")
if DownloadType(int(student_pack_type)) == DownloadType.PYTHON_PACK
else cloud_storage("club_packs/PrimaryCodingClub.zip")
)
link = cloud_storage("club_packs/PrimaryCodingClub.zip")

Check warning on line 259 in portal/views/home.py

View check run for this annotation

Codecov / codecov/patch

portal/views/home.py#L259

Added line #L259 was not covered by tests
return redirect(link)


Expand All @@ -304,9 +269,7 @@


def ten_year_map_page(request):
messages.info(
request, "This page is currently under construction.", extra_tags="safe"
)
messages.info(request, "This page is currently under construction.", extra_tags="safe")
return render(
request,
"portal/ten_year_map.html",
Expand Down
Loading
Loading