Skip to content
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

Open
wants to merge 19 commits into
base: master-dev
Choose a base branch
from

Conversation

PhilippeFerreiraDeSousa
Copy link
Member

Draft : Seul les membres du club ont accès aux brouillons dans la liste des publications du club.
Scheduled : Cette publication apparaîtra seulement sur le calendrier uPont.
Published : Cette publication sera publique sur uPont, vous pourrez envoyer un mail plus tard.
Emailed: La publication sera publiée et envoyée par mail à tous les utilisateurs de uPont qui suivent le club.

Copy link
Contributor

@LouisTrezzini LouisTrezzini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je n'ai pas eu le courage de tout relire en détail ni de tester en local

// 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');
Copy link
Contributor

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 de send_mail lors de la migration ?

Copy link
Member Author

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:)

@@ -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 = [])
Copy link
Contributor

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 ?

Copy link
Member Author

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

if ($request->query->get('name') == 'message') {
      $findBy = array('name' => 'message');
      return $this->getAll($this->is('EXTERIEUR'), $findBy);
}

En soi donner "message" comme titre de news aux messages de l'accueil est très douteux

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

À garder avec un truc du genre $aRecords = is_array($aRecords) ? $aRecords : array($aRecords);

@@ -63,6 +69,9 @@ public function getEventsAction()
public function getEventAction($slug)
{
$event = $this->getOne($slug);
if ($event->getPublicationState() == 'Draft' && !$this->isClubMember($event->getAuthorClub())) {
return $this->json('Tu n\'es pas autorisé à lire ce brouillon !', 403);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw $this->createAccessDeniedException('You cannot access this page!');

$this->getUser()->getId(),
$request->query->get('publicationState'),
$request->query->get('limit'),
$request->query->get('page'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problème d'indentation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarde bien, les lignes doublements indentées sont en argument de getAllowedEvents

ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse"
ng-if="publication.entry_method != 'Ferie'">
ng-if="publication.entry_method != 'Ferie' && ($root.hasClub(publication.author_club.slug) || ['Published', 'Emailed'].includes(publication.publication_state))">
<up-ribbon ng-repeat="(state, item) in pub_info" class="Ribbon--{{ pub_info[publication.publication_state].color }}" ng-hide="editSlug == publication.slug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi tu boucles alors que tu sais que publication.publication_state == state ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a 4 ribbons différents, un membre voit les publications de son club pour les 4 états.
On est dans list.html à l'intérieur d'un ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse" donc publication.publication_state change dans ce feed de publications

ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse"
ng-if="publication.entry_method != 'Ferie'">
ng-if="publication.entry_method != 'Ferie' && ($root.hasClub(publication.author_club.slug) || ['Published', 'Emailed'].includes(publication.publication_state))">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi tu ne renvoies pas que les bonnes publications aux bons users ? pourquoi il y a de la logique dans le front ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On veut juste pas afficher dans le feed les événements planifiés des autres assos mais y laisser accès, vu qu'on utlise la même route ownClub pour le calendrier et qu'on peut l'utiliser pour autre chose plus tard.
On peut simplifier en $root.hasClub(publication.author_club.slug) || publication.publication_state != 'scheduled'

</div>
<div up-likes show="false" objet="publication"
url="(publication.start_date ? 'events/' : 'newsitems/') + publication.slug"></div>
url="(publication.start_date ? 'events/' : 'newsitems/') + publication.slug"
ng-if="!['Draft', 'Scheduled'].includes(publication.publication_state)"></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

berk

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ?

<select class="Input" ng-model="post.entry_method">
<option value="Libre" selected ng-disabled="modify && initialEntryMethod == 'Shotgun'">Entrée libre</option>
<option value="Shotgun">Shotgun</option>
<option value="Ferie" ng-if="$root.isAdmin" ng-disabled="modify && initialEntryMethod == 'Shotgun'">Ferie</option>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ng-if="$root.isAdmin"

...
je pense que tu peux supprimer tout référence à "Ferie" du coup

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pour faire apparaître les vacances scolaires et jours fériés sur le calendrier. Ca aurait plus de sens d'être sur le panneau d'administration mais pour l'instant ça fait de mal à personne ici. On pourra statuer là-dessus plus tard je pense

@@ -82,9 +95,10 @@
<div class="InputButton" ng-if="!modify" ng-class="{'active': postFiles.length}">
<i class="fa fa-file-o"></i>
<span ng-repeat="file in postFiles"> {{ file.name ? file.name : 'Fichier' }} </span>
<button class="InputButton__fileinput" ngf-select="selectFiles($files)" multiple></button>
<button class="InputButton__fileinput" ng-select="selectFiles($files)" multiple></button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ngf-select pour les fichiers...

Copy link
Member Author

@PhilippeFerreiraDeSousa PhilippeFerreiraDeSousa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vais revoir tout ça

// 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');
Copy link
Member Author

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:)

@@ -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 = [])
Copy link
Member Author

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

if ($request->query->get('name') == 'message') {
      $findBy = array('name' => 'message');
      return $this->getAll($this->is('EXTERIEUR'), $findBy);
}

En soi donner "message" comme titre de news aux messages de l'accueil est très douteux

$this->getUser()->getId(),
$request->query->get('publicationState'),
$request->query->get('limit'),
$request->query->get('page'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarde bien, les lignes doublements indentées sont en argument de getAllowedEvents

@@ -63,6 +69,9 @@ public function getEventsAction()
public function getEventAction($slug)
{
$event = $this->getOne($slug);
if ($event->getPublicationState() == 'Draft' && !$this->isClubMember($event->getAuthorClub())) {
Copy link
Member Author

Choose a reason for hiding this comment

The 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)

$endDate = $request->query->get('endDate');
$events = $this->repository->findBy(array('publicationState' => array('Scheduled', 'Published', 'Emailed')));
$matchedEvents = array();
foreach ($events as $event) {
Copy link
Member Author

Choose a reason for hiding this comment

The 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

@@ -54,7 +54,7 @@ angular.module('upont')
},
resolve: {
events: ['$resource', function($resource) {
return $resource(apiPrefix + 'own/events').query().$promise;
return $resource(apiPrefix + 'own/events?publicationState=Scheduled,Published,Emailed').query().$promise;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les brouillons sont privés, pas sur le calendrier

ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse"
ng-if="publication.entry_method != 'Ferie'">
ng-if="publication.entry_method != 'Ferie' && ($root.hasClub(publication.author_club.slug) || ['Published', 'Emailed'].includes(publication.publication_state))">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On veut juste pas afficher dans le feed les événements planifiés des autres assos mais y laisser accès, vu qu'on utlise la même route ownClub pour le calendrier et qu'on peut l'utiliser pour autre chose plus tard.
On peut simplifier en $root.hasClub(publication.author_club.slug) || publication.publication_state != 'scheduled'

ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse"
ng-if="publication.entry_method != 'Ferie'">
ng-if="publication.entry_method != 'Ferie' && ($root.hasClub(publication.author_club.slug) || ['Published', 'Emailed'].includes(publication.publication_state))">
<up-ribbon ng-repeat="(state, item) in pub_info" class="Ribbon--{{ pub_info[publication.publication_state].color }}" ng-hide="editSlug == publication.slug"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a 4 ribbons différents, un membre voit les publications de son club pour les 4 états.
On est dans list.html à l'intérieur d'un ng-repeat="publication in events.data | concat: newsItems.data | orderBy: 'date' | reverse" donc publication.publication_state change dans ce feed de publications

</div>
<div up-likes show="false" objet="publication"
url="(publication.start_date ? 'events/' : 'newsitems/') + publication.slug"></div>
url="(publication.start_date ? 'events/' : 'newsitems/') + publication.slug"
ng-if="!['Draft', 'Scheduled'].includes(publication.publication_state)"></div>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ?

<select class="Input" ng-model="post.entry_method">
<option value="Libre" selected ng-disabled="modify && initialEntryMethod == 'Shotgun'">Entrée libre</option>
<option value="Shotgun">Shotgun</option>
<option value="Ferie" ng-if="$root.isAdmin" ng-disabled="modify && initialEntryMethod == 'Shotgun'">Ferie</option>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pour faire apparaître les vacances scolaires et jours fériés sur le calendrier. Ca aurait plus de sens d'être sur le panneau d'administration mais pour l'instant ça fait de mal à personne ici. On pourra statuer là-dessus plus tard je pense

@PhilippeFerreiraDeSousa
Copy link
Member Author

Editer la publucation pour changer l'état dans la dropdown c'était la solution rapide. Je vais réfléchir au système incrémental qui est plus élaboré mais faut que je trouve du temps

… a row and request to checkDates after changing slug

To do : test data migration, correct get to own pubilcations, unpredictable redactor. The calendar library should be changed in the future. Some fonts are missing for some months, event should inherit from newsitem and why the fuck are personnel messages newsitems with title 'message'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants