Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0b135c7
5104: Updated fixtures
rimi-itk Aug 12, 2025
76a50aa
5104: Made event organizer required
rimi-itk Aug 12, 2025
92edb10
5104: Cleaned up config
rimi-itk Aug 12, 2025
3691842
Merge branch 'develop' into feature/5110-require-event-organizer
turegjorup Feb 17, 2026
5ca8e9f
5110: Fix copy paste error
turegjorup Feb 17, 2026
79169c8
5110: Add user filters and console command to find users without orga…
turegjorup Feb 20, 2026
905ce5f
5110: Pre-fill organization when user has only one
turegjorup Feb 20, 2026
64ba604
5110: Add filter for events without organization
turegjorup Feb 20, 2026
02e4454
5110: Add command to fix events without organizer
turegjorup Feb 20, 2026
26e991a
5110: Replace form error summary with scroll-to-first-error
turegjorup Feb 23, 2026
652bbf8
5110: Fix twig-cs-fixer errors in EasyAdmin crud templates
turegjorup Feb 23, 2026
566c0fd
Update src/Command/Event/FixEventsWithoutOrganizerCommand.php
turegjorup Feb 25, 2026
f1db3c6
Update public/scripts/form-scroll-to-error.js
turegjorup Feb 25, 2026
83791dd
Update src/Command/User/ListUsersWithoutOrganizationCommand.php
turegjorup Feb 25, 2026
3d04f20
5110: Remove redundant twig templates
turegjorup Feb 25, 2026
75afa7a
5110: Use entity property names
turegjorup Feb 25, 2026
28470d5
5110: Set 'organization' field disabled for users with only one organ…
turegjorup Mar 2, 2026
08b724c
5110: Change firewall rule for dev toolbar assets to apply for both s…
turegjorup Mar 4, 2026
bcfcd2c
5110: Add validation requiring organization for org-role users and tr…
turegjorup Mar 4, 2026
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log.

## [Unreleased]

- Updated fixtures. Made event organizer required.

## [1.2.2] - 2025-10-07

- [PR-73](https://github.com/itk-dev/event-database-imports/pull/73) Set deploy user for rabbitmq container
Expand Down Expand Up @@ -119,7 +121,9 @@ See [keep a changelog] for information about writing changes to this log.
- Consolidate scheduled feed import and index populate in one command

[keep a changelog]: https://keepachangelog.com/en/1.1.0/
[Unreleased]: https://github.com/itk-dev/event-database-imports/compare/1.2.0...HEAD
[Unreleased]: https://github.com/itk-dev/event-database-imports/compare/1.2.2...HEAD
[1.2.2]: https://github.com/itk-dev/event-database-imports/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/itk-dev/event-database-imports/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/itk-dev/event-database-imports/compare/1.1.6...1.2.0
[1.1.6]: https://github.com/itk-dev/event-database-imports/releases/tag/1.1.6
[1.1.5]: https://github.com/itk-dev/event-database-imports/releases/tag/1.1.5
Expand Down
2 changes: 1 addition & 1 deletion config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ security:

firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
pattern: ^/(admin/)?(_(profiler|wdt))|^/(css|images|js)/
security: false
image_resolver:
pattern: ^/images/cache/resolve
Expand Down
9 changes: 9 additions & 0 deletions public/scripts/form-scroll-to-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener('ea.form.error', function (event) {
const form = event.detail.form;
const firstInvalid = form.querySelector(':invalid:not(:disabled)');

if (firstInvalid) {
firstInvalid.scrollIntoView({ behavior: 'smooth', block: 'center' });
firstInvalid.focus({ preventScroll: true });
}
});
98 changes: 98 additions & 0 deletions src/Command/Event/FixEventsWithoutOrganizerCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

namespace App\Command\Event;

use App\Repository\EventRepository;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:event:fix-without-organizer',
description: 'Set organization on events without organizer based on the creating user\'s organization'
)]
final class FixEventsWithoutOrganizerCommand extends Command
{
public function __construct(
private readonly EventRepository $eventRepository,
private readonly UserRepository $userRepository,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct();
}

protected function configure(): void
{
$this->addOption('dry-run', null, InputOption::VALUE_NONE, 'Show what would be changed without persisting');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$dryRun = $input->getOption('dry-run');

if ($dryRun) {
$io->note('Running in dry-run mode. No changes will be persisted.');
}

$events = $this->eventRepository->findBy(['organization' => null]);

if (0 === \count($events)) {
$io->success('No events found without an organization.');

return Command::SUCCESS;
}

$io->info(sprintf('Found %d event(s) without an organization.', \count($events)));

$fixed = 0;
$skipped = [];

foreach ($events as $event) {
$createdBy = $event->getCreatedBy();

if ('' === $createdBy) {
$skipped[] = [$event->getId(), $event->getTitle(), 'Not created by a user'];
continue;
}

$user = $this->userRepository->findOneBy(['mail' => $createdBy]);

if (null === $user) {
$skipped[] = [$event->getId(), $event->getTitle(), sprintf('User "%s" not found', $createdBy)];
continue;
}

$organizations = $user->getOrganizations();

if (1 !== $organizations->count()) {
$skipped[] = [$event->getId(), $event->getTitle(), sprintf('User "%s" has %d organizations', $createdBy, $organizations->count())];
continue;
}

$organization = $organizations->first();
$event->setOrganization($organization);
++$fixed;

$io->text(sprintf('Event #%d "%s" → Organization "%s"', $event->getId(), $event->getTitle(), $organization));
}

if (\count($skipped) > 0) {
$io->section('Skipped events');
$io->table(['ID', 'Title', 'Reason'], $skipped);
}

if ($fixed > 0 && !$dryRun) {
$this->entityManager->flush();
}

$io->success(sprintf('%s %d event(s).', $dryRun ? 'Would fix' : 'Fixed', $fixed));

return Command::SUCCESS;
}
}
72 changes: 72 additions & 0 deletions src/Command/User/ListUsersWithoutOrganizationCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace App\Command\User;

use App\Repository\UserRepository;
use App\Types\UserRoles;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:user:list-without-organization',
description: 'List users below editor role who have no organization'
)]
final class ListUsersWithoutOrganizationCommand extends Command
{
public function __construct(
private readonly UserRepository $userRepository,
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$editorOrAbove = [
UserRoles::ROLE_EDITOR->value,
UserRoles::ROLE_ADMIN->value,
UserRoles::ROLE_SUPER_ADMIN->value,
];

$qb = $this->userRepository->createQueryBuilder('u')
->leftJoin('u.organizations', 'o')
->where('o.id IS NULL');

// Roles are stored as a JSON array in the database, so we use `LIKE` to checks if a role is in the array.
foreach ($editorOrAbove as $i => $role) {
$qb->andWhere("u.roles NOT LIKE :role{$i}")
->setParameter("role{$i}", "%\"{$role}\"%");
}

$users = $qb->orderBy('u.name', 'ASC')
->getQuery()
->getResult();

if (0 === \count($users)) {
$io->success('No users found matching the criteria.');

return Command::SUCCESS;
}

$rows = array_map(fn ($user) => [
$user->getId(),
$user->getName(),
$user->getMail(),
implode(', ', $user->getRoles()),
$user->isEnabled() ? 'Yes' : 'No',
], $users);

$io->table(
['ID', 'Name', 'Email', 'Roles', 'Enabled'],
$rows,
);

$io->note(sprintf('Found %d user(s) without an organization who are not at least editor.', \count($users)));

return Command::SUCCESS;
}
}
4 changes: 3 additions & 1 deletion src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public function configureUserMenu(UserInterface $user): UserMenu

public function configureAssets(): Assets
{
return Assets::new()->addCssFile('/admin/styles/admin.css');
return Assets::new()
->addCssFile('/admin/styles/admin.css')
->addJsFile('/scripts/form-scroll-to-error.js');
}
}
Loading