proposal_arbiter email
This commit is contained in:
parent
6fd885c274
commit
2b78a17973
|
@ -72,4 +72,9 @@ export default [
|
|||
title: 'Comment reply',
|
||||
description: 'Sent if someone makes a direct reply to your comment',
|
||||
},
|
||||
{
|
||||
id: 'proposal_arbiter',
|
||||
title: 'Arbiter assignment',
|
||||
description: 'Sent if someone is made arbiter of a proposal',
|
||||
},
|
||||
] as Email[];
|
||||
|
|
|
@ -99,4 +99,9 @@ example_email_args = {
|
|||
'comment_url': 'http://somecomment.com',
|
||||
'author_url': 'http://someuser.com',
|
||||
},
|
||||
'proposal_arbiter': {
|
||||
'proposal': proposal,
|
||||
'proposal_url': 'http://someproposal.com',
|
||||
'arbitration_url': 'http://arbitrationtab.com',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ from flask import Blueprint, request
|
|||
from flask import Blueprint, request
|
||||
from flask_yoloapi import endpoint, parameter
|
||||
from grant.comment.models import Comment, user_comments_schema
|
||||
from grant.email.send import generate_email
|
||||
from grant.email.send import generate_email, send_email
|
||||
from grant.extensions import db
|
||||
from grant.proposal.models import (
|
||||
Proposal,
|
||||
|
@ -15,6 +15,7 @@ from grant.user.models import User, admin_users_schema, admin_user_schema
|
|||
from grant.rfp.models import RFP, admin_rfp_schema, admin_rfps_schema
|
||||
from grant.utils.admin import admin_auth_required, admin_is_authed, admin_login, admin_logout
|
||||
from grant.utils.enums import ProposalStatus
|
||||
from grant.utils.misc import make_url
|
||||
from grant.utils import pagination
|
||||
from sqlalchemy import func, or_
|
||||
|
||||
|
@ -153,9 +154,17 @@ def set_arbiter(proposal_id, user_id):
|
|||
if not user:
|
||||
return {"message": "User not found"}, 404
|
||||
|
||||
proposal.arbiter_id = user.id
|
||||
db.session.add(proposal)
|
||||
db.session.commit()
|
||||
if proposal.arbiter_id != user.id:
|
||||
# send email
|
||||
send_email(user.email_address, 'proposal_arbiter', {
|
||||
'proposal': proposal,
|
||||
'proposal_url': make_url(f'/proposals/{proposal.id}'),
|
||||
'arbitration_url': make_url(f'/profile/{user.id}?tab=arbitration'),
|
||||
})
|
||||
proposal.arbiter_id = user.id
|
||||
db.session.add(proposal)
|
||||
db.session.commit()
|
||||
|
||||
return {
|
||||
'proposal': proposal_schema.dump(proposal),
|
||||
'user': admin_user_schema.dump(user)
|
||||
|
|
|
@ -154,6 +154,15 @@ def comment_reply(email_args):
|
|||
}
|
||||
|
||||
|
||||
def proposal_arbiter(email_args):
|
||||
return {
|
||||
'subject': f'You are now arbiter of {email_args["proposal"].title}',
|
||||
'title': f'You are an Arbiter',
|
||||
'preview': f'Congratulations, you have been promoted to arbiter of {email_args["proposal"].title}!',
|
||||
'subscription': EmailSubscription.ARBITER,
|
||||
}
|
||||
|
||||
|
||||
get_info_lookup = {
|
||||
'signup': signup_info,
|
||||
'team_invite': team_invite_info,
|
||||
|
@ -169,6 +178,7 @@ get_info_lookup = {
|
|||
'contribution_confirmed': contribution_confirmed,
|
||||
'contribution_update': contribution_update,
|
||||
'comment_reply': comment_reply,
|
||||
'proposal_arbiter': proposal_arbiter
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,10 @@ class EmailSubscription(Enum):
|
|||
'bit': 10,
|
||||
'key': 'funded_proposal_payout_request'
|
||||
}
|
||||
ARBITER = {
|
||||
'bit': 11,
|
||||
'key': 'arbiter'
|
||||
}
|
||||
|
||||
|
||||
def is_email_sub_key(k: str):
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<p style="margin: 0 0 20px;">
|
||||
You have been made arbiter of
|
||||
<a href="{{ args.proposal_url }}" target="_blank">
|
||||
{{ args.proposal.title }} </a
|
||||
>. You will be responsible for reviewing milestone payout requests.
|
||||
</p>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td bgcolor="#ffffff" align="center" style="padding: 40px 30px 40px 30px;">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td
|
||||
align="center"
|
||||
style="border-radius: 3px;"
|
||||
bgcolor="{{ UI.PRIMARY }}"
|
||||
>
|
||||
<a
|
||||
href="{{ args.arbitration_url }}"
|
||||
target="_blank"
|
||||
style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; color: #ffffff; text-decoration: none; padding: 20px 50px; border-radius: 4px; border: 1px solid {{
|
||||
UI.PRIMARY
|
||||
}}; display: inline-block;"
|
||||
>
|
||||
View your arbitrations
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
|
@ -0,0 +1,4 @@
|
|||
You have been made arbiter of {{ args.proposal.title }}. You will be responsible
|
||||
for reviewing milestone payout requests.
|
||||
|
||||
View your arbitrations: {{ args.arbitration_url }}
|
|
@ -13,6 +13,11 @@ export const EMAIL_SUBSCRIPTIONS: { [key in ESKey]: EmailSubscriptionInfo } = {
|
|||
category: EMAIL_SUBSCRIPTION_CATEGORY.GENERAL,
|
||||
value: false,
|
||||
},
|
||||
arbiter: {
|
||||
description: 'arbitration',
|
||||
category: EMAIL_SUBSCRIPTION_CATEGORY.GENERAL,
|
||||
value: false,
|
||||
},
|
||||
|
||||
// FUNDED
|
||||
fundedProposalCanceled: {
|
||||
|
|
|
@ -11,6 +11,7 @@ export interface EmailSubscriptions {
|
|||
myProposalContribution: boolean;
|
||||
myProposalFunded: boolean;
|
||||
myProposalRefund: boolean;
|
||||
arbiter: boolean;
|
||||
}
|
||||
|
||||
export enum EMAIL_SUBSCRIPTION_CATEGORY {
|
||||
|
|
Loading…
Reference in New Issue