-
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 14 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,34 @@ | ||
<?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\', 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, DROP publicationState'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,12 @@ class ResourceController extends LikeableController | |
* @param boolean $auth Un override éventuel pour le check des permissions | ||
* @return Response | ||
*/ | ||
public function getAll($auth = false) | ||
public function getAll($auth = false, array $findBy = []) | ||
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. Pourquoi un $findBy sur le getAll des resources ? 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. 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 |
||
{ | ||
$this->trust(!$this->is('EXTERIEUR') || $auth); | ||
|
||
$paginateHelper = $this->get('ki_core.helper.paginate'); | ||
extract($paginateHelper->paginateData($this->repository)); | ||
extract($paginateHelper->paginateData($this->repository, $findBy)); | ||
|
||
list($results, $links, $count) = $paginateHelper->paginateView($results, $limit, $page, $totalPages, $count); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,6 @@ public function paginateData(EntityRepository $repository, array $findBy = []) | |
$queryBuilder = $repository->createQueryBuilder('o'); | ||
$request = $this->request->query; | ||
|
||
// On s'assure de bien recevoir des arrays | ||
foreach ($findBy as $key => $value) { | ||
$findBy[$key] = array($value); | ||
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. À garder avec un truc du genre |
||
} | ||
|
||
// On récupère les paramètres de la requête | ||
$page = $request->has('page') ? $request->get('page') : 1; | ||
$limit = $request->has('limit') ? $request->get('limit') : 100; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,9 +39,15 @@ public function setContainer(ContainerInterface $container = null) | |
* @Route("/events") | ||
* @Method("GET") | ||
*/ | ||
public function getEventsAction() | ||
public function getEventsAction(Request $request) | ||
{ | ||
return $this->getAll(); | ||
$events = $this->repository->getAllowedEvents( | ||
$this->getUser()->getId(), | ||
$request->query->get('publicationState'), | ||
$request->query->get('limit'), | ||
$request->query->get('page')); | ||
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. Problème d'indentation 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. Regarde bien, les lignes doublements indentées sont en argument de |
||
|
||
return $this->json($events); | ||
} | ||
|
||
/** | ||
|
@@ -63,6 +69,9 @@ public function getEventsAction() | |
public function getEventAction($slug) | ||
{ | ||
$event = $this->getOne($slug); | ||
if ($event->getPublicationState() == 'Draft' && !$this->isClubMember($event->getAuthorClub())) { | ||
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. Le Du coup, si c'est 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. Oui, je vais les mettre en slug. C'était comme ça à la base par cohérence avec l'entryMethod des Events 'Shotgun', 'Libre', 'Ferie' mais c'est plus très justifié maintenant Ce qui est published est sur le newsfeed et le calendrier, ce qui est scheduled n'est que sur le newsfeed des membre de l'asso qui peuvent l'éditer et sur le calendrier (mais accessible par recherche dans la topbar et par requête au back) |
||
return $this->json('Tu n\'es pas autorisé à lire ce brouillon !', 403); | ||
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.
|
||
} | ||
|
||
return $this->json($event); | ||
} | ||
|
@@ -159,6 +168,36 @@ public function deleteEventAction($slug) | |
return $this->json(null, 204); | ||
} | ||
|
||
/** | ||
* @ApiDoc( | ||
* description="Renvoie la liste des événements qui chevauchent un créneau horaire", | ||
* statusCodes={ | ||
* 200="Requête traitée avec succès", | ||
* 401="Une authentification est nécessaire pour effectuer cette action", | ||
* 503="Service temporairement indisponible ou en maintenance", | ||
* }, | ||
* section="Publications" | ||
* ) | ||
* @Route("/events/{slug}/check-dates") | ||
* @Method("GET") | ||
*/ | ||
public function getEventCheckDatesAction(Request $request, $slug) | ||
{ | ||
$startDate = $request->query->get('startDate'); | ||
$endDate = $request->query->get('endDate'); | ||
$events = $this->repository->findBy(array('publicationState' => array('Scheduled', 'Published', 'Emailed'))); | ||
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. la notation |
||
$matchedEvents = array(); | ||
foreach ($events as $event) { | ||
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. qui a dit que c'était une bonne idée de boucler sur l'intégralité des entrées de la base de données ? 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. Oui, il faut mettre cette logique dans une requête DQL dans le repository |
||
$eventStartDate = $event->getStartDate(); | ||
$eventEndDate = $event->getEndDate(); | ||
if ($startDate < $eventEndDate && $eventStartDate < $endDate && $slug != $event->getSlug()) { | ||
$matchedEvents[] = $event; | ||
} | ||
} | ||
return $this->json($matchedEvents); | ||
|
||
} | ||
|
||
/** | ||
* @ApiDoc( | ||
* description="Shotgunne un événement", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
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; | ||
|
||
class NewsitemsController extends ResourceController | ||
{ | ||
|
@@ -32,9 +34,21 @@ 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 = array('name' => 'message'); | ||
return $this->getAll($this->is('EXTERIEUR'), $findBy); | ||
} | ||
else { | ||
$newsitems = $this->repository->getAllowedNewsitems( | ||
$this->getUser()->getId(), | ||
$request->query->get('publicationState'), | ||
$request->query->get('limit'), | ||
$request->query->get('page')); | ||
|
||
return $this->json($newsitems); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -56,6 +70,9 @@ public function getNewsitemsAction() | |
public function getNewsitemAction($slug) | ||
{ | ||
$newsitem = $this->getOne($slug, $this->is('EXTERIEUR')); | ||
if ($newsitem->getPublicationState() == 'Draft' && !$this->isClubMember($newsitem->getAuthorClub())) { | ||
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. idem |
||
return $this->json('Tu n\'es pas autorisé à lire ce brouillon !', 403); | ||
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. idem |
||
} | ||
|
||
return $this->json($newsitem); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,10 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-ki')); | ||
$event->setAuthorUser($this->getReference('user-trancara')); | ||
$event->setEntryMethod('Libre'); | ||
$event->setPublicationState('Emailed'); | ||
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. slugify |
||
$event->setStartDate(mktime(0, 0, 0) + 36*3600); | ||
$event->setEndDate(mktime(0, 0, 0) + 37.5*3600); | ||
$event->setPlace('P102'); | ||
$event->setSendMail(true); | ||
$event->addAttendee($this->getReference('user-taquet-c')); | ||
$event->addAttendee($this->getReference('user-de-boisc')); | ||
$event->setLikes([$this->getReference('user-taquet-c')]); | ||
|
@@ -35,10 +35,10 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-ki')); | ||
$event->setAuthorUser($this->getReference('user-muzardt')); | ||
$event->setEntryMethod('Libre'); | ||
$event->setPublicationState('Scheduled'); | ||
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. slugify |
||
$event->setStartDate(mktime(0, 0, 0) + 36*3600); | ||
$event->setEndDate(mktime(0, 0, 0) + 36.5*3600); | ||
$event->setPlace('P402'); | ||
$event->setSendMail(true); | ||
$event->addAttendee($this->getReference('user-taquet-c')); | ||
$event->addAttendee($this->getReference('user-de-boisc')); | ||
$event->addAttendee($this->getReference('user-muzardt')); | ||
|
@@ -51,11 +51,11 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-mediatek')); | ||
$event->setAuthorUser($this->getReference('user-trancara')); | ||
$event->setEntryMethod('Shotgun'); | ||
$event->setPublicationState('Emailed'); | ||
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. slugify |
||
$event->setStartDate(1413918000); | ||
$event->setEndDate(1413930600); | ||
$event->setShotgunDate(1413396000); | ||
$event->setPlace('P102'); | ||
$event->setSendMail(false); | ||
$event->addAttendee($this->getReference('user-taquet-c')); | ||
$event->addAttendee($this->getReference('user-trancara')); | ||
$event->addAttendee($this->getReference('user-guerinh')); | ||
|
@@ -68,10 +68,10 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-pep')); | ||
$event->setAuthorUser($this->getReference('user-guerinh')); | ||
$event->setEntryMethod('Libre'); | ||
$event->setPublicationState('Draft'); | ||
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. slugify |
||
$event->setStartDate(1413999000); | ||
$event->setEndDate(1414009800); | ||
$event->setPlace('Amphi Navier'); | ||
$event->setSendMail(false); | ||
$event->addAttendee($this->getReference('user-taquet-c')); | ||
$event->addAttendee($this->getReference('user-guerinh')); | ||
$manager->persist($event); | ||
|
@@ -83,10 +83,10 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-bde')); | ||
$event->setAuthorUser($this->getReference('user-dziris')); | ||
$event->setEntryMethod('Libre'); | ||
$event->setPublicationState('Published'); | ||
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. slugify |
||
$event->setStartDate(mktime(0, 0, 0) + 9*3600); | ||
$event->setEndDate(mktime(0, 0, 0) + 15*3600); | ||
$event->setPlace('Salle Polyvalente'); | ||
$event->setSendMail(false); | ||
$event->addAttendee($this->getReference('user-taquet-c')); | ||
$event->addAttendee($this->getReference('user-trancara')); | ||
$event->addAttendee($this->getReference('user-guerinh')); | ||
|
@@ -102,11 +102,11 @@ public function load(ObjectManager $manager) | |
$event->setAuthorClub($this->getReference('club-bda')); | ||
$event->setAuthorUser($this->getReference('user-donat-bb')); | ||
$event->setEntryMethod('Shotgun'); | ||
$event->setPublicationState('Scheduled'); | ||
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. slugify |
||
$event->setStartDate(mktime(0, 0, 0) + 40*3600); | ||
$event->setEndDate(mktime(0, 0, 0) + 44*3600); | ||
$event->setShotgunDate(time() + 3600); | ||
$event->setPlace('Opéra Bastille'); | ||
$event->setSendMail(true); | ||
$event->setShotgunLimit(12); | ||
$event->setShotgunText('Viens chercher la place chez moi'); | ||
$manager->persist($event); | ||
|
@@ -115,11 +115,11 @@ public function load(ObjectManager $manager) | |
$event->setName('Vacances de Noël'); | ||
$event->setText('I\'m fucking Santa Claus bitchies!'); | ||
$event->setPlace('Ta mère'); | ||
$event->setSendMail(false); | ||
$event->setDate(1421778600); | ||
$event->setAuthorClub($this->getReference('club-ki')); | ||
$event->setAuthorUser($this->getReference('user-trancara')); | ||
$event->setEntryMethod('Ferie'); | ||
$event->setPublicationState('Draft'); | ||
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. slugify |
||
$event->setStartDate(time() - 400*3600); | ||
$event->setEndDate(time() + 600*3600); | ||
$manager->persist($event); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(1414242424); | ||
$newsitem->setAuthorClub($this->getReference('club-ki')); | ||
$newsitem->setAuthorUser($this->getReference('user-taquet-c')); | ||
$newsitem->setPublicationState('Published'); | ||
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. slugify |
||
$newsitem->setLikes([$this->getReference('user-taquet-c')]); | ||
$newsitem->setDislikes([$this->getReference('user-trancara')]); | ||
$manager->persist($newsitem); | ||
|
@@ -27,6 +28,7 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(1418325122); | ||
$newsitem->setAuthorClub($this->getReference('club-ki')); | ||
$newsitem->setAuthorUser($this->getReference('user-trancara')); | ||
$newsitem->setPublicationState('Draft'); | ||
$newsitem->setImage($this->getReference('image-newsitem-git')); | ||
$manager->persist($newsitem); | ||
|
||
|
@@ -36,6 +38,7 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(1417532897); | ||
$newsitem->setAuthorClub($this->getReference('club-ki')); | ||
$newsitem->setAuthorUser($this->getReference('user-trancara')); | ||
$newsitem->setPublicationState('Scheduled'); | ||
$manager->persist($newsitem); | ||
|
||
$newsitem = new Newsitem(); | ||
|
@@ -44,6 +47,7 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(1412831521); | ||
$newsitem->setAuthorClub($this->getReference('club-bde')); | ||
$newsitem->setAuthorUser($this->getReference('user-dziris')); | ||
$newsitem->setPublicationState('Emailed'); | ||
$newsitem->setDislikes([$this->getReference('user-trancara'), $this->getReference('user-dziris')]); | ||
$newsitem->addComment($this->getReference('comment-genial')); | ||
$newsitem->addComment($this->getReference('comment-rage')); | ||
|
@@ -56,6 +60,7 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(1414462150); | ||
$newsitem->setAuthorClub($this->getReference('club-pep')); | ||
$newsitem->setAuthorUser($this->getReference('user-guerinh')); | ||
$newsitem->setPublicationState('Draft'); | ||
$manager->persist($newsitem); | ||
|
||
$newsitem = new Newsitem(); | ||
|
@@ -65,6 +70,20 @@ public function load(ObjectManager $manager) | |
$newsitem->setAuthorClub($this->getReference('club-bde')); | ||
$newsitem->setAuthorUser($this->getReference('user-dziris')); | ||
$newsitem->setImage($this->getReference('image-newsitem-pulls')); | ||
$newsitem->setPublicationState('Published'); | ||
$manager->persist($newsitem); | ||
|
||
$newsitem = new Newsitem(); | ||
$newsitem->setName('Le béton c\'est bon.'); | ||
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. Utilise des guillemets double au lieu de tout échapper... |
||
$newsitem->setText('L\'acier aussi, c\'est complètement METAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL.'); | ||
$newsitem->setDate(time() - 21*3600); | ||
$newsitem->setAuthorUser($this->getReference('user-gcc')); | ||
$newsitem->setAuthorClub($this->getReference('club-gcc')); | ||
$newsitem->setLikes([$this->getReference('user-taquet-c')]); | ||
$newsitem->setDislikes([$this->getReference('user-trancara'), $this->getReference('user-dziris')]); | ||
$newsitem->setPublicationState('Emailed'); | ||
$newsitem->addComment($this->getReference('comment-rage')); | ||
$newsitem->addComment($this->getReference('comment-arret')); | ||
$manager->persist($newsitem); | ||
|
||
// Messages persos | ||
|
@@ -74,25 +93,15 @@ public function load(ObjectManager $manager) | |
$newsitem->setDate(time() - 3600); | ||
$newsitem->setAuthorUser($this->getReference('user-trancara')); | ||
$newsitem->setImage($this->getReference('image-game-age-of-empires-2')); | ||
$newsitem->setPublicationState('Published'); | ||
$manager->persist($newsitem); | ||
|
||
$newsitem = new Newsitem(); | ||
$newsitem->setName('message'); | ||
$newsitem->setText('[Le rêve de Jeanine]<br>Est ce que vous voyez la pluie tomber sur notre calme Champs sur Marne? Vous êtes vous seulement posés la question, ne serait-ce qu\'une fois, de ce que toute cette eau devenait? Cette nonchalance de votre part est permise seulement par la puissance de nouveaux radars qui mesurent précisément la minute et la rue où va se déverser le prochain orage sur les villes d\'Ile de France.'); | ||
$newsitem->setDate(time() - 42*3600); | ||
$newsitem->setAuthorUser($this->getReference('user-dziris')); | ||
$manager->persist($newsitem); | ||
|
||
$newsitem = new Newsitem(); | ||
$newsitem->setName('Le béton c\'est bon.'); | ||
$newsitem->setText('L\'acier aussi, c\'est complètement METAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL.'); | ||
$newsitem->setDate(time() - 21*3600); | ||
$newsitem->setAuthorUser($this->getReference('user-gcc')); | ||
$newsitem->setAuthorClub($this->getReference('club-gcc')); | ||
$newsitem->setLikes([$this->getReference('user-taquet-c')]); | ||
$newsitem->setDislikes([$this->getReference('user-trancara'), $this->getReference('user-dziris')]); | ||
$newsitem->addComment($this->getReference('comment-rage')); | ||
$newsitem->addComment($this->getReference('comment-arret')); | ||
$newsitem->setPublicationState('Published'); | ||
$manager->persist($newsitem); | ||
|
||
$manager->flush(); | ||
|
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.
Est-ce qu'on a pas envie d'attribuer le bon
publishedState
suivant la valeur actuelle desend_mail
lors de la migration ?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.
Oui oui, faut faire des boucles php ici avec des addSql partout ? o:)