-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not ask for credit card with the free option, but still create a subscription so things are more consistent. Allow plan to be provided in URL (already present on pricing page).
- Loading branch information
Showing
24 changed files
with
392 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from django.conf import settings | ||
|
||
|
||
def contact_email(request): | ||
return {'CONTACT_EMAIL': settings.CONTACT_EMAIL} | ||
def add_settings(request): | ||
return { | ||
'CONTACT_EMAIL': settings.CONTACT_EMAIL, | ||
'PRICING': settings.PRICING, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
mapit_mysociety_org/templates/account/_form_field_checkbox.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="account-form__field"> | ||
<label class="account-form__label"> | ||
{{ field }} | ||
{{ field.label }} | ||
</label> | ||
{% if field.errors %} | ||
<div class="account-form__errors">{{ field.errors }}</div> | ||
{% endif %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
mapit_mysociety_org/templates/account/_form_fields_signup.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% include 'account/_form_field.html' with field=form.email %} | ||
{% include 'account/_form_field.html' with field=form.password %} | ||
{% include 'account/_form_field.html' with field=form.password_confirm %} | ||
|
||
{% include 'account/_form_field.html' with field=form.plan %} | ||
{% include 'account/_form_field_checkbox.html' with field=form.charitable_tick %} | ||
<div id="charitable-qns"{% if not form.charitable_tick.value %} style="display:none"{% endif %}> | ||
{% include 'account/_form_field.html' with field=form.charitable %} | ||
<div id="charity-number"{% if not form.charity_number.value and not form.charity_number.errors %} style="display:none"{% endif %}> | ||
{% include 'account/_form_field.html' with field=form.charity_number %} | ||
</div> | ||
<div id="charitable-desc"{% if not form.description.value and not form.description.errors %} style="display:none"{% endif %}> | ||
{% include 'account/_form_field.html' with field=form.description %} | ||
</div> | ||
</div> | ||
{% include 'account/_form_field_checkbox.html' with field=form.tandcs_tick %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ mock==1.3.0 | |
mockredispy==2.9.0.12 | ||
redis==2.10.5 | ||
django-apptemplates==1.2 | ||
stripe==1.46.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
document.getElementById('id_charitable_tick').addEventListener('click', function(e) { | ||
if (this.checked) { | ||
document.getElementById('charitable-qns').style.display = 'block'; | ||
} else { | ||
document.getElementById('charitable-qns').style.display = 'none'; | ||
} | ||
}); | ||
document.getElementById('id_charitable_0').addEventListener('change', function(e) { | ||
document.getElementById('charitable-desc').style.display = 'none'; | ||
document.getElementById('charity-number').style.display = 'block'; | ||
}); | ||
document.getElementById('id_charitable_1').addEventListener('change', function(e) { | ||
document.getElementById('charity-number').style.display = 'none'; | ||
document.getElementById('charitable-desc').style.display = 'block'; | ||
}); | ||
document.getElementById('id_charitable_2').addEventListener('change', function(e) { | ||
document.getElementById('charity-number').style.display = 'none'; | ||
document.getElementById('charitable-desc').style.display = 'none'; | ||
}); | ||
|
||
var stripe_key = document.getElementById('js-payment').getAttribute('data-key'); | ||
var handler = StripeCheckout.configure({ | ||
key: stripe_key, | ||
image: 'https://s3.amazonaws.com/stripe-uploads/acct_19EbqNIbP0iBLddtmerchant-icon-1479145884111-mysociety-wheel-logo.png', | ||
locale: 'auto', | ||
token: function(token) { | ||
var form = document.getElementById('signup_form'); | ||
form.stripeToken.value = token.id; | ||
form.submit(); | ||
} | ||
}); | ||
|
||
document.getElementById('customButton').addEventListener('click', function(e) { | ||
// Already got a token from Stripe (so password mismatch error or somesuch) | ||
var form = document.getElementById('signup_form'); | ||
if (form.stripeToken.value) { | ||
return; | ||
} | ||
e.preventDefault(); | ||
|
||
function err_highlight(id, err) { | ||
if (err) { | ||
if (id.className.search(/(?:^|\s)error(?!\S)/) === -1) { | ||
id.className += " error"; | ||
} | ||
return 1; | ||
} else { | ||
id.className = id.className.replace(/(?:^|\s)error(?!\S)/, '') | ||
return 0; | ||
} | ||
} | ||
|
||
function err(field, extra) { | ||
var f = document.getElementById(field); | ||
if (!f) { | ||
return 0; | ||
} | ||
f = f.value; | ||
var label = document.querySelector('label[for=' + field + ']'); | ||
return err_highlight(label, extra !== undefined ? extra && !f : !f); | ||
} | ||
|
||
var errors = 0; | ||
errors += err('id_email'); | ||
errors += err('id_password'); | ||
errors += err('id_password_confirm'); | ||
var plan = document.querySelector('input[name=plan]:checked'); | ||
errors += err_highlight(document.querySelector('label[for=id_plan_0]'), !plan); | ||
var ctick = document.getElementById('id_charitable_tick').checked; | ||
var c = document.querySelector('input[name=charitable]:checked'); | ||
errors += err_highlight(document.querySelector('label[for=id_charitable_0]'), ctick && !c); | ||
errors += err('id_charity_number', ctick && c && c.value === 'c'); | ||
errors += err('id_description', ctick && c && c.value === 'i'); | ||
var tandcs = document.getElementById('id_tandcs_tick'); | ||
errors += err_highlight(tandcs.parentNode, !tandcs.checked); | ||
if (errors) { | ||
return; | ||
} | ||
|
||
plan = plan.value; | ||
var num = 20; | ||
if (plan === 'mapit-100k') { | ||
num = 100; | ||
} else if (plan === 'mapit-0k') { | ||
num = 300; | ||
} | ||
if (ctick) { | ||
c = c.value; | ||
if (c === 'c' || c === 'i') { | ||
if (num === 20) { | ||
num = 0; | ||
} else { | ||
num = num / 2; | ||
} | ||
} | ||
} | ||
if (num === 0) { | ||
form.submit(); | ||
return; | ||
} | ||
|
||
var email = document.getElementById('id_email') | ||
? document.getElementById('id_email').value | ||
: document.getElementById('js-payment').getAttribute('data-email'); | ||
|
||
handler.open({ | ||
name: 'mySociety', | ||
description: 'Subscribing to plan ' + plan, | ||
zipCode: true, | ||
currency: 'gbp', | ||
allowRememberMe: false, | ||
email: email, | ||
amount: num * 100 | ||
}); | ||
}); | ||
|
||
window.addEventListener('popstate', function() { | ||
handler.close(); | ||
}); |
Oops, something went wrong.