Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1382 from SumOfUs/development
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
eyko committed Apr 29, 2019
2 parents 5f84dbe + 670824b commit 93b6033
Show file tree
Hide file tree
Showing 67 changed files with 1,558 additions and 96 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ GEM
nenv (0.3.0)
newrelic_rpm (4.1.0.333)
nio4r (2.3.1)
nokogiri (1.10.2)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
notiffany (0.1.1)
nenv (~> 0.1)
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/member-facing/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $facebook: #597ac7;
$twitter: #5dbeec;
$paypal: #1a9ddb;
$whatsapp: #25D366;
$email: #f8492e;

// grays, named per http://davidwalsh.name/sass-color-variables-dont-suck
$chalk-gray: #ececec;
Expand Down
19 changes: 18 additions & 1 deletion app/assets/stylesheets/member-facing/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ button.button {
// shareprogress isn't super customization friendly, so we do
// what we can.
.button {
&--facebook, &--twitter, &--whatsapp {
&--facebook, &--twitter, &--whatsapp, &--email {
margin-top: 10px;
margin-left: 5px;
margin-right: 5px;
Expand Down Expand Up @@ -106,6 +106,17 @@ button.button {
font-size: 0;
}
}
&--email {
&.sp_em_small, &.sp_em_large, &.sp_tw_small, &.sp_tw_large, &.sp_fb_small, &.sp_fb_large {
a {
@include button($email);
padding-top: 15px;
color: $email;
font-size: 1px;
font-size: 0;
}
}
}
&--facebook a::before {
content: "Share";
}
Expand All @@ -118,4 +129,10 @@ button.button {
&--twitter a::after {
content: '\f099';
}
&--email a::before {
content: "Email";
}
&--email a::after {
content: "\f0e0";
}
}
5 changes: 4 additions & 1 deletion app/assets/stylesheets/member-facing/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ label.checkbox-label {

.radio-container {
margin-top: 10px;
display: flex;
flex-direction: column;
align-items: flex-start;
&.has-error {
border-right: 2px solid red;
border-bottom: 2px solid red;
}
label {
margin: 12px 0 16px 10px;
margin: 6px 0 6px 10px;
display: block;
}
}
Expand Down
15 changes: 15 additions & 0 deletions app/assets/stylesheets/member-facing/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.container {
section {
padding: 2em 4%;
clear: both;

.one-column {
max-width: 1000px;
margin: auto;
}
}

.alternate-bg {
background-color: #ececec;
}
}
35 changes: 35 additions & 0 deletions app/controllers/api/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ def create
end
end

def create_unsafe
service = UnsafeEmailSender.new(params[:page_id], unsafe_email_params, recipient_params, tracking_params)
if service.run
write_member_cookie(service.action.member_id) if service.action.member_id
render json: { follow_up_page: PageFollower.new_from_page(page).follow_up_path }
else
render json: { errors: service.errors }, status: :unprocessable_entity
end
end

def create_pension_email
reg_endpoint = plugin.try(:registered_target_endpoint)

Expand All @@ -37,6 +47,16 @@ def create_pension_email

private

def unsafe_email_params
params
.require(:email)
.permit(:body, :subject, :from_name, :from_email, :country, :consented)
end

def recipient_params
params.require(:recipient).permit(:name, :email)
end

def email_params
params
.require(:email)
Expand Down Expand Up @@ -69,6 +89,21 @@ def pension_email_params
data
end

def unsafe_action_params
{
page_id: params[:page_id],
recipient: "#{recipient_params[:name]}, <#{recipient_params[:email]}>",
name: params[:from_name],
email: params[:from_email],
country: params[:country],
akid: params[:akid],
referring_akid: params[:referring_akid],
referrer_id: params[:referrer_id],
rid: params[:rid],
source: params[:source]
}
end

def action_params
{
page_id: params[:page_id],
Expand Down
23 changes: 18 additions & 5 deletions app/controllers/api/payment/braintree_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,28 @@ def webhook
end

def one_click
@result = client::OneClick.new(unsafe_params, cookies.signed[:payment_methods]).run
unless @result.success?
@errors = client::ErrorProcessing.new(@result, locale: locale).process
render status: :unprocessable_entity, errors: @errors
end
@result = client::OneClick.new(unsafe_params, cookies.signed[:payment_methods], member).run
render status: :unprocessable_entity, errors: oneclick_payment_errors unless @result.success?
end

private

def member
if params[:user][:email].present?
Member.find_by_email(params[:user][:email])
elsif unsafe_params[:akid].present?
Member.find_from_request(akid: unsafe_params[:akid], id: cookies.signed[:member_id])
end
end

def oneclick_payment_errors
if @result.class == Braintree::ErrorResult
client::ErrorProcessing.new(@result, locale: locale).process
else
@result.errors
end
end

def payment_options
{
nonce: unsafe_params[:payment_method_nonce],
Expand Down
21 changes: 21 additions & 0 deletions app/javascript/async/email-ukparliament.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @flow
import React from 'react';
import { render } from 'react-dom';
import { EmailPluginConfig } from './interfaces';
import EmailParliament from '../modules/EmailParliament';

type Options = {
el: HTMLElement,
config: EmailPluginConfig,
[key: string]: any,
};

export const init = (options: Options) => {
if (!options.config.active) return;
if (options.el) {
render(
<EmailParliament config={options.config} onSend={options.onSend} />,
options.el
);
}
};
53 changes: 53 additions & 0 deletions app/javascript/async/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// @flow

type PluginErrorOptions = {
name?: string,
message: string,
};

export class PluginError {
name: string;
message: string;
constructor(options: PluginErrorOptions) {
this.name = options.name || 'PluginError';
this.message = options.message;
}

toString() {
return `${this.name}: ${this.message}`;
}
}

export const MODULES = {
'email-ukparliament': () => import('./email-ukparliament'),
};

// Lists supported async modules
export const list = (): string[] => Object.keys(MODULES);

// Loads an async module.
export const load = async (name: string, options: any) => {
const loader = MODULES[name];
if (!loader) {
throw new PluginError({
message: `Plugin "${name}" is not available or does not support dynamic loading.`,
});
}
const plugin = await loader();
plugin.init(options);
};

export const modules = {
// Attaches the async feature to the champaign global
// object.
setup(champaign: any) {
Object.assign(champaign, {
modules: {
load,
list,
},
});
},
};

export default modules;
15 changes: 15 additions & 0 deletions app/javascript/async/interfaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow

export interface PluginConfig {
ref: string;
active: boolean;
locale: string;
pageId: number;
pluginId: number;
title: string;
}

export interface EmailPluginConfig extends PluginConfig {
subject: string;
template: string;
}
1 change: 0 additions & 1 deletion app/javascript/campaigner_facing/emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const NoEmailsFound = () => <p>No emails were found</p>;

const Email = props => {
const body = () => ({ __html: props.Body });
console.log(props.Recipients);
return (
<div className="panel panel-default">
<div className="panel-heading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,28 @@ exports[`renders all amounts with the currency symbol 1`] = `
"cookie_consent.privacy_policy_link_text": "Privacy Policy",
"double_opt_in.check_email.body": "Please check your e-mail to confirm your e-mail address and validate your signature",
"double_opt_in.email.subject": "Confirm your signature",
"email_pension.form.other_pension_fund_text": "Can't find your pension fund?",
"email_pension.form.select_target": "Select your Pension or Mutual Fund",
"email_tool.form.email_body": "Body",
"email_tool.form.errors.country": "Please select a country",
"email_tool.form.errors.email": "Please add your email address",
"email_tool.form.errors.fund": "Please select a pension fund",
"email_tool.form.errors.fund_not_found": "We're sorry you couldn't find your pension fund. Send us its name and we'll update our records.",
"email_tool.form.errors.message": "Whoops! There are some errors with the form. Please check you've filled in the required fields.",
"email_tool.form.errors.name": "Please add you name",
"email_tool.form.errors.subject": "Please add a subject line",
"email_tool.form.errors.suggest_fund": "Name of pension fund can't be blank",
"email_tool.form.errors.target.outdated": "It seems the targets information has recently changed. Please reload the page and try again.",
"email_tool.form.errors.targets": "Please enter your location to find your representative",
"email_tool.form.name_of_your_pension_fund": "Name of your pension fund",
"email_tool.form.representative.not_found": "Sorry, we couldn't find a target with this location.",
"email_tool.form.representative.postal_code": "Enter your postal code",
"email_tool.form.representative.search_pending": "Please enter your postal code above.",
"email_tool.form.representative.searching": "Searching for your representative",
"email_tool.form.representative.selected_targets": "Representatives",
"email_tool.form.select_country": "Select your Country",
"email_tool.form.select_target": "Select a target",
"email_tool.form.send_button_text": "Send",
"email_tool.form.send_email": "Send email",
"email_tool.form.subject": "Subject line",
"email_tool.form.your_email": "Your email address",
Expand Down Expand Up @@ -154,6 +158,8 @@ exports[`renders all amounts with the currency symbol 1`] = `
"fundraiser.one_click_failed": "We're sorry but we could not process your donation. Please try again with a different card.",
"fundraiser.one_click_warning": "Your donation will be processed immediately.",
"fundraiser.oneclick.credit_card_payment_method": "{card_type} ending in {last_four_digits}",
"fundraiser.oneclick.duplicate_donation": "You've just made a donation a few minutes ago. Are you sure, you want to donate again? We're doing this to make sure you don't accidentally donate twice.
Thanks so much for everything you do!",
"fundraiser.oneclick.new_payment_method": "Add payment method",
"fundraiser.oneclick.paypal_payment_method": "Paypal ({email})",
"fundraiser.oneclick.select_payment": "Select a saved payment method",
Expand Down Expand Up @@ -229,6 +235,7 @@ SumOfUs",
"share.cta": "Share the campaign!",
"share.send_email": "Send Email",
"share.share": "Share",
"share.share_on_email": "Email",
"share.share_on_whatsapp": "Whatsapp",
"share.tweet": "Tweet",
"share.twitter_handle": "@sumofus",
Expand Down Expand Up @@ -516,24 +523,28 @@ exports[`renders correctly 1`] = `
"cookie_consent.privacy_policy_link_text": "Privacy Policy",
"double_opt_in.check_email.body": "Please check your e-mail to confirm your e-mail address and validate your signature",
"double_opt_in.email.subject": "Confirm your signature",
"email_pension.form.other_pension_fund_text": "Can't find your pension fund?",
"email_pension.form.select_target": "Select your Pension or Mutual Fund",
"email_tool.form.email_body": "Body",
"email_tool.form.errors.country": "Please select a country",
"email_tool.form.errors.email": "Please add your email address",
"email_tool.form.errors.fund": "Please select a pension fund",
"email_tool.form.errors.fund_not_found": "We're sorry you couldn't find your pension fund. Send us its name and we'll update our records.",
"email_tool.form.errors.message": "Whoops! There are some errors with the form. Please check you've filled in the required fields.",
"email_tool.form.errors.name": "Please add you name",
"email_tool.form.errors.subject": "Please add a subject line",
"email_tool.form.errors.suggest_fund": "Name of pension fund can't be blank",
"email_tool.form.errors.target.outdated": "It seems the targets information has recently changed. Please reload the page and try again.",
"email_tool.form.errors.targets": "Please enter your location to find your representative",
"email_tool.form.name_of_your_pension_fund": "Name of your pension fund",
"email_tool.form.representative.not_found": "Sorry, we couldn't find a target with this location.",
"email_tool.form.representative.postal_code": "Enter your postal code",
"email_tool.form.representative.search_pending": "Please enter your postal code above.",
"email_tool.form.representative.searching": "Searching for your representative",
"email_tool.form.representative.selected_targets": "Representatives",
"email_tool.form.select_country": "Select your Country",
"email_tool.form.select_target": "Select a target",
"email_tool.form.send_button_text": "Send",
"email_tool.form.send_email": "Send email",
"email_tool.form.subject": "Subject line",
"email_tool.form.your_email": "Your email address",
Expand Down Expand Up @@ -591,6 +602,8 @@ exports[`renders correctly 1`] = `
"fundraiser.one_click_failed": "We're sorry but we could not process your donation. Please try again with a different card.",
"fundraiser.one_click_warning": "Your donation will be processed immediately.",
"fundraiser.oneclick.credit_card_payment_method": "{card_type} ending in {last_four_digits}",
"fundraiser.oneclick.duplicate_donation": "You've just made a donation a few minutes ago. Are you sure, you want to donate again? We're doing this to make sure you don't accidentally donate twice.
Thanks so much for everything you do!",
"fundraiser.oneclick.new_payment_method": "Add payment method",
"fundraiser.oneclick.paypal_payment_method": "Paypal ({email})",
"fundraiser.oneclick.select_payment": "Select a saved payment method",
Expand Down Expand Up @@ -666,6 +679,7 @@ SumOfUs",
"share.cta": "Share the campaign!",
"share.send_email": "Send Email",
"share.share": "Share",
"share.share_on_email": "Email",
"share.share_on_whatsapp": "Whatsapp",
"share.tweet": "Tweet",
"share.twitter_handle": "@sumofus",
Expand Down
Loading

0 comments on commit 93b6033

Please sign in to comment.