Skip to content

Commit

Permalink
Merge branch 'master' into reviewapp-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
patjouk committed Jul 9, 2018
2 parents 30bc408 + 92222c5 commit b6e2856
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
Django = "==1.11.13"
Django = "==1.11.14"
gunicorn = "*"
djangorestframework = "*"
django-filter = "*"
Expand Down
35 changes: 19 additions & 16 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions source/js/components/petition/petition.jsx
Expand Up @@ -209,6 +209,7 @@ export default class Petition extends React.Component {
let surname = this.surname.element.value;
let country = this.country && this.country.element.value;
let postalCode = this.postalCode && this.postalCode.element.value;
let newsletterSignup = false;

// These should not be possible due to the fact that we validate
// their content prior to submission. TODO: remove these rejections?
Expand All @@ -224,13 +225,17 @@ export default class Petition extends React.Component {
return reject(new Error(`missing postal code`));
}

if (this.refs.newsletterSignup) {
newsletterSignup = !!(this.refs.newsletterSignup.checked);
}

let payload = {
givenNames,
surname,
email: this.email.element.value,
checkbox1: this.props.checkbox1 ? !!(this.refs.checkbox1.checked) : null,
checkbox2: this.props.checkbox2 ? !!(this.refs.checkbox2.checked) : null,
newsletterSignup: !!(this.refs.newsletterSignup.checked),
newsletterSignup,
country,
postalCode,
source: window.location.toString(),
Expand Down Expand Up @@ -575,12 +580,14 @@ export default class Petition extends React.Component {
{this.state.userTriedSubmitting && !this.refs.privacy.checked && <small className="has-danger">Please check this box if you want to proceed</small>}
</label>
</div>
<div className="my-2">
<label className="form-check-label">
<input disabled={disableFields} type="checkbox" className="form-check-input" id="PrivacyCheckbox" ref="newsletterSignup" />
<span className="h6-heading form-text">Yes, I want to receive email updates about Mozilla’s campaigns.</span>
</label>
</div>
{ this.props.subscribed ? null :
<div className="my-2">
<label className="form-check-label">
<input disabled={disableFields} type="checkbox" className="form-check-input" id="NewsletterSignup" ref="newsletterSignup" />
<span className="h6-heading form-text">Yes, I want to receive email updates about Mozilla’s campaigns.</span>
</label>
</div>
}
{ checkboxes.length > 0 ? (<div className="my-2">{checkboxes}</div>) : null }
<div className="mt-3">
<button disabled={disableFields} className="col-12 btn btn-normal petition-btn">Add my name</button>
Expand Down
7 changes: 6 additions & 1 deletion source/js/main.js
Expand Up @@ -231,13 +231,18 @@ let main = {

// petition elements
var petitionElements = Array.from(document.querySelectorAll(`.sign-petition`));
var subscribed = false;

if (window.location.search.indexOf(`subscribed=1`) !== -1) {
subscribed = true;
}

petitionElements.forEach(element => {
var props = element.dataset;

props.apiUrl = `${networkSiteURL}/api/campaign/petitions/${props.petitionId}/`;

ReactDOM.render(<Petition {...props} isHidden={false} />, element);
ReactDOM.render(<Petition {...props} isHidden={false} subscribed={subscribed}/>, element);
});

if (document.getElementById(`people`)) {
Expand Down

0 comments on commit b6e2856

Please sign in to comment.