aboutsummaryrefslogtreecommitdiffstats
path: root/alphabetlearning
diff options
context:
space:
mode:
Diffstat (limited to 'alphabetlearning')
-rw-r--r--alphabetlearning/pages/__init__.py0
-rw-r--r--alphabetlearning/pages/admin.py3
-rw-r--r--alphabetlearning/pages/apps.py6
-rw-r--r--alphabetlearning/pages/migrations/__init__.py0
-rw-r--r--alphabetlearning/pages/models.py3
-rw-r--r--alphabetlearning/pages/tests.py3
-rw-r--r--alphabetlearning/pages/urls.py8
-rw-r--r--alphabetlearning/pages/views.py5
-rw-r--r--alphabetlearning/payments/forms.py5
-rw-r--r--alphabetlearning/payments/views.py2
-rw-r--r--alphabetlearning/templates/base.html2
-rw-r--r--alphabetlearning/templates/pages/home.html3
-rw-r--r--alphabetlearning/templates/payments/rate_limited.html11
13 files changed, 50 insertions, 1 deletions
diff --git a/alphabetlearning/pages/__init__.py b/alphabetlearning/pages/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/alphabetlearning/pages/__init__.py
diff --git a/alphabetlearning/pages/admin.py b/alphabetlearning/pages/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/alphabetlearning/pages/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/alphabetlearning/pages/apps.py b/alphabetlearning/pages/apps.py
new file mode 100644
index 0000000..cdd024b
--- /dev/null
+++ b/alphabetlearning/pages/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class PagesConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'pages'
diff --git a/alphabetlearning/pages/migrations/__init__.py b/alphabetlearning/pages/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/alphabetlearning/pages/migrations/__init__.py
diff --git a/alphabetlearning/pages/models.py b/alphabetlearning/pages/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/alphabetlearning/pages/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/alphabetlearning/pages/tests.py b/alphabetlearning/pages/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/alphabetlearning/pages/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/alphabetlearning/pages/urls.py b/alphabetlearning/pages/urls.py
new file mode 100644
index 0000000..f8c5b15
--- /dev/null
+++ b/alphabetlearning/pages/urls.py
@@ -0,0 +1,8 @@
+from django.urls import path
+
+from . import views
+
+app_name = "pages"
+urlpatterns = [
+ path("", views.HomePageView.as_view(), name="home"),
+]
diff --git a/alphabetlearning/pages/views.py b/alphabetlearning/pages/views.py
new file mode 100644
index 0000000..81d4392
--- /dev/null
+++ b/alphabetlearning/pages/views.py
@@ -0,0 +1,5 @@
+from django.views.generic import TemplateView
+
+
+class HomePageView(TemplateView):
+ template_name = "pages/home.html"
diff --git a/alphabetlearning/payments/forms.py b/alphabetlearning/payments/forms.py
index 3aa2d95..68acfee 100644
--- a/alphabetlearning/payments/forms.py
+++ b/alphabetlearning/payments/forms.py
@@ -1,8 +1,13 @@
from django import forms
+from django_recaptcha.fields import ReCaptchaField
+from django_recaptcha.widgets import ReCaptchaV2Checkbox
+
from .models import EmailVerification
class EmailVerificationForm(forms.ModelForm):
+ captcha = ReCaptchaField(widget=ReCaptchaV2Checkbox)
+
class Meta:
model = EmailVerification
fields = ["email"]
diff --git a/alphabetlearning/payments/views.py b/alphabetlearning/payments/views.py
index 2be5344..7682c35 100644
--- a/alphabetlearning/payments/views.py
+++ b/alphabetlearning/payments/views.py
@@ -61,6 +61,8 @@ class SuccessEmailSignupView(TemplateView):
@ratelimit(key="ip", rate="2/m", block=True)
def email_signup_verification(request):
if request.method == "POST":
+ if getattr(request, "limited", False):
+ return render(request, "payments/rate_limited.html", status=429)
form = EmailVerificationForm(request.POST)
if form.is_valid():
# Create pending verification
diff --git a/alphabetlearning/templates/base.html b/alphabetlearning/templates/base.html
index 5aa2193..f26fb72 100644
--- a/alphabetlearning/templates/base.html
+++ b/alphabetlearning/templates/base.html
@@ -59,7 +59,7 @@
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-white">
<div class="container-fluid">
- <a class="navbar-brand" href="{% url "home" %}">
+ <a class="navbar-brand" href="{% url "pages:home" %}">
<img style="margin-left: 2rem; margin-top: 20px;" src="{% static "images/AL_long_logo_black_grey.png" %}" width=300px alt="Alphabet Learning Logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
diff --git a/alphabetlearning/templates/pages/home.html b/alphabetlearning/templates/pages/home.html
index 6261524..0d00042 100644
--- a/alphabetlearning/templates/pages/home.html
+++ b/alphabetlearning/templates/pages/home.html
@@ -65,6 +65,9 @@
placeholder="Your email address..."
/>
</div>
+ <div>
+ {{ form.captcha }}
+ </div>
<button
type="submit"
style="
diff --git a/alphabetlearning/templates/payments/rate_limited.html b/alphabetlearning/templates/payments/rate_limited.html
new file mode 100644
index 0000000..c75e474
--- /dev/null
+++ b/alphabetlearning/templates/payments/rate_limited.html
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+
+{% load static %}
+
+{% block content %}
+ <div class="container my-5">
+ <div class="row">
+ <h2>You have made to many submissions</h2>
+ <p>Please try again later.</p>
+ </div>
+{% endblock content %}