Skip to content

Commit

Permalink
Merge pull request #25 from itk-dev/feature/318-readonly-feed-data
Browse files Browse the repository at this point in the history
318 - Read-only feed data
  • Loading branch information
cableman authored Nov 30, 2023
2 parents 4c96b8d + 6cc27e1 commit 6925de0
Show file tree
Hide file tree
Showing 31 changed files with 272 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ See [keep a changelog] for information about writing changes to this log.
- Added daily occurrence factory
- Added indexing service and helper commands to populate and create indexes
- Added Easy admin and event fixtures
- Make data imported from feeds read-only in easy admin

[keep a changelog]: https://keepachangelog.com/en/1.1.0/
[unreleased]: https://github.com/itk-dev/event-database-imports/compare/main...develop
10 changes: 10 additions & 0 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
</file>
<file src="src/DataFixtures/EventFixture.php">
<ArgumentTypeCoercion>
<code><![CDATA[$this->getReference(ImagesFixtures::AAK)]]></code>
<code><![CDATA[$this->getReference(ImagesFixtures::ITK)]]></code>
<code><![CDATA[$this->getReference(LocationFixture::ITKDEV)]]></code>
<code><![CDATA[$this->getReference(LocationFixture::ITKDEV)]]></code>
<code><![CDATA[$this->getReference(OrganizationFixtures::ITK)]]></code>
<code><![CDATA[$this->getReference(OrganizationFixtures::ITK)]]></code>
<code><![CDATA[$this->getReference(TagsFixtures::AROS)]]></code>
<code><![CDATA[$this->getReference(TagsFixtures::AROS)]]></code>
<code><![CDATA[$this->getReference(TagsFixtures::CONCERT)]]></code>
<code><![CDATA[$this->getReference(TagsFixtures::ITKDEV)]]></code>
<code><![CDATA[$this->getReference(TagsFixtures::RACE)]]></code>
</ArgumentTypeCoercion>
</file>
Expand All @@ -30,6 +33,12 @@
<code><![CDATA[$this->getReference(UserFixtures::USER)]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/DataFixtures/ImagesFixtures.php">
<PossiblyNullArgument>
<code><![CDATA[$image->getSource()]]></code>
<code><![CDATA[$image->getSource()]]></code>
</PossiblyNullArgument>
</file>
<file src="src/DataFixtures/LocationFixture.php">
<ArgumentTypeCoercion>
<code><![CDATA[$this->getReference(AddressFixture::ITKDEV)]]></code>
Expand All @@ -54,6 +63,7 @@
<code><![CDATA[$this->getReference(VocabularyFixtures::MANAGED)]]></code>
<code><![CDATA[$this->getReference(VocabularyFixtures::MANAGED)]]></code>
<code><![CDATA[$this->getReference(VocabularyFixtures::MANAGED)]]></code>
<code><![CDATA[$this->getReference(VocabularyFixtures::MANAGED)]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/Service/Feeds/Mapper/Source/FeedItemSource.php">
Expand Down
17 changes: 0 additions & 17 deletions docs/adr/006-user handling and login

This file was deleted.

27 changes: 27 additions & 0 deletions docs/adr/006-user-handling-and-login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# User handling and login

Date: 28-09-2023

## Status

Accepted

## Context

The idea is that each organization/institution has an appointed admin that is allowed to send users invitation out for
his/her organization. Each user can be part of more than one organization, it just requires that they get an invitation
and thereby link their account to a given organization.

## Decision

For this first phase of the project, users login by using username and password. If there needs to be a higher level of
security surrounding user login in the future, an identity Provider such as MitId can be connected to the project, but
for now the customer has specifically requested (due to experiences with login in the existing solution) that we
continue using username and password.

Using Single Sign On (SSO) would be a more professional login method for the future, but for now it's not a part of the
project.

## Consequences

Login using username and password is not as secure as using SSO.
24 changes: 24 additions & 0 deletions docs/adr/007-editability-of-content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Editability of content

Date: 27-11-2023

## Status

Accepted

## Context

The forms UI (administrative user interface) allows users to add new content and change existing data.

## Decision

All data imported through feeds are marked as read-only as changes made in the administrative UI are overwritten by
changes in the feed.

All other data is editable and will trigger a reindex of the data changes and all related data.

## Consequences

Imported data from feeds are not editable, and some changes to data not from feeds will trigger a reindex of data,
which may trigger a lager job to be processed based on which data is changed. E.g. if an address is changed, that will
trigger an update of all content in indexes that contains that address. Which may be a large number of events.
41 changes: 41 additions & 0 deletions migrations/Version20231127121531.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231127121531 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE address ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE event ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE image ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE location ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE occurrence ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE tag ADD editable TINYINT(1) NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE occurrence DROP editable');
$this->addSql('ALTER TABLE location DROP editable');
$this->addSql('ALTER TABLE event DROP editable');
$this->addSql('ALTER TABLE tag DROP editable');
$this->addSql('ALTER TABLE address DROP editable');
$this->addSql('ALTER TABLE image DROP editable');
}
}
28 changes: 28 additions & 0 deletions src/Controller/Admin/AbstractBaseCrudController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Controller\Admin;

