Merge branch 'develop' into admin-users
This commit is contained in:
commit
076bcc67bf
|
@ -9,9 +9,9 @@ from .subscription_settings import EmailSubscription, is_subscribed
|
|||
|
||||
default_template_args = {
|
||||
'home_url': make_url('/'),
|
||||
'account_url': make_url('/user'),
|
||||
'email_settings_url': make_url('/settings'),
|
||||
'unsubscribe_url': make_url('/unsubscribe'),
|
||||
'account_url': make_url('/profile'),
|
||||
'email_settings_url': make_url('/profile/settings?tab=emails'),
|
||||
'unsubscribe_url': make_url('/profile/settings?tab=emails'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,6 +113,7 @@ def proposal_failed(email_args):
|
|||
'preview': 'Your proposal entitled {} failed to get enough funding by the deadline'.format(
|
||||
email_args['proposal'].title,
|
||||
),
|
||||
'subscription': EmailSubscription.MY_PROPOSAL_FUNDED,
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,7 +268,7 @@ get_info_lookup = {
|
|||
}
|
||||
|
||||
|
||||
def generate_email(type, email_args):
|
||||
def generate_email(type, email_args, user=None):
|
||||
info = get_info_lookup[type](email_args)
|
||||
body_text = render_template(
|
||||
'emails/%s.txt' % (type),
|
||||
|
@ -280,10 +281,15 @@ def generate_email(type, email_args):
|
|||
UI=UI,
|
||||
)
|
||||
|
||||
template_args = { **default_template_args }
|
||||
if user:
|
||||
template_args['unsubscribe_url'] = make_url('/email/unsubscribe?code={}'.format(user.email_verification.code))
|
||||
|
||||
|
||||
html = render_template(
|
||||
'emails/template.html',
|
||||
args={
|
||||
**default_template_args,
|
||||
**template_args,
|
||||
**info,
|
||||
'body': Markup(body_html),
|
||||
},
|
||||
|
@ -292,7 +298,7 @@ def generate_email(type, email_args):
|
|||
text = render_template(
|
||||
'emails/template.txt',
|
||||
args={
|
||||
**default_template_args,
|
||||
**template_args,
|
||||
**info,
|
||||
'body': body_text,
|
||||
},
|
||||
|
@ -310,17 +316,18 @@ def send_email(to, type, email_args):
|
|||
if current_app and current_app.config.get("TESTING"):
|
||||
return
|
||||
|
||||
from grant.user.models import User
|
||||
user = User.get_by_email(to)
|
||||
info = get_info_lookup[type](email_args)
|
||||
|
||||
if 'subscription' in info and 'user' in email_args:
|
||||
user = email_args['user']
|
||||
if user and 'subscription' in info:
|
||||
sub = info['subscription']
|
||||
if not is_subscribed(user.settings.email_subscriptions, sub):
|
||||
if user and not is_subscribed(user.settings.email_subscriptions, sub):
|
||||
print(f'Ignoring send_email to {to} of type {type} because user is unsubscribed.')
|
||||
return
|
||||
|
||||
try:
|
||||
email = generate_email(type, email_args)
|
||||
email = generate_email(type, email_args, user)
|
||||
sg = sendgrid.SendGridAPIClient(apikey=SENDGRID_API_KEY)
|
||||
|
||||
mail = Mail(
|
||||
|
|
|
@ -700,7 +700,12 @@ class ProposalContributionSchema(ma.Schema):
|
|||
return dt_to_unix(obj.date_created)
|
||||
|
||||
def get_addresses(self, obj):
|
||||
return blockchain_get('/contribution/addresses', {'contributionId': obj.id})
|
||||
# Omit 'memo' and 'sprout' for now
|
||||
# TODO: Add back in 'sapling' when ready
|
||||
addresses = blockchain_get('/contribution/addresses', {'contributionId': obj.id})
|
||||
return {
|
||||
'transparent': addresses['transparent'],
|
||||
}
|
||||
|
||||
|
||||
proposal_contribution_schema = ProposalContributionSchema()
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
<td align="center" bgcolor="#f4f4f4"
|
||||
style="padding: 0px 30px 30px 30px; color: #666666; font-family: 'Nunito Sans', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;">
|
||||
<p style="margin: 0;">
|
||||
Don’t want anymore emails?
|
||||
Don’t want any more emails?
|
||||
<a href="{{ args.unsubscribe_url }}" style="color: #221F1F; font-weight: 700;"
|
||||
target="_blank">
|
||||
Click here to unsubscribe
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
123 Address Street
|
||||
City, ST 12345
|
||||
|
||||
Unsubscribe here: {{ args.unsubscribe_url }}
|
||||
Don't want any more emails? Unsubscribe here: {{ args.unsubscribe_url }}
|
|
@ -1,6 +1,6 @@
|
|||
import React, { ReactNode } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { Button, Form, Icon, Radio } from 'antd';
|
||||
import { Button, Form, Icon, Radio, Alert } from 'antd';
|
||||
import { RadioChangeEvent } from 'antd/lib/radio';
|
||||
import QRCode from 'qrcode.react';
|
||||
import { formatZcashCLI, formatZcashURI } from 'utils/formatters';
|
||||
|
@ -22,7 +22,7 @@ interface State {
|
|||
|
||||
export default class PaymentInfo extends React.Component<Props, State> {
|
||||
state: State = {
|
||||
sendType: 'sprout',
|
||||
sendType: 'transparent',
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@ -36,14 +36,73 @@ export default class PaymentInfo extends React.Component<Props, State> {
|
|||
|
||||
if (contribution) {
|
||||
if (sendType !== 'transparent') {
|
||||
memo = contribution.addresses.memo;
|
||||
memo = 'Fix me';
|
||||
// memo = contribution.addresses.memo;
|
||||
}
|
||||
address = contribution.addresses[sendType];
|
||||
// address = contribution.addresses[sendType];
|
||||
address = contribution.addresses.transparent;
|
||||
amount = contribution.amount;
|
||||
cli = formatZcashCLI(address, amount, memo);
|
||||
uri = formatZcashURI(address, amount, memo);
|
||||
}
|
||||
|
||||
let content;
|
||||
if (sendType === 'sprout') {
|
||||
content = (
|
||||
<Alert
|
||||
type="warning"
|
||||
message="Not yet supported"
|
||||
description={`
|
||||
Unfortunately, sapling addresses aren't yet supported, and sprout addresses
|
||||
have been deprecated. We hope to add support in the near future!
|
||||
`}
|
||||
showIcon
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
content = (
|
||||
<>
|
||||
<div className="PaymentInfo-uri">
|
||||
<div className={classnames('PaymentInfo-uri-qr', !uri && 'is-loading')}>
|
||||
<span style={{ opacity: uri ? 1 : 0 }}>
|
||||
<QRCode value={uri || ''} />
|
||||
</span>
|
||||
{!uri && <Loader />}
|
||||
</div>
|
||||
<div className="PaymentInfo-uri-info">
|
||||
<CopyInput
|
||||
className="PaymentInfo-uri-info-input"
|
||||
label="Payment URI"
|
||||
value={uri}
|
||||
isTextarea
|
||||
/>
|
||||
<Button type="ghost" size="large" href={uri} block>
|
||||
Open in Wallet <Icon type="link" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="PaymentInfo-fields">
|
||||
<div className="PaymentInfo-fields-row">
|
||||
<CopyInput
|
||||
className="PaymentInfo-fields-row-address"
|
||||
label="Address"
|
||||
value={address}
|
||||
/>
|
||||
{memo && <CopyInput label="Memo" value={memo} />}
|
||||
</div>
|
||||
<div className="PaymentInfo-fields-row">
|
||||
<CopyInput
|
||||
label="Zcash CLI command"
|
||||
help="Make sure you replace YOUR_ADDRESS with your actual address"
|
||||
value={cli}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Form className="PaymentInfo" layout="vertical">
|
||||
<div className="PaymentInfo-text">
|
||||
|
@ -53,53 +112,15 @@ export default class PaymentInfo extends React.Component<Props, State> {
|
|||
you, and we'll let you know when your contribution has been confirmed.
|
||||
`}
|
||||
</div>
|
||||
|
||||
<Radio.Group
|
||||
className="PaymentInfo-types"
|
||||
onChange={this.handleChangeSendType}
|
||||
value={sendType}
|
||||
>
|
||||
<Radio.Button value="sprout">Z Address (Private)</Radio.Button>
|
||||
<Radio.Button value="transparent">T Address (Public)</Radio.Button>
|
||||
<Radio.Button value="sprout">Z Address (Private)</Radio.Button>
|
||||
</Radio.Group>
|
||||
|
||||
<div className="PaymentInfo-uri">
|
||||
<div className={classnames('PaymentInfo-uri-qr', !uri && 'is-loading')}>
|
||||
<span style={{ opacity: uri ? 1 : 0 }}>
|
||||
<QRCode value={uri || ''} />
|
||||
</span>
|
||||
{!uri && <Loader />}
|
||||
</div>
|
||||
<div className="PaymentInfo-uri-info">
|
||||
<CopyInput
|
||||
className="PaymentInfo-uri-info-input"
|
||||
label="Payment URI"
|
||||
value={uri}
|
||||
isTextarea
|
||||
/>
|
||||
<Button type="ghost" size="large" href={uri} block>
|
||||
Open in Wallet <Icon type="link" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="PaymentInfo-fields">
|
||||
<div className="PaymentInfo-fields-row">
|
||||
<CopyInput
|
||||
className="PaymentInfo-fields-row-address"
|
||||
label="Address"
|
||||
value={address}
|
||||
/>
|
||||
{memo && <CopyInput label="Memo" value={memo} />}
|
||||
</div>
|
||||
<div className="PaymentInfo-fields-row">
|
||||
<CopyInput
|
||||
label="Zcash CLI command"
|
||||
help="Make sure you replace YOUR_ADDRESS with your actual address"
|
||||
value={cli}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{content}
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ export const EMAIL_SUBSCRIPTIONS: { [key in ESKey]: EmailSubscriptionInfo } = {
|
|||
value: false,
|
||||
},
|
||||
fundedProposalFunded: {
|
||||
description: 'gets full funding',
|
||||
description: 'gets fully funded or fails to get funding',
|
||||
category: EMAIL_SUBSCRIPTION_CATEGORY.FUNDED,
|
||||
value: false,
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ export const EMAIL_SUBSCRIPTIONS: { [key in ESKey]: EmailSubscriptionInfo } = {
|
|||
value: false,
|
||||
},
|
||||
myProposalFunded: {
|
||||
description: 'gets fully funded',
|
||||
description: 'gets fully funded or fails to get funding',
|
||||
category: EMAIL_SUBSCRIPTION_CATEGORY.PROPOSAL,
|
||||
value: false,
|
||||
},
|
||||
|
|
|
@ -11,9 +11,10 @@ export interface Contribution {
|
|||
|
||||
export interface ContributionWithAddresses extends Contribution {
|
||||
addresses: {
|
||||
sprout: string;
|
||||
transparent: string;
|
||||
memo: string;
|
||||
// TODO: Add sapling and memo in when ready
|
||||
// sprout: string;
|
||||
// memo: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue