2019-03-14 13:29:02 -07:00
|
|
|
import validators
|
2019-01-16 14:26:45 -08:00
|
|
|
from animal_case import keys_to_snake_case
|
2019-03-14 13:29:02 -07:00
|
|
|
from flask import Blueprint, g, current_app
|
2019-03-01 12:11:03 -08:00
|
|
|
from marshmallow import fields
|
2019-03-14 13:29:02 -07:00
|
|
|
from validate_email import validate_email
|
2019-03-18 12:03:01 -07:00
|
|
|
from webargs import validate
|
2019-03-01 12:11:03 -08:00
|
|
|
|
|
|
|
import grant.utils.auth as auth
|
2018-11-30 15:52:00 -08:00
|
|
|
from grant.comment.models import Comment, user_comments_schema
|
2019-01-22 21:35:22 -08:00
|
|
|
from grant.email.models import EmailRecovery
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
from grant.ccr.models import CCR, ccrs_schema
|
2019-03-14 13:29:02 -07:00
|
|
|
from grant.extensions import limiter
|
2019-03-01 12:11:03 -08:00
|
|
|
from grant.parser import query, body
|
2018-11-30 15:52:00 -08:00
|
|
|
from grant.proposal.models import (
|
|
|
|
Proposal,
|
|
|
|
ProposalTeamInvite,
|
|
|
|
invites_with_proposal_schema,
|
2019-01-09 11:07:50 -08:00
|
|
|
user_proposal_contributions_schema,
|
2019-01-09 10:23:08 -08:00
|
|
|
user_proposals_schema,
|
2019-02-09 18:58:40 -08:00
|
|
|
user_proposal_arbiters_schema
|
2018-11-30 15:52:00 -08:00
|
|
|
)
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
from grant.proposal.models import ProposalContribution
|
2019-03-01 12:11:03 -08:00
|
|
|
from grant.utils.enums import ProposalStatus, ContributionStatus
|
2019-01-22 21:35:22 -08:00
|
|
|
from grant.utils.exceptions import ValidationException
|
2019-03-14 13:29:02 -07:00
|
|
|
from grant.utils.requests import validate_blockchain_get
|
2019-01-02 10:23:02 -08:00
|
|
|
from grant.utils.social import verify_social, get_social_login_url, VerifySocialException
|
2019-01-22 21:35:22 -08:00
|
|
|
from grant.utils.upload import remove_avatar, sign_avatar_upload, AvatarException
|
2019-01-16 14:26:45 -08:00
|
|
|
from .models import (
|
|
|
|
User,
|
|
|
|
SocialMedia,
|
|
|
|
Avatar,
|
2019-01-27 14:13:12 -08:00
|
|
|
self_user_schema,
|
2019-01-16 14:26:45 -08:00
|
|
|
user_schema,
|
|
|
|
user_settings_schema,
|
|
|
|
db
|
|
|
|
)
|
2018-09-25 13:09:25 -07:00
|
|
|
|
|
|
|
blueprint = Blueprint('user', __name__, url_prefix='/api/v1/users')
|
|
|
|
|
|
|
|
|
2018-10-19 22:18:27 -07:00
|
|
|
@blueprint.route("/me", methods=["GET"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2018-10-19 22:18:27 -07:00
|
|
|
def get_me():
|
2019-01-27 14:13:12 -08:00
|
|
|
dumped_user = self_user_schema.dump(g.current_user)
|
2018-11-04 10:33:22 -08:00
|
|
|
return dumped_user
|
2018-10-19 22:18:27 -07:00
|
|
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/<user_id>", methods=["GET"])
|
2019-03-01 12:11:03 -08:00
|
|
|
@query({
|
|
|
|
"withProposals": fields.Bool(required=False, missing=None),
|
|
|
|
"withComments": fields.Bool(required=False, missing=None),
|
|
|
|
"withFunded": fields.Bool(required=False, missing=None),
|
|
|
|
"withPending": fields.Bool(required=False, missing=None),
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
"withArbitrated": fields.Bool(required=False, missing=None),
|
|
|
|
"withRequests": fields.Bool(required=False, missing=None)
|
|
|
|
|
2019-03-01 12:11:03 -08:00
|
|
|
})
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
def get_user(user_id, with_proposals, with_comments, with_funded, with_pending, with_arbitrated, with_requests):
|
2018-12-14 11:36:22 -08:00
|
|
|
user = User.get_by_id(user_id)
|
2018-09-26 12:42:40 -07:00
|
|
|
if user:
|
|
|
|
result = user_schema.dump(user)
|
2019-02-21 14:23:46 -08:00
|
|
|
authed_user = auth.get_authed_user()
|
2019-02-06 14:37:45 -08:00
|
|
|
is_self = authed_user and authed_user.id == user.id
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
if with_requests:
|
|
|
|
requests = CCR.get_by_user(user)
|
|
|
|
requests_dump = ccrs_schema.dump(requests)
|
|
|
|
result["requests"] = requests_dump
|
2018-11-30 15:52:00 -08:00
|
|
|
if with_proposals:
|
|
|
|
proposals = Proposal.get_by_user(user)
|
|
|
|
proposals_dump = user_proposals_schema.dump(proposals)
|
2019-01-09 11:07:50 -08:00
|
|
|
result["proposals"] = proposals_dump
|
2018-11-30 15:52:00 -08:00
|
|
|
if with_funded:
|
2019-01-09 11:07:50 -08:00
|
|
|
contributions = ProposalContribution.get_by_userid(user_id)
|
2019-01-09 14:54:41 -08:00
|
|
|
if not authed_user or user.id != authed_user.id:
|
2019-01-30 09:59:15 -08:00
|
|
|
contributions = [c for c in contributions if c.status == ContributionStatus.CONFIRMED]
|
2019-06-11 19:49:14 -07:00
|
|
|
contributions = [c for c in contributions if not c.private]
|
2019-02-25 08:41:00 -08:00
|
|
|
contributions = [c for c in contributions if c.proposal.status == ProposalStatus.LIVE]
|
2019-01-09 11:07:50 -08:00
|
|
|
contributions_dump = user_proposal_contributions_schema.dump(contributions)
|
|
|
|
result["contributions"] = contributions_dump
|
2018-11-30 15:52:00 -08:00
|
|
|
if with_comments:
|
|
|
|
comments = Comment.get_by_user(user)
|
|
|
|
comments_dump = user_comments_schema.dump(comments)
|
|
|
|
result["comments"] = comments_dump
|
2019-02-06 14:37:45 -08:00
|
|
|
if with_pending and is_self:
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
pending_proposals = Proposal.get_by_user(user, [
|
|
|
|
ProposalStatus.STAKING,
|
|
|
|
ProposalStatus.PENDING,
|
|
|
|
ProposalStatus.APPROVED,
|
|
|
|
ProposalStatus.REJECTED,
|
|
|
|
])
|
|
|
|
pending_proposals_dump = user_proposals_schema.dump(pending_proposals)
|
|
|
|
result["pendingProposals"] = pending_proposals_dump
|
|
|
|
pending_ccrs = CCR.get_by_user(user, [
|
2019-01-31 14:56:16 -08:00
|
|
|
ProposalStatus.STAKING,
|
2019-01-30 09:59:15 -08:00
|
|
|
ProposalStatus.PENDING,
|
|
|
|
ProposalStatus.APPROVED,
|
|
|
|
ProposalStatus.REJECTED,
|
|
|
|
])
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
pending_ccrs_dump = ccrs_schema.dump(pending_ccrs)
|
|
|
|
result["pendingRequests"] = pending_ccrs_dump
|
2019-02-06 14:37:45 -08:00
|
|
|
if with_arbitrated and is_self:
|
2019-02-09 18:58:40 -08:00
|
|
|
result["arbitrated"] = user_proposal_arbiters_schema.dump(user.arbiter_proposals)
|
|
|
|
|
2018-11-04 10:33:22 -08:00
|
|
|
return result
|
2018-09-26 12:42:40 -07:00
|
|
|
else:
|
2018-12-14 11:36:22 -08:00
|
|
|
message = "User with id matching {} not found".format(user_id)
|
2018-11-04 10:33:22 -08:00
|
|
|
return {"message": message}, 404
|
2018-10-01 16:22:56 -07:00
|
|
|
|
2018-10-19 22:18:27 -07:00
|
|
|
|
2018-10-01 16:22:56 -07:00
|
|
|
@blueprint.route("/", methods=["POST"])
|
2019-03-12 20:35:38 -07:00
|
|
|
@limiter.limit("30/day;5/minute")
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
2019-03-14 13:29:02 -07:00
|
|
|
"emailAddress": fields.Str(required=True, validate=lambda e: validate_email(e)),
|
2019-03-01 12:11:03 -08:00
|
|
|
"password": fields.Str(required=True),
|
2019-03-18 12:03:01 -07:00
|
|
|
"displayName": fields.Str(required=True, validate=validate.Length(min=2, max=50)),
|
|
|
|
"title": fields.Str(required=True, validate=validate.Length(min=2, max=50)),
|
2019-03-01 12:11:03 -08:00
|
|
|
})
|
2018-11-07 11:08:42 -08:00
|
|
|
def create_user(
|
2018-11-13 06:17:06 -08:00
|
|
|
email_address,
|
2018-12-14 11:36:22 -08:00
|
|
|
password,
|
2018-11-13 06:17:06 -08:00
|
|
|
display_name,
|
2018-12-14 11:36:22 -08:00
|
|
|
title
|
2018-11-07 11:08:42 -08:00
|
|
|
):
|
2018-12-14 11:36:22 -08:00
|
|
|
existing_user = User.get_by_email(email_address)
|
2018-10-01 16:22:56 -07:00
|
|
|
if existing_user:
|
2018-12-14 11:36:22 -08:00
|
|
|
return {"message": "User with that email already exists"}, 409
|
2018-10-01 16:22:56 -07:00
|
|
|
|
2018-11-02 09:07:06 -07:00
|
|
|
user = User.create(
|
2018-10-01 16:22:56 -07:00
|
|
|
email_address=email_address,
|
2018-12-14 11:36:22 -08:00
|
|
|
password=password,
|
2018-10-01 16:22:56 -07:00
|
|
|
display_name=display_name,
|
|
|
|
title=title
|
|
|
|
)
|
2018-12-14 11:36:22 -08:00
|
|
|
user.login()
|
2019-01-27 14:13:12 -08:00
|
|
|
result = self_user_schema.dump(user)
|
2018-11-27 11:07:09 -08:00
|
|
|
return result, 201
|
2018-10-30 07:40:21 -07:00
|
|
|
|
2018-11-13 06:17:06 -08:00
|
|
|
|
2018-11-07 11:08:42 -08:00
|
|
|
@blueprint.route("/auth", methods=["POST"])
|
2019-06-25 08:02:44 -07:00
|
|
|
@limiter.limit("30/hour;5/minute")
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"email": fields.Str(required=True),
|
|
|
|
"password": fields.Str(required=True)
|
|
|
|
})
|
2018-12-14 11:36:22 -08:00
|
|
|
def auth_user(email, password):
|
2019-02-21 14:23:46 -08:00
|
|
|
authed_user = auth.auth_user(email, password)
|
|
|
|
return self_user_schema.dump(authed_user)
|
2018-11-07 11:08:42 -08:00
|
|
|
|
2018-11-13 06:17:06 -08:00
|
|
|
|
2019-01-24 10:53:26 -08:00
|
|
|
@blueprint.route("/me/password", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"currentPassword": fields.Str(required=True),
|
|
|
|
"password": fields.Str(required=True)
|
|
|
|
})
|
2018-12-14 11:36:22 -08:00
|
|
|
def update_user_password(current_password, password):
|
|
|
|
if not g.current_user.check_password(current_password):
|
|
|
|
return {"message": "Current password incorrect"}, 403
|
|
|
|
g.current_user.set_password(password)
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2018-10-30 07:40:21 -07:00
|
|
|
|
2018-11-13 06:17:06 -08:00
|
|
|
|
2019-01-24 10:53:26 -08:00
|
|
|
@blueprint.route("/me/email", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
2019-03-14 13:29:02 -07:00
|
|
|
"email": fields.Str(required=True, validate=lambda e: validate_email(e)),
|
2019-03-01 12:11:03 -08:00
|
|
|
"password": fields.Str(required=True)
|
|
|
|
})
|
2019-01-24 10:53:26 -08:00
|
|
|
def update_user_email(email, password):
|
|
|
|
if not g.current_user.check_password(password):
|
|
|
|
return {"message": "Password is incorrect"}, 403
|
2019-03-14 13:29:02 -07:00
|
|
|
current_app.logger.info(
|
|
|
|
f"Updating userId: {g.current_user.id} with current email: {g.current_user.email_address} to new email: {email}"
|
|
|
|
)
|
2019-01-24 10:53:26 -08:00
|
|
|
g.current_user.set_email(email)
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2019-01-24 10:53:26 -08:00
|
|
|
|
|
|
|
|
2019-02-08 11:57:54 -08:00
|
|
|
@blueprint.route("/me/resend-verification", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-02-08 11:57:54 -08:00
|
|
|
def resend_email_verification():
|
|
|
|
g.current_user.send_verification_email()
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2019-02-08 11:57:54 -08:00
|
|
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/logout", methods=["POST"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2018-12-14 11:36:22 -08:00
|
|
|
def logout_user():
|
2019-02-21 14:23:46 -08:00
|
|
|
auth.logout_current_user()
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2018-12-14 11:36:22 -08:00
|
|
|
|
|
|
|
|
2019-01-02 10:23:02 -08:00
|
|
|
@blueprint.route("/social/<service>/authurl", methods=["GET"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-01-02 10:23:02 -08:00
|
|
|
def get_user_social_auth_url(service):
|
|
|
|
try:
|
|
|
|
return {"url": get_social_login_url(service)}
|
|
|
|
|
|
|
|
except VerifySocialException as e:
|
|
|
|
return {"message": str(e)}, 400
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/social/<service>/verify", methods=["POST"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"code": fields.Str(required=True)
|
|
|
|
})
|
2019-01-02 10:23:02 -08:00
|
|
|
def verify_user_social(service, code):
|
|
|
|
try:
|
|
|
|
# 1. verify with 3rd party
|
|
|
|
username = verify_social(service, code)
|
|
|
|
# 2. remove existing username/service
|
|
|
|
sm_other_db = SocialMedia.query.filter_by(service=service, username=username).first()
|
|
|
|
if sm_other_db:
|
|
|
|
db.session.delete(sm_other_db)
|
|
|
|
# 3. remove existing for authed user/service
|
|
|
|
sm_self_db = SocialMedia.query.filter_by(service=service, user_id=g.current_user.id).first()
|
|
|
|
if sm_self_db:
|
|
|
|
db.session.delete(sm_self_db)
|
|
|
|
# 4. set this users verified social item
|
|
|
|
sm = SocialMedia(service=service, username=username, user_id=g.current_user.id)
|
|
|
|
db.session.add(sm)
|
|
|
|
db.session.commit()
|
|
|
|
return {"username": username}, 200
|
|
|
|
|
|
|
|
except VerifySocialException as e:
|
|
|
|
return {"message": str(e)}, 400
|
|
|
|
|
|
|
|
|
2018-12-17 10:33:33 -08:00
|
|
|
@blueprint.route("/recover", methods=["POST"])
|
2019-03-12 20:35:38 -07:00
|
|
|
@limiter.limit("10/day;2/minute")
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"email": fields.Str(required=True)
|
|
|
|
})
|
2018-12-17 10:33:33 -08:00
|
|
|
def recover_user(email):
|
|
|
|
existing_user = User.get_by_email(email)
|
|
|
|
if not existing_user:
|
|
|
|
return {"message": "No user exists with that email"}, 400
|
2019-02-21 14:23:46 -08:00
|
|
|
auth.throw_on_banned(existing_user)
|
2018-12-17 10:33:33 -08:00
|
|
|
existing_user.send_recovery_email()
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2018-12-17 10:33:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/recover/<code>", methods=["POST"])
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"password": fields.Str(required=True)
|
|
|
|
})
|
2018-12-17 10:33:33 -08:00
|
|
|
def recover_email(code, password):
|
|
|
|
er = EmailRecovery.query.filter_by(code=code).first()
|
|
|
|
if er:
|
|
|
|
if er.is_expired():
|
|
|
|
return {"message": "Reset code expired"}, 401
|
2019-02-21 14:23:46 -08:00
|
|
|
auth.throw_on_banned(er.user)
|
2018-12-17 10:33:33 -08:00
|
|
|
er.user.set_password(password)
|
|
|
|
db.session.delete(er)
|
|
|
|
db.session.commit()
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2018-12-17 10:33:33 -08:00
|
|
|
|
|
|
|
return {"message": "Invalid reset code"}, 400
|
|
|
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/avatar", methods=["POST"])
|
2019-03-12 20:35:38 -07:00
|
|
|
@limiter.limit("20/day;3/minute")
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"mimetype": fields.Str(required=True)
|
|
|
|
})
|
2018-12-14 11:36:22 -08:00
|
|
|
def upload_avatar(mimetype):
|
2018-11-16 19:33:25 -08:00
|
|
|
user = g.current_user
|
|
|
|
try:
|
2018-12-14 11:36:22 -08:00
|
|
|
signed_post = sign_avatar_upload(mimetype, user.id)
|
|
|
|
return signed_post
|
|
|
|
except AvatarException as e:
|
2018-11-16 19:33:25 -08:00
|
|
|
return {"message": str(e)}, 400
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/avatar", methods=["DELETE"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"url": fields.Str(required=True)
|
|
|
|
})
|
2018-11-16 19:33:25 -08:00
|
|
|
def delete_avatar(url):
|
|
|
|
user = g.current_user
|
|
|
|
remove_avatar(url, user.id)
|
|
|
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/<user_id>", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_auth
|
|
|
|
@auth.requires_same_user_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
2019-03-14 13:29:02 -07:00
|
|
|
"displayName": fields.Str(required=True, validate=lambda d: 2 <= len(d) <= 60),
|
|
|
|
"title": fields.Str(required=True, validate=lambda t: 2 <= len(t) <= 60),
|
2019-03-01 12:11:03 -08:00
|
|
|
"socialMedias": fields.List(fields.Dict(), required=True),
|
2019-03-14 18:55:13 -07:00
|
|
|
"avatar": fields.Str(required=True, allow_none=True, validate=lambda d: validators.url(d))
|
2019-03-01 12:11:03 -08:00
|
|
|
})
|
2018-12-14 11:36:22 -08:00
|
|
|
def update_user(user_id, display_name, title, social_medias, avatar):
|
2018-11-13 06:17:06 -08:00
|
|
|
user = g.current_user
|
2018-10-30 07:40:21 -07:00
|
|
|
|
|
|
|
if display_name is not None:
|
|
|
|
user.display_name = display_name
|
|
|
|
|
|
|
|
if title is not None:
|
|
|
|
user.title = title
|
|
|
|
|
2019-01-02 10:23:02 -08:00
|
|
|
# only allow deletions here, check for absent items
|
2018-11-16 15:05:17 -08:00
|
|
|
db_socials = SocialMedia.query.filter_by(user_id=user.id).all()
|
2019-01-02 10:23:02 -08:00
|
|
|
new_socials = list(map(lambda s: s['service'], social_medias))
|
|
|
|
for social in db_socials:
|
|
|
|
if social.service not in new_socials:
|
|
|
|
db.session.delete(social)
|
2018-11-16 15:05:17 -08:00
|
|
|
|
|
|
|
db_avatar = Avatar.query.filter_by(user_id=user.id).first()
|
|
|
|
if db_avatar:
|
|
|
|
db.session.delete(db_avatar)
|
|
|
|
if avatar:
|
|
|
|
new_avatar = Avatar(image_url=avatar, user_id=user.id)
|
|
|
|
db.session.add(new_avatar)
|
2018-10-30 07:40:21 -07:00
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
old_avatar_url = db_avatar and db_avatar.image_url
|
|
|
|
if old_avatar_url and old_avatar_url != avatar:
|
|
|
|
remove_avatar(old_avatar_url, user.id)
|
2018-11-16 19:33:25 -08:00
|
|
|
|
2018-10-30 07:40:21 -07:00
|
|
|
db.session.commit()
|
2019-01-27 14:13:12 -08:00
|
|
|
result = self_user_schema.dump(user)
|
2018-10-30 07:40:21 -07:00
|
|
|
return result
|
2018-11-16 10:50:47 -08:00
|
|
|
|
2018-11-30 15:52:00 -08:00
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/<user_id>/invites", methods=["GET"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_same_user_auth
|
2018-12-14 11:36:22 -08:00
|
|
|
def get_user_invites(user_id):
|
2018-11-16 10:50:47 -08:00
|
|
|
invites = ProposalTeamInvite.get_pending_for_user(g.current_user)
|
|
|
|
return invites_with_proposal_schema.dump(invites)
|
|
|
|
|
2018-11-30 15:52:00 -08:00
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
@blueprint.route("/<user_id>/invites/<invite_id>/respond", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_same_user_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"response": fields.Bool(required=True)
|
|
|
|
})
|
2018-12-14 11:36:22 -08:00
|
|
|
def respond_to_invite(user_id, invite_id, response):
|
2018-11-16 10:50:47 -08:00
|
|
|
invite = ProposalTeamInvite.query.filter_by(id=invite_id).first()
|
|
|
|
if not invite:
|
|
|
|
return {"message": "No invite found with id {}".format(invite_id)}, 404
|
2018-11-30 15:52:00 -08:00
|
|
|
|
2018-11-16 10:50:47 -08:00
|
|
|
invite.accepted = response
|
|
|
|
db.session.add(invite)
|
|
|
|
|
|
|
|
if invite.accepted:
|
|
|
|
invite.proposal.team.append(g.current_user)
|
|
|
|
db.session.add(invite)
|
2018-11-30 15:52:00 -08:00
|
|
|
|
2018-11-16 10:50:47 -08:00
|
|
|
db.session.commit()
|
2019-03-01 12:11:03 -08:00
|
|
|
return {"message": "ok"}, 200
|
2019-01-16 14:26:45 -08:00
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/<user_id>/settings", methods=["GET"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_same_user_auth
|
2019-01-16 14:26:45 -08:00
|
|
|
def get_user_settings(user_id):
|
|
|
|
return user_settings_schema.dump(g.current_user.settings)
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/<user_id>/settings", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_same_user_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
2019-03-12 10:08:16 -07:00
|
|
|
"emailSubscriptions": fields.Dict(required=False, missing=None),
|
2019-03-14 13:29:02 -07:00
|
|
|
"refundAddress": fields.Str(required=False, missing=None,
|
2019-11-13 15:44:35 -08:00
|
|
|
validate=lambda r: validate_blockchain_get('/validate/address', {'address': r})),
|
|
|
|
"tipJarAddress": fields.Str(required=False, missing=None,
|
|
|
|
validate=lambda r: validate_blockchain_get('/validate/address', {'address': r})),
|
|
|
|
"tipJarViewKey": fields.Str(required=False, missing=None) # TODO: add viewkey validation here
|
2019-03-01 12:11:03 -08:00
|
|
|
})
|
2019-11-13 15:44:35 -08:00
|
|
|
def set_user_settings(user_id, email_subscriptions, refund_address, tip_jar_address, tip_jar_view_key):
|
2019-02-16 08:49:32 -08:00
|
|
|
if email_subscriptions:
|
|
|
|
try:
|
2019-01-16 14:26:45 -08:00
|
|
|
email_subscriptions = keys_to_snake_case(email_subscriptions)
|
|
|
|
g.current_user.settings.email_subscriptions = email_subscriptions
|
2019-02-16 08:49:32 -08:00
|
|
|
except ValidationException as e:
|
|
|
|
return {"message": str(e)}, 400
|
|
|
|
|
2019-03-13 16:36:24 -07:00
|
|
|
if refund_address == '' and g.current_user.settings.refund_address:
|
|
|
|
return {"message": "Refund address cannot be unset, only changed"}, 400
|
2019-02-16 08:49:32 -08:00
|
|
|
if refund_address:
|
|
|
|
g.current_user.settings.refund_address = refund_address
|
|
|
|
|
2019-11-13 15:44:35 -08:00
|
|
|
# TODO: is additional validation needed similar to refund_address?
|
|
|
|
if tip_jar_address is not None:
|
|
|
|
g.current_user.settings.tip_jar_address = tip_jar_address
|
|
|
|
if tip_jar_view_key is not None:
|
|
|
|
g.current_user.settings.tip_jar_view_key = tip_jar_view_key
|
|
|
|
|
2019-01-16 14:26:45 -08:00
|
|
|
db.session.commit()
|
|
|
|
return user_settings_schema.dump(g.current_user.settings)
|
2019-02-09 18:58:40 -08:00
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/<user_id>/arbiter/<proposal_id>", methods=["PUT"])
|
2019-02-21 14:23:46 -08:00
|
|
|
@auth.requires_same_user_auth
|
2019-03-01 12:11:03 -08:00
|
|
|
@body({
|
|
|
|
"isAccept": fields.Bool(required=False, missing=None)
|
|
|
|
})
|
2019-02-09 18:58:40 -08:00
|
|
|
def set_user_arbiter(user_id, proposal_id, is_accept):
|
|
|
|
try:
|
|
|
|
proposal = Proposal.query.filter_by(id=int(proposal_id)).first()
|
|
|
|
if not proposal:
|
|
|
|
return {"message": "No such proposal"}, 404
|
|
|
|
|
|
|
|
if is_accept:
|
|
|
|
proposal.arbiter.accept_nomination(g.current_user.id)
|
|
|
|
return {"message": "Accepted nomination"}, 200
|
|
|
|
else:
|
|
|
|
proposal.arbiter.reject_nomination(g.current_user.id)
|
|
|
|
return {"message": "Rejected nomination"}, 200
|
|
|
|
|
|
|
|
except ValidationException as e:
|
|
|
|
return {"message": str(e)}, 400
|