Require answers' authors to be unique in Ponder

Summary: Ref T3578. I forget if this was an explicit decision or not, but we currently let the same user answer questions multiple times. I think this probably causes more confusion than it provides freedom. In conjunction with other UI issues (commenting being weird, notably), we're seeing some use of answers to comment, which is undesirable. Require each answer's author to be unique. Merge existing nonunique authors' answers.

Test Plan: {F52062}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3578

Differential Revision: https://secure.phabricator.com/D6605
This commit is contained in:
epriestley
2013-07-28 16:30:30 -07:00
parent 61e7043664
commit 6172f2bbd1
4 changed files with 89 additions and 9 deletions

View File

@@ -27,11 +27,18 @@ final class PonderQuestionViewController extends PonderController {
$question_xactions = $this->buildQuestionTransactions($question);
$answers = $this->buildAnswers($question->getAnswers());
$answer_add_panel = new PonderAddAnswerView();
$answer_add_panel
->setQuestion($question)
->setUser($user)
->setActionURI("/ponder/answer/add/");
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$user->getPHID()])) {
// TODO: Make this pretty
$answer_add_panel = pht(
'You have already answered this question.');
} else {
$answer_add_panel = new PonderAddAnswerView();
$answer_add_panel
->setQuestion($question)
->setUser($user)
->setActionURI("/ponder/answer/add/");
}
$header = id(new PhabricatorHeaderView())
->setHeader($question->getTitle());
@@ -268,10 +275,15 @@ final class PonderQuestionViewController extends PonderController {
$view->invokeWillRenderEvent();
$view->addTextContent(
PhabricatorMarkupEngine::renderOneObject(
$answer,
$answer->getMarkupField(),
$viewer));
phutil_tag(
'div',
array(
'class' => 'phabricator-remarkup',
),
PhabricatorMarkupEngine::renderOneObject(
$answer,
$answer->getMarkupField(),
$viewer)));
return $view;
}

View File

@@ -1487,6 +1487,14 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql',
'name' => $this->getPatchPath('20130726.ponderxactions.sql'),
),
'20130728.ponderunique.php' => array(
'type' => 'php',
'name' => $this->getPatchPath('20130728.ponderunique.php'),
),
'20130728.ponderuniquekey.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20130728.ponderuniquekey.sql'),
),
);
}
}