use App\Entity\EditableEntityInterface;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;

abstract class AbstractBaseCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return self::class;
}

public function configureActions(Actions $actions): Actions
{
return parent::configureActions($actions)
->update(Crud::PAGE_INDEX, Action::EDIT, static function (Action $action) {
return $action->displayIf(static function (object $entity) {
return !($entity instanceof EditableEntityInterface) || $entity->isEditable();
});
})
->add(Crud::PAGE_INDEX, Action::DETAIL);
}
}
3 changes: 1 addition & 2 deletions src/Controller/Admin/AddressCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
use App\Entity\Address;
use Doctrine\Common\Collections\Criteria;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Symfony\Component\Translation\TranslatableMessage;

class AddressCrudController extends AbstractCrudController
class AddressCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/EventCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Entity\Event;
use Doctrine\Common\Collections\Criteria;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
Expand All @@ -15,7 +14,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
use Symfony\Component\Translation\TranslatableMessage;

class EventCrudController extends AbstractCrudController
class EventCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/FeedCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace App\Controller\Admin;

use App\Entity\Feed;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\CodeEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Symfony\Component\Translation\TranslatableMessage;

class FeedCrudController extends AbstractCrudController
class FeedCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/ImageCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace App\Controller\Admin;

use App\Entity\Image;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
use Symfony\Component\Translation\TranslatableMessage;

class ImageCrudController extends AbstractCrudController
class ImageCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/LocationCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Entity\Location;
use Doctrine\Common\Collections\Criteria;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
Expand All @@ -17,7 +16,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
use Symfony\Component\Translation\TranslatableMessage;

class LocationCrudController extends AbstractCrudController
class LocationCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/OccurrenceCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
use App\Entity\Occurrence;
use Doctrine\Common\Collections\Criteria;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Symfony\Component\Translation\TranslatableMessage;

class OccurrenceCrudController extends AbstractCrudController
class OccurrenceCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/OrganizationCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Controller\Admin;

use App\Entity\Organization;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
Expand All @@ -12,7 +11,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
use Symfony\Component\Translation\TranslatableMessage;

class OrganizationCrudController extends AbstractCrudController
class OrganizationCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/TagCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace App\Controller\Admin;

use App\Entity\Tag;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Symfony\Component\Translation\TranslatableMessage;

class TagCrudController extends AbstractCrudController
class TagCrudController extends AbstractBaseCrudController
{
public static function getEntityFqcn(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Admin/UserCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
Expand All @@ -21,7 +20,7 @@
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Translation\TranslatableMessage;

class UserCrudController extends AbstractCrudController
class UserCrudController extends AbstractBaseCrudController
{
public function __construct(
private readonly UserPasswordHasherInterface $userPasswordHasher,
Expand Down
3 changes: 2 additions & 1 deletion src/DataFixtures/AddressFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function load(ObjectManager $manager): void
->setCountry('Danmark')
->setCity('Aarhus')
->setLatitude(56.1507645)
->setLongitude(10.2112699);
->setLongitude(10.2112699)
->setEditable(true);
$manager->persist($address);
$this->addReference(self::ITKDEV, $address);

Expand Down
8 changes: 7 additions & 1 deletion src/DataFixtures/EventFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public function load(ObjectManager $manager): void
->setLocation($this->getReference(LocationFixture::ITKDEV))
->addTag($this->getReference(TagsFixtures::AROS))
->addTag($this->getReference(TagsFixtures::RACE))
->setHash('4936efebda146f6775fb7e429d884fef');
->addTag($this->getReference(TagsFixtures::ITKDEV))
->setImage($this->getReference(ImagesFixtures::ITK))
->setEditable(true)
->setHash('4936efebda146f6775fb7e429d884fef');
$manager->persist($event);
$this->addReference(self::EVENT2, $event);

Expand All @@ -45,6 +48,8 @@ public function load(ObjectManager $manager): void
->setLocation($this->getReference(LocationFixture::ITKDEV))
->addTag($this->getReference(TagsFixtures::CONCERT))
->addTag($this->getReference(TagsFixtures::AROS))
->setEditable(true)
->setImage($this->getReference(ImagesFixtures::AAK))
->setHash('16d48c26d38f6d59b3d081e596b4d0e8');
$manager->persist($event);
$this->addReference(self::EVENT1, $event);
Expand All @@ -60,6 +65,7 @@ public function getDependencies(): array
OrganizationFixtures::class,
LocationFixture::class,
TagsFixtures::class,
ImagesFixtures::class,
];
}
}
Loading

0 comments on commit 6925de0

Please sign in to comment.