Skip to content

Commit

Permalink
fix: Remove donate button (#2400)
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 authored Jan 28, 2025
1 parent 9f2ebe0 commit 2ff52a8
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 200 deletions.
1 change: 0 additions & 1 deletion example_project/portal_test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
"common.context_processors.module_name",
"common.context_processors.cookie_management_enabled",
"portal.context_processors.process_newsletter_form",
"portal.context_processors.process_donate_form",
]
},
}
Expand Down
1 change: 0 additions & 1 deletion example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"common.context_processors.module_name",
"common.context_processors.cookie_management_enabled",
"portal.context_processors.process_newsletter_form",
"portal.context_processors.process_donate_form",
]
}
}
Expand Down
6 changes: 1 addition & 5 deletions portal/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from portal.forms.dotmailer import DonateForm, NewsletterForm
from portal.forms.dotmailer import NewsletterForm


def process_newsletter_form(request):
return {"news_form": NewsletterForm()}


def process_donate_form(request):
return {"donate_form": DonateForm()}
22 changes: 0 additions & 22 deletions portal/forms/dotmailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,6 @@ class NewsletterForm(forms.Form):
)


class DonateForm(forms.Form):
email = forms.EmailField(
label="This data will only be used for this purpose and you will be "
"able to opt out anytime. Please read our privacy notice for "
"further details.",
label_suffix="",
widget=forms.EmailInput(
attrs={
"placeholder": "Enter your email address",
"id": "donate_email_field",
}
),
help_text="Enter your email address",
)

age_verification = forms.BooleanField(
widget=forms.CheckboxInput(attrs={"id": "donate_age_verification"}),
initial=False,
required=True,
)


