Skip to content

Commit

Permalink
fix: Portal 2361 (#2371)
Browse files Browse the repository at this point in the history
* add buttons

* fix: download python button packs

* comment out test

* feedback
  • Loading branch information
SKairinos authored Oct 22, 2024
1 parent 2ee8419 commit 139f19e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 277 deletions.
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 @@ def render_signup_form(request):
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 @@ def process_signup_form(request, data):
[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 @@ def process_signup_form(request, data):

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 @@ def process_independent_student_signup_form(request, data):
[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 @@ def process_independent_student_signup_form(request, data):

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 process_independent_student_signup_form(request, data):


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


def redirect_teacher_to_correct_page(request, teacher):
Expand Down Expand Up @@ -254,14 +229,10 @@ def home(request):
# 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")
except ObjectDoesNotExist:
pass

Expand All @@ -279,19 +250,13 @@ def home(request):


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})


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")
return redirect(link)


Expand All @@ -304,9 +269,7 @@ def home_learning(request):


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

0 comments on commit 139f19e

Please sign in to comment.