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

General convention #11412

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ security:
- ROLE_APP_ADMIN_PROCURATION_V2_REQUEST_ALL
- ROLE_APP_ADMIN_PROCURATION_V2_PROXY_ALL
- ROLE_APP_ADMIN_PROCURATION_V2_PROCURATION_REQUEST_ALL
ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS:
- ROLE_APP_ADMIN_GENERAL_CONVENTION_ALL

## Application Mobile
ROLE_ADMIN_APPLICATION_MOBILE_NOTIFICATIONS:
Expand Down
8 changes: 8 additions & 0 deletions config/services/admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@
</service>
<service id="App\Admin\ReportAdmin" alias="app.admin.report" />

<service id="app.admin.general_convention" class="App\Admin\GeneralConventionAdmin">
<tag name="sonata.admin" manager-type="orm" label="États généraux" group="Territoires" />

<argument />
<argument>App\Entity\GeneralConvention\GeneralConvention</argument>
<argument />
</service>

<!--
######################################################
# Mobilisation
Expand Down
94 changes: 94 additions & 0 deletions migrations/2025/Version20250131104505.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20250131104505 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE general_convention (
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
department_zone_id INT UNSIGNED DEFAULT NULL,
committee_zone_id INT UNSIGNED DEFAULT NULL,
district_zone_id INT UNSIGNED DEFAULT NULL,
reporter_id INT UNSIGNED DEFAULT NULL,
created_by_administrator_id INT DEFAULT NULL,
updated_by_administrator_id INT DEFAULT NULL,
organizer VARCHAR(255) NOT NULL,
reported_at DATETIME NOT NULL,
meeting_type VARCHAR(255) NOT NULL,
members_count SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
participant_quality VARCHAR(255) NOT NULL,
general_summary LONGTEXT DEFAULT NULL,
party_definition_summary LONGTEXT DEFAULT NULL,
unique_party_summary LONGTEXT DEFAULT NULL,
progress_since2016 LONGTEXT DEFAULT NULL,
party_objectives LONGTEXT DEFAULT NULL,
governance LONGTEXT DEFAULT NULL,
communication LONGTEXT DEFAULT NULL,
militant_training LONGTEXT DEFAULT NULL,
member_journey LONGTEXT DEFAULT NULL,
mobilization LONGTEXT DEFAULT NULL,
talent_detection LONGTEXT DEFAULT NULL,
election_preparation LONGTEXT DEFAULT NULL,
relationship_with_supporters LONGTEXT DEFAULT NULL,
work_with_partners LONGTEXT DEFAULT NULL,
additional_comments LONGTEXT DEFAULT NULL,
uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\',
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
UNIQUE INDEX UNIQ_F66947EFD17F50A6 (uuid),
INDEX IDX_F66947EF2285D748 (department_zone_id),
INDEX IDX_F66947EF94819E3B (committee_zone_id),
INDEX IDX_F66947EF23F5C396 (district_zone_id),
INDEX IDX_F66947EFE1CFE6F5 (reporter_id),
INDEX IDX_F66947EF9DF5350C (created_by_administrator_id),
INDEX IDX_F66947EFCF1918FF (updated_by_administrator_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EF2285D748 FOREIGN KEY (department_zone_id) REFERENCES geo_zone (id)');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EF94819E3B FOREIGN KEY (committee_zone_id) REFERENCES geo_zone (id)');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EF23F5C396 FOREIGN KEY (district_zone_id) REFERENCES geo_zone (id)');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EFE1CFE6F5 FOREIGN KEY (reporter_id) REFERENCES adherents (id) ON DELETE
SET
NULL');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EF9DF5350C FOREIGN KEY (created_by_administrator_id) REFERENCES administrators (id) ON DELETE
SET
NULL');
$this->addSql('ALTER TABLE
general_convention
ADD
CONSTRAINT FK_F66947EFCF1918FF FOREIGN KEY (updated_by_administrator_id) REFERENCES administrators (id) ON DELETE
SET
NULL');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EF2285D748');
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EF94819E3B');
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EF23F5C396');
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EFE1CFE6F5');
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EF9DF5350C');
$this->addSql('ALTER TABLE general_convention DROP FOREIGN KEY FK_F66947EFCF1918FF');
$this->addSql('DROP TABLE general_convention');
}
}
248 changes: 248 additions & 0 deletions src/Admin/GeneralConventionAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?php