class ConsentForm(forms.Form):
email = forms.EmailField(
label="Email",
Expand Down
18 changes: 0 additions & 18 deletions portal/static/portal/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,6 @@ function hidePopupConfirmation() {
$("#popup").find(".popup-text").remove();
}

function showDonatePopup(title, text) {
let popup = $("#donate-popup");
popup.find(".popup-box__title").text(title);
popup.find(".popup-box__msg").append(text);

popup.addClass("popup--fade");
}

function hideDonatePopup() {
$("#donate-popup").removeClass("popup--fade");
$("#donate-popup").find(".popup-text").remove();
$("#donate_email_field").val("");
$('#donate_age_verification').prop("checked", false);
const donateSubmitButton = $('#confirm_donate_button');
donateSubmitButton.addClass("disabled");
donateSubmitButton.prop("disabled", true);
}

function showDonateConfirmation(path) {
let title = "We would love to have you support our non-profit mission! ❤️";
let text =
Expand Down
3 changes: 0 additions & 3 deletions portal/static/portal/sass/modules/_colours.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ $color-button-contained-disabled: $color-secondary-100;
$color-button-outlined-border: $color-secondary-600;
$color-button-outlined-border-active: $color-secondary-600;
$color-button-subnav-border: white;
$color-button-pill: #86ae18;
$color-button-pill-hover: #82a210;
$color-button-pill-active: #82a210;
// Old buttons
$color-button-primary-action-navigation: $color-secondary;
$color-button-primary-action-navigation-hover: $color-secondary;
Expand Down
31 changes: 0 additions & 31 deletions portal/static/portal/sass/partials/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,6 @@ table {
}
}

/* Green button */
.button--tertiary {
@include _padding(10px, 15px, 10px, 15px);
background: $color-button-pill;
color: $color-text-secondary;

&:hover:not(.disabled){
@include material-shadow();
background: $color-button-pill-hover;
color: $color-text-secondary;
text-decoration: none;
}

&:active:not(.disabled) {
background: $color-button-pill-active;
color: $color-text-secondary;
box-shadow: none;
}
}

.button--pill {
@include _border-radius-all(20px);
}

.button-right-arrow {
&:after {
content: "\e5e1";
Expand Down Expand Up @@ -437,13 +413,6 @@ td .button--primary {
justify-content: center;
}

&.button--donate {
background: $color-button-pill;
border: 0;
color: $color-text-secondary;
justify-content: center;
}

&.button--header--login {
border: 2px solid $color-secondary-600;
margin: 0;
Expand Down
5 changes: 0 additions & 5 deletions portal/static/portal/sass/partials/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@
font-weight: normal;
}

.button--pill:hover,
.button--pill:focus, {
font-weight: 600;
}

.button--menu--secondary {
@include _padding($spacing * 3, 0px, $spacing * 3, 0px);
}
Expand Down
14 changes: 2 additions & 12 deletions portal/templates/portal/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
{% include "portal/tag_manager/tag_manager_body.html" %}
{% render_block "js" %}
{% include 'portal/mouseflow.html' %}
{% include "portal/partials/donate_popup.html" %}
<div class="content-footer-wrapper">
{% block contentWrapper %}
<div {% block pageID %}id="contentWrapper"{% endblock %}>
Expand Down Expand Up @@ -240,25 +239,16 @@
});
</script>
<script>
// disable newsletter signup and donate buttons by default
// disable newsletter signup button by default
const newsletterSubmitButton = $('#submit_newsletter');
newsletterSubmitButton.addClass("disabled");
newsletterSubmitButton.prop("disabled", true);

const donateSubmitButton = $('#confirm_donate_button');
donateSubmitButton.addClass("disabled");
donateSubmitButton.prop("disabled", true);

// enable them or disable them depending on age verification checkbox
// enable them or disable it depending on age verification checkbox
$('#id_age_verification').on("click", function() {
newsletterSubmitButton.prop("disabled", !this.checked);
newsletterSubmitButton.toggleClass("disabled", !this.checked);
});

$('#donate_age_verification').on("click", function() {
donateSubmitButton.prop("disabled", !this.checked);
donateSubmitButton.toggleClass("disabled", !this.checked);
})
</script>
{% endblock scripts %}
</body>
Expand Down
46 changes: 0 additions & 46 deletions portal/templates/portal/partials/donate_popup.html

This file was deleted.

4 changes: 0 additions & 4 deletions portal/templates/portal/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
<a class="button--menu button--menu--secondary button--menu--disabled">Games</a>
<a class="button--menu button--menu--secondary button--menu--disabled">Teaching Resources</a>
{% endif %}
<button onclick="showDonateConfirmation()" class="button--menu button--pill button--tertiary">Donate</button>
{% else %}
{% if user|is_independent_student %}
<div class="menu--title">Independent</div>
Expand Down Expand Up @@ -104,7 +103,6 @@
<div class="menu__left-side col-md-5">
<a href="{% url 'teach' %}" class="button--menu button--menu--primary button--menu--enabled">Teachers</a>
<a href="{% url 'play' %}" class="button--menu button--menu--primary button--menu--enabled">Students</a>
<button id="donate" onclick="showDonateConfirmation()" class="button--menu button--pill button--tertiary">Donate</button>
{% endif %}
</div>
{% if user|is_logged_in %}
Expand Down Expand Up @@ -241,8 +239,6 @@ <h1>{{ user|make_into_username }}</h1>
{% else %}
<a class="button button--menu__item button--register"
href="{% url 'register' %}">Register now</a>
<button onclick="showDonateConfirmation()"
class="button--menu__item button--donate">Donate</button>
<button class="button--menu__item button--menu__item--sub-header login"
data-toggle="collapse" data-target="#login-tabs">Log in</button>
<div id="login-tabs" class="collapse">
Expand Down
11 changes: 1 addition & 10 deletions portal/tests/cypress/integration/user.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
/// <reference types="cypress" />

describe('User', () => {
it('can open donate popup', () => {
cy.visit("/");
cy.get('#donate').click();
cy.get('.popup-box').should('be.visible');
cy.get('#donate_form').should('be.visible');
});
});
/// <reference types="cypress" />
16 changes: 0 additions & 16 deletions portal/tests/test_global_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,3 @@ def test_newsletter_signup_fail(self):
response = client.post(url, data)
messages = list(response.wsgi_request._messages)
assert len([m for m in messages if "error" in m.tags]) == 1

def test_donate_signup_successful(self):
url = reverse("process_donate_form")
client = Client()
data = {"email": "[email protected]", "age_verification": "on"}
response = client.post(url, data)
messages = list(response.wsgi_request._messages)
assert len([m for m in messages if m.tags == "success"]) == 1

def test_donate_signup_fail(self):
url = reverse("process_donate_form")
client = Client()
data = {"email": "invalid_email", "age_verification": "on"}
response = client.post(url, data)
messages = list(response.wsgi_request._messages)
assert len([m for m in messages if "error" in m.tags]) == 1
4 changes: 0 additions & 4 deletions portal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
)
from portal.views.dotmailer import (
dotmailer_consent_form,
process_donate_form,
process_newsletter_form,
)
from portal.views.email import verify_email
Expand Down Expand Up @@ -279,9 +278,6 @@
process_newsletter_form,
name="process_newsletter_form",
),
re_path(
r"^donate_signup/$", process_donate_form, name="process_donate_form"
),
re_path(r"^consent_form/$", dotmailer_consent_form, name="consent_form"),
re_path(
r"^verify_email/$",
Expand Down
23 changes: 1 addition & 22 deletions portal/views/dotmailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.urls import reverse_lazy
from django.views.decorators.csrf import csrf_exempt

from portal.forms.dotmailer import NewsletterForm, DonateForm, ConsentForm
from portal.forms.dotmailer import NewsletterForm, ConsentForm


@csrf_exempt
Expand Down Expand Up @@ -40,27 +40,6 @@ def process_newsletter_form(request):
return HttpResponse(status=405)


@csrf_exempt
def process_donate_form(request):
if request.method == "POST":
donate_form = DonateForm(data=request.POST)
if donate_form.is_valid():
user_email = request.POST.get("email", "")
add_to_dotmailer("", "", user_email, address_book_ids["donors"])
messages.success(
request, "Thank you for registering your interest! 🎉"
)
return HttpResponseRedirect(reverse_lazy("home"))
messages.error(
request,
"Invalid email address. Please try again.",
extra_tags="sub-nav--warning",
)
return HttpResponseRedirect(reverse_lazy("home"))

return HttpResponse(status=405)


def dotmailer_consent_form(request):
if request.method == "POST":
consent_form = ConsentForm(data=request.POST)
Expand Down

0 comments on commit 2ff52a8

Please sign in to comment.