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/page projets #18

Merged
merged 26 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
596d984
feat(project-list): Add project list + map
plduthoit Oct 7, 2024
391fb48
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 7, 2024
e5fd244
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 8, 2024
80f69b4
feat: Add filter modal
plduthoit Oct 8, 2024
c3f4927
fix(ci): rm unused image
plduthoit Oct 8, 2024
461959a
fix: ts errors
plduthoit Oct 8, 2024
cb1ac28
fix: ts errors on template refs
plduthoit Oct 8, 2024
75586f3
feat(project-list): Add back images to cards
plduthoit Oct 9, 2024
8cfb78b
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 9, 2024
fef42f8
fix(projects): Adjust stores naming + translations +
plduthoit Oct 11, 2024
ef2ebb1
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
96620dd
fix ts
plduthoit Oct 11, 2024
e88ea4a
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
4c0ca5d
rm unusedor duplicates command
plduthoit Oct 11, 2024
a31f437
set env as one liner
plduthoit Oct 11, 2024
484dc9a
fix fixturees not loading in prod
plduthoit Oct 11, 2024
d045a11
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
26c54e8
new migration
plduthoit Oct 11, 2024
b9556a2
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
69aa149
add cache clear to deployement
plduthoit Oct 11, 2024
51225e9
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
9346d67
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
a487d3a
Merge branch 'main' of github.com:CartONG/plateforme-urbaine-cameroun…
plduthoit Oct 11, 2024
8a882cf
move card component
plduthoit Oct 11, 2024
81cdcd7
feat(project): Fix things after merge with Actor page and make projec…
plduthoit Oct 14, 2024
e9c79c9
fix: Adjust components pathtree
plduthoit Oct 14, 2024
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
9 changes: 5 additions & 4 deletions symfony/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ sf: ## List all Symfony commands or pass the parameter "c=" to run a given comma
cc: c=c:c ## Clear the cache
cc: sf

reset-database-schema:
@$(SYMFONY) do:s:u -f

recreate-database: restart-db-container drop-database create-database
recreate-database: restart-db-container drop-database create-database configure-database

drop-database:
@$(SYMFONY) do:da:dr -f --if-exists
Expand All @@ -54,9 +51,13 @@ make-entity:
regenerate-entity:
@$(SYMFONY) make:entity --regenerate

enable-postgis:
@$(SYMFONY) dbal:run-sql 'CREATE extension postgis;'

make-run-migration: make-migration run-migration
reset-database: recreate-database run-migration
rerun-database: reset-database run-fixtures
configure-database: enable-postgis
create-short-migration: recreate-database run-migration make-migration rerun-migration

init-jwt-keypair:
Expand Down
1 change: 1 addition & 0 deletions symfony/config/packages/hautelook_alice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ when@dev: &dev
fixtures_path: fixtures

when@test: *dev
when@prod: *dev
1 change: 1 addition & 0 deletions symfony/config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ security:
- { path: ^/auth, roles: PUBLIC_ACCESS }
- { path: ^/api/users, roles: PUBLIC_ACCESS, methods: [POST]}
- { path: ^/api/actors, roles: PUBLIC_ACCESS, methods: [GET] }
- { path: ^/api/projects, roles: PUBLIC_ACCESS, methods: [GET] }
- { path: ^/api/actor_expertises, roles: PUBLIC_ACCESS, methods: [GET] }
- { path: ^/api/thematics, roles: PUBLIC_ACCESS, methods: [GET] }
- { path: ^/api/administrative_scopes, roles: PUBLIC_ACCESS, methods: [GET] }
Expand Down
4 changes: 2 additions & 2 deletions symfony/fixtures/actors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ App\Entity\Actor:
email: <email()>
logo: <imageUrl(200, 200)>
projects: '<numberBetween(1, 8)>x @project_*'
created_at: '<dateTimeBetween("-200 days", "now")>'
updated_at: '<dateTimeBetween($created_at, "now")>'
createdAt: '<dateTimeBetween("-200 days", "now")>'
updatedAt: '<dateTimeBetween($createdAt, "now")>'
7 changes: 7 additions & 0 deletions symfony/fixtures/actorsExpertise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
App\Entity\ActorExpertise:
actorexpertise_1:
name: Planification urbaine
actorexpertise_2:
name: Elaboration et mise en œuvre de la politique algorithmique de la nation ainsi que de l’aménagement du territoire
actorexpertise_3:
name: Production de l’Information Géospatiale
9 changes: 9 additions & 0 deletions symfony/fixtures/administrativeScopes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
App\Entity\AdministrativeScope:
administrative_scope_1:
name: National
administrative_scope_2:
name: Régional
administrative_scope_3:
name: Départemental
administrative_scope_4:
name: Communal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

