Ver Fonte

Education Timing

Vincent GUFFON há 3 anos atrás
pai
commit
24518daede

+ 1 - 66
config/opentalent/products.yaml

@@ -12,11 +12,6 @@ opentalent:
           - Country
           - Tagg
           - Enum
-        actions:
-          - Export_list
-          - Export_card
-          - Export_report-activity
-          - Export_licence-cmf
         roles:
           - ROLE_IMPORT
           - ROLE_TAGG
@@ -58,10 +53,6 @@ opentalent:
           - PersonActivity
           - PersonHoliday
           - OrganizationResponsability
-        actions:
-          - CreateAccounts
-          - DeleteAccounts
-          - SharingContact
         roles:
           - ROLE_USERS
           - ROLE_ACCOUNTS
@@ -77,8 +68,6 @@ opentalent:
           - EducationStudent
           - Course
           - Education
-        actions:
-          - CreateOwnPresenceAttendance
 
       Medals:
         entities:
@@ -97,8 +86,6 @@ opentalent:
           - Message
           - Email
           - ReportMessage
-        actions:
-          - Rulerz
         roles:
           - ROLE_EMAILS
 
@@ -112,8 +99,6 @@ opentalent:
         entities:
           - Sms
           - MobytUserStatus
-        actions:
-          - Rulerz
         roles:
           - ROLE_TEXTO
 
@@ -140,10 +125,6 @@ opentalent:
             - Categories
             - EventReport
             - AttendanceBooking
-          actions:
-            - Rulerz
-            - EventInvitation
-            - Export_presence-event
           roles:
             - ROLE_EVENTS
 
@@ -153,9 +134,6 @@ opentalent:
             - Work
             - WorkByUser
             - EducationStudent
-          actions:
-            - Export_presence-course
-            - DuplicateCourses
           roles:
             - ROLE_COURSES
 
@@ -163,9 +141,6 @@ opentalent:
           entities:
             - Examen
             - Jury
-          actions:
-            - ExamenConvocation
-            - Export_presence-examen
           roles:
             - ROLE_EXAMENS
 
@@ -173,8 +148,6 @@ opentalent:
           entities:
             - EducationalProject
             - EducationalProjectPublic
-          actions:
-            - Export_road-map
           roles:
             - ROLE_EDUCATIONALPROJECTS
 
@@ -193,9 +166,6 @@ opentalent:
             - EquipmentRepair
             - EquipmentList
             - EquipmentComposition
-          actions:
-            - EquipmentLoanReminder
-            - Export_equipment-availability-form
           roles:
             - ROLE_EQUIPMENTS
 
@@ -210,9 +180,7 @@ opentalent:
             - ExamenConvocation
             - Education
             - Cycle
-          actions:
-            - CycleUpdating
-            - Export_report-card
+            - EducationTiming
           roles:
             - ROLE_PEDAGOGICS_ADMINISTRATION
 
@@ -221,8 +189,6 @@ opentalent:
             - EducationStudent
           roles:
             - ROLE_PEDAGOGICS_SEIZURE
-          actions:
-            - EvaluateStudents
 
       AdvancedEducationNotation:
         entities:
@@ -242,20 +208,6 @@ opentalent:
             - BillLine
             - AccessPayer
             - AccessIntangible
-          actions:
-            - BillingEdition
-            - CreditEdition
-            - Rulerz
-            - Export_unpaid-bill
-            - Export_unpaid-bill-email
-            - Export_billing
-            - Export_all-bill
-            - Export_paid-bill
-            - Export_paid-bill-email
-            - Export_bill-billlines
-            - Export_bill-payment-receipt
-            - Export_bill-payment-detail
-            - Export_all-bill-email
           roles :
             - ROLE_BILLINGS_ADMINISTRATION
             - ROLE_BILLINGS_SEIZURE
@@ -263,9 +215,6 @@ opentalent:
       Pes:
           entities:
             - Pes
-          actions:
-            - Export_pes
-            - Export_sepa-debit-mandate
 
       IEL:
           entities:
@@ -274,26 +223,16 @@ opentalent:
             - AccessTmp
             - EducationStudentWish
             - OnlineRegistrationSettings
-          actions:
-            - SendOnlineRegistration
-            - ValidationRegistration
-            - IelProvisionalRegistration
           roles:
             - ROLE_ONLINEREGISTRATION_ADMINISTRATION
 
       BergerLevrault:
           entities:
             - BergerLevrault
-          actions:
-            - Export_berger-levrault
-            - Export_sepa-debit-mandate
 
       Jvs:
           entities:
             - Jvs
-          actions:
-            - Export_jvs
-            - Export_sepa-debit-mandate
 
       Website:
           entities: ~
@@ -314,10 +253,6 @@ opentalent:
             - Network
           roles:
             - ROLE_NETWORK
-          actions:
-            - GenerateCredentials
-            - ChangeEmailAdmin
-            - TakeOutOrganization
 
       Cotisation:
         entities:

+ 47 - 0
src/Doctrine/Education/CurrentEducationTimingExtension.php

