-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] 5104: Require event organizer #68
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
Draft
rimi-itk
wants to merge
3
commits into
develop
Choose a base branch
from
feature/5110-require-event-organizer
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,9 +31,10 @@ The application is built around Symfony and event messages for more information | |
| [docs](docs/README.md) folder in this repository. | ||
|
|
||
| ```shell | ||
| docker compose up -d | ||
| docker compose pull | ||
| docker compose up --detach --remove-orphans | ||
| docker compose exec phpfpm composer install | ||
| docker compose exec phpfpm bin/console doctrine:migrations:migrate | ||
| docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction | ||
| docker compose exec phpfpm bin/console app:index:create | ||
| docker compose exec phpfpm bin/console messenger:setup-transports | ||
| ``` | ||
|
|
@@ -82,6 +83,13 @@ doctrine fixture load command: | |
| docker compose exec phpfpm bin/console doctrine:fixtures:load | ||
| ``` | ||
|
|
||
| After loading fixtures, you can sign (on `/admin/login`) in as one of these users: | ||
|
|
||
| | Username | Password | Roles | | ||
| |--------------------|--------------|--------------| | ||
| | `[email protected]` | `admin` | `ROLE_ADMIN` | | ||
| | `[email protected]` | `1233456789` | `ROLE_ADMIN` | | ||
|
|
||
| ### Production | ||
|
|
||
| When installing composer and Symfony based application in production, you should not install development packages, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,10 @@ | |
| use App\Service\ImageServiceInterface; | ||
| use App\Types\UserRoles; | ||
| use Doctrine\Common\Collections\Order; | ||
| use Doctrine\ORM\QueryBuilder; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Asset; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; | ||
| use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | ||
|
|
@@ -134,20 +132,22 @@ public function configureFields(string $pageName): iterable | |
| yield FormField::addFieldset('Organizer information') | ||
| ->setLabel(new TranslatableMessage('admin.event.organizer.headline')); | ||
|
|
||
| if ($this->isGranted(UserRoles::ROLE_EDITOR->value)) { | ||
| yield AssociationField::new('organization') | ||
| ->setLabel(new TranslatableMessage('admin.event.edited.organization')); | ||
| } else { | ||
| yield AssociationField::new('organization') | ||
| ->setLabel(new TranslatableMessage('admin.event.edited.organization')) | ||
| ->setQueryBuilder( | ||
| fn (QueryBuilder $queryBuilder) => $queryBuilder | ||
| ->select('o') | ||
| ->from(Organization::class, 'o') | ||
| ->where(':user MEMBER OF o.users') | ||
| ->setParameter('user', $this->getUser()) | ||
| ); | ||
| $organization = AssociationField::new('organization') | ||
| ->setLabel(new TranslatableMessage('admin.event.edited.organization')) | ||
| // We assume at least one organization exist for non-editor users | ||
| // (cf. editor stuff below). | ||
| ->setRequired(true) | ||
| ->setFormTypeOption('placeholder', new TranslatableMessage('admin.event.organizer.placeholder')); | ||
| // Limit organization choices for non-editors to the organizations the user is a member of. | ||
| if (!$this->isGranted(UserRoles::ROLE_EDITOR->value)) { | ||
| $userOrganizations = $this->getUser()->getOrganizations(); | ||
| $organization | ||
| ->setFormTypeOption('choices', $userOrganizations) | ||
| // Make sure that the user is not forced to make a choice if none exists. | ||
| ->setRequired($userOrganizations->count() > 0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choice should exist, so better to throw an exception. |
||
| } | ||
| yield $organization; | ||
|
|
||
| yield AssociationField::new('partners') | ||
| ->setLabel(new TranslatableMessage('admin.event.edited.partners')) | ||
| ->hideOnDetail(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| namespace App\DataFixtures; | ||
|
|
||
| use App\Entity\Address; | ||
| use App\Entity\Location; | ||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
|
|
@@ -17,7 +18,7 @@ public function load(ObjectManager $manager): void | |
| $location->setName('ITK Development') | ||
| ->setMail('[email protected]') | ||
| ->setUrl('https://itk.aarhus.dk/om-itk/afdelinger/development/') | ||
| ->setAddress($this->getReference(AddressFixture::ITKDEV)) | ||
| ->setAddress($this->getReference(AddressFixture::ITKDEV, Address::class)) | ||
| ->setDisabilityAccess(true) | ||
| ->setEditable(true); | ||
| $manager->persist($location); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes:
$organizationFieldwould better signal what is assigned to the vaiableAs for the actual business logic, the intent was:
organizeris ALWAYS requirededitorandadminusers can set organizer from all available organizers.organization-editor/admincan only select form organizations they belong to (they should ALWAYS belong to at least one organization, but I don't think this is enforced)One further possible improvement (as stated in the linked ticket) would be for
organization-editor/adminusers that only belong to one organization. If we could set that organization as default value, and disable the field.