Misc Fixes (#381)
* Fix Logging typo * only allow consecutive milestone date estimates * fix typo * handle empty target * validate max proposal brief size
This commit is contained in:
parent
c41d74c0fa
commit
495b50a9e9
|
@ -384,7 +384,7 @@ class Proposal(db.Model):
|
|||
self.brief = brief
|
||||
self.category = category
|
||||
self.content = content
|
||||
self.target = target
|
||||
self.target = target if target != '' else None
|
||||
self.payout_address = payout_address
|
||||
self.deadline_duration = deadline_duration
|
||||
Proposal.simple_validate(vars(self))
|
||||
|
@ -590,6 +590,7 @@ class Proposal(db.Model):
|
|||
|
||||
@hybrid_property
|
||||
def funded(self):
|
||||
|
||||
target = Decimal(self.target)
|
||||
# apply matching multiplier
|
||||
funded = Decimal(self.contributed) * Decimal(1 + self.contribution_matching)
|
||||
|
|
|
@ -78,6 +78,11 @@ export default class CreateFlowMilestones extends React.Component<Props, State>
|
|||
milestone={milestone}
|
||||
index={idx}
|
||||
error={errors.milestones && errors.milestones[idx]}
|
||||
previousMilestoneDateEstimate={
|
||||
milestones[idx - 1] && milestones[idx - 1].dateEstimated
|
||||
? moment(milestones[idx - 1].dateEstimated * 1000)
|
||||
: undefined
|
||||
}
|
||||
onChange={this.handleMilestoneChange}
|
||||
onRemove={this.removeMilestone}
|
||||
/>
|
||||
|
@ -96,6 +101,7 @@ export default class CreateFlowMilestones extends React.Component<Props, State>
|
|||
interface MilestoneFieldsProps {
|
||||
index: number;
|
||||
milestone: CreateMilestone;
|
||||
previousMilestoneDateEstimate: moment.Moment | undefined;
|
||||
error: Falsy | string;
|
||||
onChange(index: number, milestone: CreateMilestone): void;
|
||||
onRemove(index: number): void;
|
||||
|
@ -107,6 +113,7 @@ const MilestoneFields = ({
|
|||
error,
|
||||
onChange,
|
||||
onRemove,
|
||||
previousMilestoneDateEstimate,
|
||||
}: MilestoneFieldsProps) => (
|
||||
<Card style={{ marginBottom: '2rem' }}>
|
||||
<div style={{ display: 'flex', marginBottom: '0.5rem', alignItems: 'center' }}>
|
||||
|
@ -154,14 +161,23 @@ const MilestoneFields = ({
|
|||
allowClear={false}
|
||||
onChange={time => onChange(index, { ...milestone, dateEstimated: time.unix() })}
|
||||
disabled={milestone.immediatePayout}
|
||||
disabledDate={current =>
|
||||
current
|
||||
? current <
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
: false
|
||||
}
|
||||
disabledDate={current => {
|
||||
if (!previousMilestoneDateEstimate) {
|
||||
return current
|
||||
? current <
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
: false;
|
||||
} else {
|
||||
return current
|
||||
? current <
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month') || current < previousMilestoneDateEstimate
|
||||
: false;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Input
|
||||
value={milestone.payoutPercent}
|
||||
|
|
|
@ -57,7 +57,7 @@ export function getCreateErrors(
|
|||
skipRequired?: boolean,
|
||||
): CreateFormErrors {
|
||||
const errors: CreateFormErrors = {};
|
||||
const { title, team, milestones, target, payoutAddress, rfp, rfpOptIn } = form;
|
||||
const { title, team, milestones, target, payoutAddress, rfp, rfpOptIn, brief } = form;
|
||||
|
||||
// Required fields with no extra validation
|
||||
if (!skipRequired) {
|
||||
|
@ -85,6 +85,11 @@ export function getCreateErrors(
|
|||
errors.title = 'Title can only be 60 characters maximum';
|
||||
}
|
||||
|
||||
// Brief
|
||||
if (brief && brief.length > 140) {
|
||||
errors.brief = 'Brief can only be 140 characters maximum';
|
||||
}
|
||||
|
||||
// Amount to raise
|
||||
const targetFloat = target ? parseFloat(target) : 0;
|
||||
if (target && !Number.isNaN(targetFloat)) {
|
||||
|
@ -169,7 +174,7 @@ export function getCreateWarnings(form: Partial<ProposalDraft>): string[] {
|
|||
warnings.push(`
|
||||
You still have pending team invitations. If you publish before they
|
||||
are accepted, your team will be locked in and they won’t be able to
|
||||
accept join.
|
||||
join.
|
||||
`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue