Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix bug 765783] Implement callback url support.
- For each successful subscription in /contribute we POST to callbackurl GET parameter if available. - Added /contribute/event/ page that renders the same page as /contribute but returns user to the same page after successfull subscription, so a new user can directly join. Conflicts: apps/mozorg/urls.py apps/mozorg/views.py
- Loading branch information
1 parent
9baeda5
commit 3425f80
Showing
5 changed files
with
151 additions
and
96 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,87 +1,92 @@ | ||
{% if not success %} | ||
{% if not success or return_to_form %} | ||
<form class="billboard{% if form.errors %} has-errors{% endif %}" | ||
action="#help-form" id="help-form" method="post"> | ||
action="#help-form" id="help-form" method="post"> | ||
<input type="hidden" name="contribute-form" value="Y" /> | ||
|
||
{% if success and return_to_form %} | ||
<h4 id="thank-you"> | ||
{{ _('Thank you for getting in touch! You will hear from us soon.') }} | ||
</h4> | ||
{% endif %} | ||
|
||
{% if form.errors %} | ||
{{ form.non_field_errors()|safe }} | ||
{{ form.non_field_errors()|safe }} | ||
|
||
<ul class="errorlist"> | ||
{% if form.email.errors %} | ||
<li>{{_('Please enter a valid email address.')}}</li> | ||
{% endif %} | ||
<ul class="errorlist"> | ||
{% if form.email.errors %} | ||
<li>{{_('Please enter a valid email address.')}}</li> | ||
{% endif %} | ||
|
||
{% if form.privacy.errors %} | ||
<li>{{_('You must agree to the privacy policy.')}}</li> | ||
{% endif %} | ||
{% if form.privacy.errors %} | ||
<li>{{_('You must agree to the privacy policy.')}}</li> | ||
{% endif %} | ||
|
||
{% if form.interest.errors %} | ||
<li>{{_('Please select an area of interest.')}}</li> | ||
{% endif %} | ||
{% if form.interest.errors %} | ||
<li>{{_('Please select an area of interest.')}}</li> | ||
{% endif %} | ||
|
||
{% if form.comments.errors %} | ||
<li>{{_('Please tell us more about your interests.')}}</li> | ||
{% endif %} | ||
{% if form.comments.errors %} | ||
<li>{{_('Please tell us more about your interests.')}}</li> | ||
{% endif %} | ||
|
||
{% if form.captcha.errors %} | ||
<li>{{_('Your CAPTCHA response did not match. Please try again.')}}</li> | ||
{% endif %} | ||
</ul> | ||
{% if form.captcha.errors %} | ||
<li>{{_('Your CAPTCHA response did not match. Please try again.')}}</li> | ||
{% endif %} | ||
</ul> | ||
{% endif %} | ||
|
||
<fieldset> | ||
|
||
<div class="form-row"> | ||
<div class="form-column-1"> | ||
<h3>{{_('Want to help?')}}</h3> | ||
</div> | ||
<div class="form-column-2"> | ||
<div class="field field-email"> | ||
{{ field_with_attrs(form.email, placeholder=_('YOUR EMAIL HERE'))|safe }} | ||
</div> | ||
</div> | ||
<div class="form-column-3"> | ||
<div class="field field-interest"> | ||
{{ form.interest|safe }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-row" id="form-details"> | ||
<div class="form-column-1"> | ||
<p>{{_('Send us a note and we can get you started right away.')}}</p> | ||
</div> | ||
<div class="form-column-2"> | ||
<div class="field field-comments"> | ||
{{ field_with_attrs(form.comments, placeholder=_('Hi, I’m interested in…'))|safe }} | ||
<div id="form-content" | ||
{% if success and return_to_form %} style="display:none"{% endif %}> | ||
<fieldset> | ||
<div class="row"> | ||
<div class="form-column-1"> | ||
<h3>{{_('Want to help?')}}</h3> | ||
</div> | ||
<div class="form-column-2"> | ||
<div class="field field-email"> | ||
{{ field_with_attrs(form.email, placeholder=_('YOUR EMAIL HERE'))|safe }} | ||
</div> | ||
</div> | ||
<div class="form-column-3"> | ||
<div class="field field-interest"> | ||
{{ form.interest|safe }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-column-3"> | ||
<div class="field field-privacy {% if form.privacy.errors%}field-error{% endif %}"> | ||
{{ form.privacy|safe }} | ||
</div> | ||
<div class="field field-newsletter"> | ||
<label for="id_newsletter"> | ||
{{ form.newsletter|safe }} | ||
{{_('I’d like to receive regular contribution news by email')}} | ||
</label> | ||
</div> | ||
<div class="field field-captcha"> | ||
{{ form.captcha }} | ||
</div> | ||
</div> | ||
|
||
</fieldset> | ||
|
||
<div class="form-row" id="form-details"> | ||
<div class="form-column-1"> | ||
<p>{{_('Send us a note and we can get you started right away.')}}</p> | ||
</div> | ||
<div class="form-column-2"> | ||
<div class="field field-comments"> | ||
{{ field_with_attrs(form.comments, placeholder=_('Hi, I’m interested in…'))|safe }} | ||
</div> | ||
</div> | ||
<div class="form-column-3"> | ||
<div class="field field-privacy {% if form.privacy.errors%}field-error{% endif %}"> | ||
{{ form.privacy|safe }} | ||
</div> | ||
<div class="field field-newsletter"> | ||
<label for="id_newsletter"> | ||
{{ form.newsletter|safe }} | ||
{{_('I’d like to receive regular contribution news by email')}} | ||
</label> | ||
</div> | ||
<div class="field field-captcha"> | ||
{{ form.captcha }} | ||
</div> | ||
</div> | ||
</div> | ||
</fieldset> | ||
<div class="form-submit"> | ||
<input type="submit" class="button-blue" id="form-submit" value="{{_('Submit »')}}"> | ||
</div> | ||
|
||
</div> | ||
</form> | ||
{% else %} | ||
<div id="help-form" class="billboard thank"> | ||
<div id="help-form" class="billboard thank"> | ||
<h4>{{_('Thank you for getting in touch.')}}</h4> | ||
<p>{{_('Someone from Mozilla will get back to you soon with information about how to get involved. While you’re waiting, browse through some of the volunteer opportunities available below.')}} | ||
</p> | ||
</div> | ||
</div> | ||
{% endif %} |
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 |
---|---|---|
@@ -1,32 +1,71 @@ | ||
$(document).ready(function() { | ||
function getUrlVars() { | ||
// Function to read URL Get variables. | ||
// from http://papermashup.com/read-url-get-variables-withjavascript/ | ||
var vars = {}; | ||
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { | ||
vars[key] = value; | ||
}); | ||
return vars; | ||
} | ||
|
||
function validate_domain(url, trusted_domains) { | ||
// Function to validate that callback url points | ||
// to a trusted domain. | ||
for (var domain in trusted_domains) { | ||
var regex = new RegExp(trusted_domains[domain]); | ||
if (regex.test(url)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
var $opportunities = $('#opportunities'); | ||
function scrollTo($el) { | ||
var top = $el.offset().top; | ||
$("html:not(:animated),body:not(:animated)").animate( | ||
{ scrollTop: top - 20 }, | ||
100 | ||
); | ||
var top = $el.offset().top; | ||
$("html:not(:animated),body:not(:animated)").animate( | ||
{ scrollTop: top - 20 }, | ||
100 | ||
); | ||
} | ||
|
||
var pager = Mozilla.Pager.rootPagers[0]; | ||
|
||
$('#interest-header').click(function(e) { | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['interest']); | ||
scrollTo($opportunities); | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['interest']); | ||
scrollTo($opportunities); | ||
}); | ||
|
||
$('#location-header').click(function(e) { | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['location']); | ||
scrollTo($opportunities); | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['location']); | ||
scrollTo($opportunities); | ||
}); | ||
|
||
$('#time-header').click(function(e) { | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['time']); | ||
scrollTo($opportunities); | ||
e.preventDefault(); | ||
pager.setPageWithAnimation(pager.pagesById['time']); | ||
scrollTo($opportunities); | ||
}); | ||
|
||
}); | ||
$('#help-form').submit(function(e) { | ||
// Validate that the callback points to one of the allowed domains. | ||
|
||
callback_url = getUrlVars()['callbackurl']; | ||
|
||
trusted_domains = ['^https://reps.mozilla.org/', | ||
'^https://reps.allizom.org/', | ||
'^https://reps-dev.allizom.org/', | ||
'^http://127.0.0.1:8000/']; | ||
|
||
if (callback_url && validate_domain(callback_url, trusted_domains)) { | ||
$.post(callback_url); | ||
} | ||
}); | ||
|
||
$('#thank-you').delay(8500).fadeOut('fast', function() { | ||
$('#form-content').fadeIn('fast'); | ||
}); | ||
}); |