je l'ai récupéré de ta branche mais dans l'idée plutot le gérer en enum.

11 changes: 6 additions & 5 deletions symfony/fixtures/projects.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
App\Entity\Project:
project_{1..100}:
title: <city()> Urban Development
project_{1..500}:
name: <city()> Urban Development
location: <city()>
coords: 'POINT(<longitude()> <latitude()>)'
status: '<randomElement(<(App\Enum\Status::toArray())>)>' # Remplace par les valeurs de ton Enum Status
# coords: 'POINT(<longitude()> <latitude()>)'
coords: 'POINT(<randomFloat(11, 12.8593962671, 1.72767263428)> <randomFloat(11, 16.0128524106, 8.48881554529)>)'
status: '<randomElement(<(App\Enum\Status::toArray())>)>'
description: <paragraph(2)>
images: []
partners: []
interventionZone: '<randomElement(<(App\Enum\AdministrativeScopes::toArray())>)>' # Remplace par les valeurs de ton Enum AdministrativeScopes
interventionZone: '<randomElement(<(App\Enum\AdministrativeScope::toArray())>)>'
financialActors: '<numberBetween(1, 5)>x @actor_*'
actor: '@actor_*'
contractingActors: '<numberBetween(1, 5)>x @actor_*'
Expand Down
28 changes: 0 additions & 28 deletions symfony/migrations/Version20241001093511.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241008150316 extends AbstractMigration
final class Version20241011202727 extends AbstractMigration
{
public function getDescription(): string
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public function up(Schema $schema): void
$this->addSql('COMMENT ON COLUMN actor_administrative_scope.actor_id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE actor_expertise (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE administrative_scope (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE project (id INT NOT NULL, actor_id UUID NOT NULL, title VARCHAR(255) NOT NULL, location VARCHAR(255) NOT NULL, coords geometry(POINT, 0) NOT NULL, status VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, images JSON DEFAULT NULL, partners JSON DEFAULT NULL, intervention_zone VARCHAR(255) NOT NULL, project_manager_name VARCHAR(255) DEFAULT NULL, project_manager_position VARCHAR(255) DEFAULT NULL, project_manager_email VARCHAR(255) DEFAULT NULL, project_manager_tel VARCHAR(255) DEFAULT NULL, project_manager_photo VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE project (id INT NOT NULL, actor_id UUID NOT NULL, name VARCHAR(255) NOT NULL, location VARCHAR(255) NOT NULL, coords geometry(POINT, 0) NOT NULL, status VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, images JSON DEFAULT NULL, partners JSON DEFAULT NULL, intervention_zone VARCHAR(255) NOT NULL, project_manager_name VARCHAR(255) DEFAULT NULL, project_manager_position VARCHAR(255) DEFAULT NULL, project_manager_email VARCHAR(255) DEFAULT NULL, project_manager_tel VARCHAR(255) DEFAULT NULL, project_manager_photo VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_2FB3D0EE10DAF24A ON project (actor_id)');
$this->addSql('COMMENT ON COLUMN project.actor_id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE project_thematic (project_id INT NOT NULL, thematic_id INT NOT NULL, PRIMARY KEY(project_id, thematic_id))');
Expand All @@ -57,7 +57,7 @@ public function up(Schema $schema): void
$this->addSql('CREATE INDEX IDX_E73AB79010DAF24A ON contracted_projects_actors (actor_id)');
$this->addSql('COMMENT ON COLUMN contracted_projects_actors.actor_id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE thematic (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, is_validated BOOLEAN NOT NULL, requested_roles JSON DEFAULT NULL, organisation VARCHAR(255) DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, phone VARCHAR(20) DEFAULT NULL, sign_up_message TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) DEFAULT NULL, is_validated BOOLEAN NOT NULL, requested_roles JSON DEFAULT NULL, organisation VARCHAR(255) DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, phone VARCHAR(20) DEFAULT NULL, sign_up_message TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE actor ADD CONSTRAINT FK_447556F9B03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE actor_actor_expertise ADD CONSTRAINT FK_4A438EAD10DAF24A FOREIGN KEY (actor_id) REFERENCES actor (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE actor_actor_expertise ADD CONSTRAINT FK_4A438EAD916905AC FOREIGN KEY (actor_expertise_id) REFERENCES actor_expertise (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
Expand Down
5 changes: 2 additions & 3 deletions symfony/src/Entity/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use ApiPlatform\Metadata\GetCollection;
use App\Entity\Trait\TimestampableEntity;
use Doctrine\Common\Collections\Collection;
use Symfony\Bundle\SecurityBundle\Security;
use App\Services\State\Provider\ActorProvider;
use App\Services\State\Processor\ActorProcessor;
use Doctrine\Common\Collections\ArrayCollection;
Expand Down Expand Up @@ -74,11 +73,11 @@ class Actor
private ?Uuid $id = null;

#[ORM\Column(length: 255)]
#[Groups([self::ACTOR_READ_ITEM_COLLECTION, self::ACTOR_READ_ITEM, self::ACTOR_WRITE])]
#[Groups([self::ACTOR_READ_ITEM_COLLECTION, self::ACTOR_READ_ITEM, self::ACTOR_WRITE, Project::PROJECT_READ_ALL])]
private ?string $name = null;

#[ORM\Column(length: 255)]
#[Groups([self::ACTOR_READ_ITEM_COLLECTION, self::ACTOR_READ_ITEM, self::ACTOR_WRITE])]
#[Groups([self::ACTOR_READ_ITEM_COLLECTION, self::ACTOR_READ_ITEM, self::ACTOR_WRITE, Project::PROJECT_READ_ALL])]
private ?string $acronym = null;

#[ORM\ManyToOne(inversedBy: 'actorsCreated')]
Expand Down
56 changes: 41 additions & 15 deletions symfony/src/Entity/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace App\Entity;

use ApiPlatform\Metadata\GetCollection;
use App\Enum\AdministrativeScope;
use App\Enum\Status;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Enum\AdministrativeScopes;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProjectRepository;
use App\Entity\Trait\TimestampableEntity;
Expand All @@ -15,30 +16,44 @@
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: ProjectRepository::class)]
#[ApiResource]
#[ApiResource(
paginationEnabled: false,
operations: [
new GetCollection(
normalizationContext: ['groups' => [self::PROJECT_READ_ALL]]
)
]
)]
class Project
{
use TimestampableEntity;

public const PROJECT_READ = 'project:read';
public const PROJECT_READ_ALL = 'project:read:all';

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups([self::PROJECT_READ_ALL])]
private ?int $id = null;

#[ORM\Column(length: 255)]
#[Groups([Actor::ACTOR_READ_ITEM])]
private ?string $title = null;
#[Groups([self::PROJECT_READ_ALL, Actor::ACTOR_READ_ITEM])]
private ?string $name = null;

#[ORM\Column(length: 255)]
#[Groups([self::PROJECT_READ_ALL])]
private ?string $location = null;

#[ORM\Column(
type: PostGISType::GEOMETRY,
options: ['geometry_type' => 'POINT'],
)]
#[Groups([self::PROJECT_READ_ALL])]
private ?string $coords = null;

#[ORM\Column(enumType: Status::class)]
#[Groups([self::PROJECT_READ_ALL])]
private ?Status $status = null;

#[ORM\Column(type: Types::TEXT, nullable: true)]
Expand All @@ -50,13 +65,15 @@ class Project
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $partners = null;

#[ORM\Column(enumType: AdministrativeScopes::class)]
private ?AdministrativeScopes $interventionZone = null;
#[ORM\Column(enumType: AdministrativeScope::class)]
#[Groups([self::PROJECT_READ_ALL])]
private ?AdministrativeScope $interventionZone = null;

/**
* @var Collection<int, Thematic>
*/
#[ORM\ManyToMany(targetEntity: Thematic::class, inversedBy: 'projects')]
#[Groups([self::PROJECT_READ_ALL])]
private Collection $thematics;