namespace App\Admin;

use App\Entity\Adherent;
use App\Entity\Geo\Zone;
use App\Form\Admin\SimpleMDEContent;
use App\GeneralConvention\MeetingTypeEnum;
use App\GeneralConvention\OrganizerEnum;
use App\GeneralConvention\ParticipantQuality;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;

class GeneralConventionAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $form): void
{
$form
->add('departmentZone', ModelAutocompleteType::class, [
'multiple' => false,
'label' => 'Département',
'required' => true,
'property' => ['name', 'code'],
'callback' => function (AdminInterface $admin, array $property, $value): void {
$datagrid = $admin->getDatagrid();
$query = $datagrid->getQuery();
$rootAlias = $query->getRootAlias();
$query
->andWhere($rootAlias.'.type = :type_department')
->setParameter('type_department', Zone::DEPARTMENT)
;

$datagrid->setValue($property[0], null, $value);
},
'btn_add' => false,
])
->add('committeeZone', ModelAutocompleteType::class, [
'multiple' => false,
'label' => 'Comité (zone)',
'required' => false,
'property' => ['name', 'code'],
'callback' => function (AdminInterface $admin, array $property, $value): void {
$datagrid = $admin->getDatagrid();
$query = $datagrid->getQuery();
$rootAlias = $query->getRootAlias();
$query
->andWhere($rootAlias.'.type = :type_city')
->setParameter('type_city', Zone::CITY)
Remg marked this conversation as resolved.
Show resolved Hide resolved
;

$datagrid->setValue($property[0], null, $value);
},
'btn_add' => false,
])
->add('districtZone', ModelAutocompleteType::class, [
'multiple' => false,
'label' => 'Circonscription',
'required' => false,
'property' => ['name', 'code'],
'callback' => function (AdminInterface $admin, array $property, $value): void {
$datagrid = $admin->getDatagrid();
$query = $datagrid->getQuery();
$rootAlias = $query->getRootAlias();
$query
->andWhere($rootAlias.'.type = :type_district')
->setParameter('type_district', Zone::DISTRICT)
;

$datagrid->setValue($property[0], null, $value);
},
'btn_add' => false,
])
->add('organizer', EnumType::class, [
'label' => 'Instance organisatrice',
'class' => OrganizerEnum::class,
'choice_label' => function (OrganizerEnum $organizer) {
return 'general_convention.organizer.'.$organizer->value;
},
])
->add('reporter', ModelAutocompleteType::class, [
'label' => 'Auteur de la remontée',
'required' => true,
'minimum_input_length' => 1,
'items_per_page' => 20,
'property' => [
'search',
],
'to_string_callback' => static function (Adherent $adherent): string {
return \sprintf(
'%s (%s) [%s]',
$adherent->getFullName(),
$adherent->getEmailAddress(),
$adherent->getId()
);
},
'btn_add' => false,
])
->add('reportedAt', null, [
'label' => 'Date de la remontée',
Remg marked this conversation as resolved.
Show resolved Hide resolved
])
->add('meetingType', EnumType::class, [
'label' => 'Instance organisatrice',
Remg marked this conversation as resolved.
Show resolved Hide resolved
'class' => MeetingTypeEnum::class,
'choice_label' => function (MeetingTypeEnum $meetingType) {
return 'general_convention.meeting_type.'.$meetingType->value;
},
])
->add('membersCount', null, [
'label' => 'Nombre de participants',
])
->add('participantQuality', EnumType::class, [
'label' => 'Qualité des participants',
'class' => ParticipantQuality::class,
'choice_label' => function (ParticipantQuality $participantQuality) {
return 'general_convention.participant_quality.'.$participantQuality->value;
},
])
->add('generalSummary', SimpleMDEContent::class, [
'label' => 'Synthèse générale',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('partyDefinitionSummary', SimpleMDEContent::class, [
'label' => 'Synthèse des réponses concernant l\'échange sur ce qu\'est un parti politique pour les participants',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('uniquePartySummary', SimpleMDEContent::class, [
'label' => 'Synthèse des échanges sur "Renaissance, un parti pas comme les autres"',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('progressSince2016', SimpleMDEContent::class, [
'label' => 'Synthèse des échanges sur le chemin parcouru depuis 2016',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('partyObjectives', SimpleMDEContent::class, [
'label' => 'Synthèse des échanges sur les objectifs de Renaissance',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('governance', SimpleMDEContent::class, [
'label' => 'Notre gouvernance',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('communication', SimpleMDEContent::class, [
'label' => 'Notre communication',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('militantTraining', SimpleMDEContent::class, [
'label' => 'La formation militante',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('memberJourney', SimpleMDEContent::class, [
'label' => 'Le parcours adhérent',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('mobilization', SimpleMDEContent::class, [
'label' => 'La mobilisation',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('talentDetection', SimpleMDEContent::class, [
'label' => 'Détecter les talents',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('electionPreparation', SimpleMDEContent::class, [
'label' => 'Préparer les élections',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('relationshipWithSupporters', SimpleMDEContent::class, [
'label' => 'Notre relation aux sympathisants, aux corps intermédiaires, à la société civile',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('workWithPartners', SimpleMDEContent::class, [
'label' => 'Notre travail avec les partenaires',
'required' => false,
'attr' => ['rows' => 10],
'help_html' => true,
])
->add('additionalComments', SimpleMDEContent::class, [
'label' => 'Souhaitez-vous ajouter quelque chose ?',
'required' => false,
'attr' => ['rows' => 10],
'help' => 'help.markdown',
'help_html' => true,
])
;
}

protected function configureListFields(ListMapper $list): void
{
$list
->add('departmentZone', null, [
'label' => 'Département',
])
->add('organizer', null, [
'label' => 'Instance organisatrice',
'template' => 'admin/general_convention/list_organizer.html.twig',
])
->add('district_or_committee', null, [
'label' => 'Circonscription ou Comité organisateur',
'virtual_field' => true,
'template' => 'admin/general_convention/list_district_or_committee.html.twig',
])
->add('reportedAt', null, [
'label' => 'Date',
])
->add('membersCount', null, [
'label' => 'Participants',
])
->add('reporter', null, [
'label' => 'Auteur',
])
->add(ListMapper::NAME_ACTIONS, null, [
'virtual_field' => true,
'actions' => [
'edit' => [],
],
])
;
}
}
1 change: 1 addition & 0 deletions src/DataFixtures/ORM/LoadAdminData.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function load(ObjectManager $manager): void
'ROLE_ADMIN_TERRITOIRES_JME_GENERAL_MEETING_REPORTS',
'ROLE_ADMIN_TERRITOIRES_JME_EMAIL_TEMPLATES',
'ROLE_ADMIN_TERRITOIRES_ELUS_NOTIFICATION',
'ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS',
'ROLE_ADMIN_PETITION',
]);

Expand Down
5 changes: 5 additions & 0 deletions src/DataFixtures/ORM/LoadAdministratorRoleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ private function getRoles(): \Generator
'Administrateur des mandants & mandataires',
AdministratorRoleGroupEnum::ELECTIONS
);
yield $this->createRole(
'ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS',
'Administrateur des états généraux',
AdministratorRoleGroupEnum::TERRITOIRES
);
// Application Mobile
yield $this->createRole(
'ROLE_ADMIN_APPLICATION_MOBILE_NOTIFICATIONS',
Expand Down
Loading