@@ -0,0 +1,47 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Doctrine\Education;
+
+use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
+use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
+use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
+use App\Entity\Access\Access;
+use App\Entity\Education\EducationTiming;
+use Doctrine\ORM\QueryBuilder;
+use Symfony\Component\Security\Core\Security;
+
+/**
+ * Class CurrentEducationTimingExtension : Filtre de sécurité par défaut pour une resource CurrentEducationTiming
+ * @package App\Doctrine\Core
+ */
+final class CurrentEducationTimingExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
+{
+    public function __construct(private Security $security)
+    { }
+
+    public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null): void
+    {
+        $this->addWhere($queryBuilder, $resourceClass, $operationName);
+    }
+
+    public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, string $operationName = null, array $context = []): void
+    {
+        $this->addWhere($queryBuilder, $resourceClass, $operationName);
+    }
+
+    private function addWhere(QueryBuilder $queryBuilder, string $resourceClass, string $operationName): void
+    {
+        if (EducationTiming::class !== $resourceClass) {
+            return;
+        }
+
+        /** @var Access $currentUser */
+        $currentUser = $this->security->getUser();
+        $rootAlias = $queryBuilder->getRootAliases()[0];
+        $queryBuilder
+            ->andWhere(sprintf('%s.organization = :organization', $rootAlias))
+            ->setParameter('organization', $currentUser->getOrganization())
+        ;
+    }
+}

+ 70 - 0
src/Entity/Education/EducationTiming.php

@@ -0,0 +1,70 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Entity\Education;
+
+use ApiPlatform\Core\Annotation\ApiResource;
+use App\Annotation\OrganizationDefaultValue;
+use App\Entity\Organization\Organization;
+use App\Repository\Education\EducationTimingRepository;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Temps d'un enseignement
+ */
+#[ApiResource(
+    collectionOperations: [
+        "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW')"],
+        "post"
+    ],
+    itemOperations: [
+        "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW') and object.getOrganization().getId() == user.getOrganization().getId()"],
+        "put" => ["security" => "object.getOrganization().getId() == user.getOrganization().getId()"],
+        "delete" => ["security" => "object.getOrganization().getId() == user.getOrganization().getId()"],
+    ],
+    attributes: ["security" => "is_granted('ROLE_ORGANIZATION')"]
+)]
+#[OrganizationDefaultValue(fieldName: "organization")]
+#[ORM\Entity(repositoryClass: EducationTimingRepository::class)]
+class EducationTiming
+{
+    #[ORM\Id]
+    #[ORM\Column]
+    #[ORM\GeneratedValue]
+    private ?int $id = null;
+
+    #[ORM\ManyToOne(inversedBy: 'educationTimings')]
+    #[ORM\JoinColumn(nullable: false)]
+    private Organization $organization;
+
+    #[ORM\Column]
+    private int $timing;
+
+    public function getId(): ?int
+    {
+        return $this->id;
+    }
+
+    public function setOrganization(Organization $organization): self
+    {
+        $this->organization = $organization;
+        return $this;
+    }
+
+    public function getOrganization(): Organization
+    {
+        return $this->organization;
+    }
+
+    public function setTiming(int $timing): self
+    {
+        $this->timing = $timing;
+
+        return $this;
+    }
+
+    public function getTiming(): int
+    {
+        return $this->timing;
+    }
+}

+ 32 - 0
src/Entity/Organization/Organization.php

@@ -12,6 +12,7 @@ use App\Entity\Core\ContactPoint;
 use App\Entity\Core\File;
 use App\Entity\Education\Cycle;
 use App\Entity\Education\EducationNotationConfig;
+use App\Entity\Education\EducationTiming;
 use App\Entity\Network\NetworkOrganization;
 use App\Repository\Organization\OrganizationRepository;
 use Doctrine\Common\Collections\ArrayCollection;
@@ -220,6 +221,9 @@ class Organization
     #[ORM\OneToMany(mappedBy: 'organization', targetEntity: Cycle::class, orphanRemoval: true)]
     private Collection $cycles;
 
+    #[ORM\OneToMany(mappedBy: 'organization', targetEntity: EducationTiming::class, orphanRemoval: true)]
+    private Collection $educationTimings;
+
     #[Pure] public function __construct()
     {
         $this->accesses = new ArrayCollection();
@@ -232,6 +236,7 @@ class Organization
         $this->organizationLicences = new ArrayCollection();
         $this->organizationArticles = new ArrayCollection();
         $this->cycles = new ArrayCollection();
+        $this->educationTimings = new ArrayCollection();
         $this->educationNotationConfigs = new ArrayCollection();
     }
 
@@ -1029,4 +1034,31 @@ class Organization
     {
         return $this->educationNotationConfigs;
     }
+
+    public function addEducationTiming(EducationTiming $educationTiming): self
+    {
+        if (!$this->educationTimings->contains($educationTiming)) {
+            $this->educationTimings[] = $educationTiming;
+            $educationTiming->setOrganization($this);
+        }
+
+        return $this;
+    }
+
+    public function removeEducationTiming(EducationTiming $educationTiming): self
+    {
+        if ($this->educationTimings->removeElement($educationTiming)) {
+            // set the owning side to null (unless already changed)
+            if ($educationTiming->getOrganization() === $this) {
+                $educationTiming->setOrganization(null);
+            }
+        }
+
+        return $this;
+    }
+
+    public function getEducationTimings(): Collection
+    {
+        return $this->educationTimings;
+    }
 }

+ 16 - 0
src/Repository/Education/EducationTimingRepository.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Repository\Education;
+
+use App\Entity\Education\EducationTiming;
+use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
+use Doctrine\Persistence\ManagerRegistry;
+
+class EducationTimingRepository extends ServiceEntityRepository
+{
+    public function __construct(ManagerRegistry $registry)
+    {
+        parent::__construct($registry, EducationTiming ::class);
+    }
+}