Skip to content

5104: Require event organizer#68

Open
rimi-itk wants to merge 16 commits intodevelopfrom
feature/5110-require-event-organizer
Open

5104: Require event organizer#68
rimi-itk wants to merge 16 commits intodevelopfrom
feature/5110-require-event-organizer

Conversation

@rimi-itk
Copy link
Contributor

@rimi-itk rimi-itk commented Aug 12, 2025

Link to ticket

https://leantime.itkdev.dk/_#/tickets/showTicket/5104

Description

  • Makes setting organizer on event required

Screenshot of the result

If your change affects the user interface you should include a screenshot of the result with the pull request.

Checklist

  • My code is covered by test cases.
  • My code passes our test (all our tests).
  • My code passes our static analysis suite.
  • My code passes our continuous integration process.

If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change
should be exempt from the list.

Additional comments or questions

  1. I'm not completely sure why the editor role is handled as a special case in EventCrudController.php, but I assume that it has something to do with that role be some kind of super user (that has access to everything)
  2. I'm not completely sure that User::getOrganizations() and SELECT o FROM Organization o WHERE user MEMBER OF o.users (cf. changes in EventCrudController.php)

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 0% with 208 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.71%. Comparing base (8842f50) to head (75afa7a).
⚠️ Report is 43 commits behind head on develop.

Files with missing lines Patch % Lines
src/Controller/Admin/EventCrudController.php 0.00% 77 Missing ⚠️
...Command/Event/FixEventsWithoutOrganizerCommand.php 0.00% 40 Missing ⚠️
...mmand/User/ListUsersWithoutOrganizationCommand.php 0.00% 33 Missing ⚠️
src/EasyAdmin/Filter/JsonContainsFilter.php 0.00% 28 Missing ⚠️
src/EasyAdmin/Filter/HasOrganizationFilter.php 0.00% 16 Missing ⚠️
src/Controller/Admin/UserCrudController.php 0.00% 11 Missing ⚠️
src/Controller/Admin/DashboardController.php 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop     #68      +/-   ##
============================================
+ Coverage       0.57%   3.71%   +3.14%     
- Complexity      1205    1248      +43     
============================================
  Files            156     162       +6     
  Lines           4361    4438      +77     
============================================
+ Hits              25     165     +140     
+ Misses          4336    4273      -63     
Flag Coverage Δ
8.4 ?
unittests 3.71% <0.00%> (+3.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rimi-itk rimi-itk force-pushed the feature/5110-require-event-organizer branch 2 times, most recently from 4f8f753 to 619a553 Compare August 12, 2025 09:26
@rimi-itk rimi-itk changed the title 5110: Require event organizer 5104: Require event organizer Aug 12, 2025
@rimi-itk rimi-itk force-pushed the feature/5110-require-event-organizer branch from 619a553 to 92edb10 Compare August 12, 2025 09:41
@rimi-itk rimi-itk changed the title 5104: Require event organizer [WIP] 5104: Require event organizer Aug 13, 2025
@rimi-itk rimi-itk requested a review from turegjorup August 14, 2025 09:38
->where(':user MEMBER OF o.users')
->setParameter('user', $this->getUser())
);
$organization = AssociationField::new('organization')
Copy link
Contributor

Choose a reason for hiding this comment

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

A few notes:

  • I think the original if/else construct has better readability but that is highly subjective
  • $organizationField would better signal what is assigned to the vaiable

As for the actual business logic, the intent was:

  • organizer is ALWAYS required
  • editor and admin users can set organizer from all available organizers.
  • organization-editor/admin can 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/admin users that only belong to one organization. If we could set that organization as default value, and disable the field.

$organization
->setFormTypeOption('choices', $userOrganizations)
// Make sure that the user is not forced to make a choice if none exists.
->setRequired($userOrganizations->count() > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Choice should exist, so better to throw an exception.

turegjorup and others added 7 commits February 17, 2026 12:30
# Conflicts:
#	CHANGELOG.md
#	README.md
#	config/packages/security.yaml
…nizations

Add EasyAdmin filters to UserCrudController for organizations, has/no
organization, roles (JSON-aware), and email. Add console command
app:user:list-without-organization to list non-editor users with no
organization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of displaying a summary of all validation errors, scroll to
and focus the first invalid field. Remove the now-unused
form-errors-summary container and its translation keys.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@turegjorup turegjorup changed the title [WIP] 5104: Require event organizer 5104: Require event organizer Feb 23, 2026
@turegjorup turegjorup marked this pull request as ready for review February 23, 2026 12:20
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor Author

@rimi-itk rimi-itk left a comment

Choose a reason for hiding this comment

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

This looks good! I've added some comments and suggestions.

Comment on lines +5 to +8
if (firstInvalid) {
firstInvalid.scrollIntoView({ behavior: 'smooth', block: 'center' });
firstInvalid.focus({ preventScroll: true });
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a really good idea! 🎉

Comment on lines +29 to +33
$editorOrAbove = [
UserRoles::ROLE_EDITOR->value,
UserRoles::ROLE_ADMIN->value,
UserRoles::ROLE_SUPER_ADMIN->value,
];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be able to compute this based on the role hierarchy, but we'll leave that for later.

->hideOnIndex();
}

yield TextField::new('created_by')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should use the entity property names (rather than database column names) to defined fields , i.e. TextField::new('createdBy') etc. (cf. https://symfony.com/bundles/EasyAdminBundle/current/fields.html).

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you “extend from the original templates and change only the parts you want to override” in the “new” and “edit” templates?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants