Commit f856d4fb authored by xiphon's avatar xiphon

reject proposal if any mandatoriy field is missing or empty in .md

parent dbac712e
...@@ -62,6 +62,14 @@ class ProcessProposals extends Command ...@@ -62,6 +62,14 @@ class ProcessProposals extends Command
private const layoutToState = [ 'fr' => 'FUNDING-REQUIRED', private const layoutToState = [ 'fr' => 'FUNDING-REQUIRED',
'wip' => 'WORK-IN-PROGRESS', 'wip' => 'WORK-IN-PROGRESS',
'cp' => 'COMPLETED']; 'cp' => 'COMPLETED'];
private const mandatoryFields = [ 'amount',
'author',
'date',
'layout',
'milestones',
'title'];
/** /**
* Execute the console command. * Execute the console command.
*/ */
...@@ -81,6 +89,12 @@ class ProcessProposals extends Command ...@@ -81,6 +89,12 @@ class ProcessProposals extends Command
$detail['name'] = $filename; $detail['name'] = $filename;
$detail['values'] = $this->getAmountFromText($file); $detail['values'] = $this->getAmountFromText($file);
foreach ($this::mandatoryFields as $field) {
if (empty($detail['values'][$field])) {
throw new \Exception("Mandatory field $field is missing");
}
}
$amount = floatval(str_replace(",", ".", $detail['values']['amount'])); $amount = floatval(str_replace(",", ".", $detail['values']['amount']));
$author = htmlspecialchars($detail['values']['author'], ENT_QUOTES); $author = htmlspecialchars($detail['values']['author'], ENT_QUOTES);
$date = strtotime($detail['values']['date']); $date = strtotime($detail['values']['date']);
...@@ -133,7 +147,7 @@ class ProcessProposals extends Command ...@@ -133,7 +147,7 @@ class ProcessProposals extends Command
{ {
$contents = preg_split('/\r?\n?---\r?\n/m', Storage::get($filename)); $contents = preg_split('/\r?\n?---\r?\n/m', Storage::get($filename));
if (sizeof($contents) < 3) { if (sizeof($contents) < 3) {
throw new \Exception("Failed to parse proposal, can't find YAML description surrounded by '---' lines"); throw new \Exception("Failed to parse proposal, can't find YAML description surrounded by '---' lines");
} }
return Yaml::parse($contents[1]); return Yaml::parse($contents[1]);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment