-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/publication state #274
base: master-dev
Are you sure you want to change the base?
Changes from all commits
26d79b6
57dcede
8be81e6
adf716a
dbcd096
4d40da7
d3187ad
ab5969a
0e72392
e81e438
ca0a65a
4a70526
e0928be
469d085
cc330f1
daad1bc
c1627b8
a82e2fc
a2ce603
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Application\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20171015200834 extends AbstractMigration | ||
{ | ||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE Post ADD publicationState VARCHAR(255) DEFAULT \'published\' NOT NULL'); | ||
$this->addSql(' | ||
UPDATE Post | ||
SET Post.publicationState = \'emailed\' | ||
WHERE Post.send_mail | ||
'); | ||
$this->addSql('ALTER TABLE Post DROP send_mail'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE Post ADD send_mail TINYINT(1) DEFAULT NULL'); | ||
$this->addSql(' | ||
UPDATE Post | ||
SET Post.send_mail = true | ||
WHERE Post.publicationState = \'emailed\' | ||
'); | ||
$this->addSql(' | ||
UPDATE Post | ||
SET Post.send_mail = false | ||
WHERE Post.publicationState != \'emailed\' | ||
'); | ||
$this->addSql('ALTER TABLE Post DROP publicationState'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
class NewsitemsController extends ResourceController | ||
{ | ||
|
@@ -32,9 +35,16 @@ public function setContainer(ContainerInterface $container = null) | |
* @Route("/newsitems") | ||
* @Method("GET") | ||
*/ | ||
public function getNewsitemsAction() | ||
public function getNewsitemsAction(Request $request) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Est-ce que tous les newsitems ne seraient pas des événements ? Pourquoi s'emmerder à dupliquer le code partout ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ca aurait été trop logique, Newsitem et Event héritent tous deux de Post |
||
{ | ||
return $this->getAll($this->is('EXTERIEUR')); | ||
if ($request->query->get('name') == 'message') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Est-ce que les messages sont vraiment utiles sur uPont ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non effectivement, on aurait pu en faire quelque chose mais ils n'ont même pas d'existence réel dans la bdd. Mais bon ils ne font de mal à personne où ils sont |
||
$findBy = ['name' => 'message']; | ||
return $this->getAll($this->is('EXTERIEUR'), $findBy); | ||
} | ||
else { | ||
$dql = $this->repository->getAllowedNewsitemsDql($this->getUser()->getId(), $request->query->all()); | ||
return $this->getPaginatedResponse($dql); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -56,6 +66,9 @@ public function getNewsitemsAction() | |
public function getNewsitemAction($slug) | ||
{ | ||
$newsitem = $this->getOne($slug, $this->is('EXTERIEUR')); | ||
if ($newsitem->getPublicationState() == 'draft' && !$this->isClubMember($newsitem->getAuthorClub())) { | ||
throw $this->createAccessDeniedException('You cannot access this draft!'); | ||
} | ||
|
||
return $this->json($newsitem); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi un $findBy sur le getAll des resources ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je l'utilise pour requêter les messages à /newsitems?name=message
En soi donner "message" comme titre de news aux messages de l'accueil est très douteux