#[ORM\Column(length: 255, nullable: true)]
Expand All @@ -78,13 +95,15 @@ class Project
private ?string $website = null;

#[ORM\Column(length: 255, nullable: true)]
#[Groups([self::PROJECT_READ_ALL])]
private ?string $logo = null;

/**
* @var Collection<int, Actor>
*/
#[ORM\JoinTable(name: 'financed_projects_actors')]
#[ORM\ManyToMany(targetEntity: Actor::class)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Il va falloir qu'on voit avec Maelle, mais je ne suis pas sur qu'il s'agira d'acteurs au sens de la plateforme ici, probablement qu'il s'agira d'une chaine de caractères. A vérifier

#[Groups([self::PROJECT_READ_ALL])]
private Collection $financialActors;

/**
Expand All @@ -93,10 +112,12 @@ class Project

#[ORM\JoinTable(name: 'contracted_projects_actors')]
#[ORM\ManyToMany(targetEntity: Actor::class)]
#[Groups([self::PROJECT_READ_ALL])]
Copy link
Contributor

Choose a reason for hiding this comment

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

Même chose ici

private Collection $contractingActors;

#[ORM\ManyToOne(inversedBy: 'projects')]
#[ORM\JoinColumn(nullable: false)]
#[Groups([self::PROJECT_READ_ALL])]
private ?Actor $actor = null;

public function __construct()
Expand All @@ -111,14 +132,14 @@ public function getId(): ?int
return $this->id;
}

public function getTitle(): ?string
public function getName(): ?string
{
return $this->title;
return $this->name;
}

public function setTitle(string $title): static
public function setName(string $name): static
{
$this->title = $title;
$this->name = $name;

return $this;
}
Expand All @@ -135,9 +156,14 @@ public function setLocation(string $location): static
return $this;
}

public function getCoords(): ?string
{
return $this->coords;
public function getCoords(): ?array {
if (preg_match('/POINT\(([-\d\.]+) ([-\d\.]+)\)/', $this->coords, $matches)) {
return [
'lat' => (float)$matches[1],
'long' => (float)$matches[2],
];
}
return null;
}

public function setCoords(string $coords): static
Expand Down Expand Up @@ -195,12 +221,12 @@ public function setPartners(?array $partners): static
return $this;
}

public function getInterventionZone(): ?AdministrativeScopes
public function getInterventionZone(): ?AdministrativeScope
{
return $this->interventionZone;
}

public function setInterventionZone(AdministrativeScopes $interventionZone): static
public function setInterventionZone(AdministrativeScope $interventionZone): static
{
$this->interventionZone = $interventionZone;

Expand Down
6 changes: 5 additions & 1 deletion symfony/src/Entity/Thematic.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#[ORM\Entity(repositoryClass: ThematicRepository::class)]
#[UniqueEntity('name')]
#[ApiResource(
paginationEnabled: false,
operations: [
new GetCollection(),
new Post(
Expand All @@ -28,13 +29,16 @@
)]
class Thematic
{
public const THEMATIC_READ = 'thematic:read';

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups([self::THEMATIC_READ, Project::PROJECT_READ_ALL])]
private ?int $id = null;

#[ORM\Column(length: 255)]
#[Groups([Actor::ACTOR_READ_ITEM])]
#[Groups([self::THEMATIC_READ, Actor::ACTOR_READ_ITEM, Project::PROJECT_READ_ALL])]
private ?string $name = null;

/**
Expand Down
3 changes: 3 additions & 0 deletions symfony/src/Entity/Trait/TimestampableEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Entity\Trait;

use App\Entity\Project;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Attribute\Groups;

trait TimestampableEntity
{
Expand All @@ -14,6 +16,7 @@ trait TimestampableEntity

#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Groups([Project::PROJECT_READ_ALL])]
protected ?\DateTimeInterface $updatedAt;

public function getCreatedAt(): ?\DateTimeInterface
Expand Down
14 changes: 14 additions & 0 deletions symfony/src/Enum/AdministrativeScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace App\Enum;

use App\Enum\Trait\ToArray;

enum AdministrativeScope: string
{
case NATIONAL = 'national';
case REGIONAL = 'regional';
case STATE = 'state';
case CITY = 'city';

use ToArray;
}
Loading
Loading