Skip to content

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 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.57%. Comparing base (8842f50) to head (92edb10).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
src/Controller/Admin/EventCrudController.php 0.00% 13 Missing ⚠️
src/DataFixtures/EventFixture.php 0.00% 13 Missing ⚠️
src/DataFixtures/FeedFixtures.php 0.00% 9 Missing ⚠️
src/DataFixtures/DailyOccurrenceFixture.php 0.00% 2 Missing ⚠️
src/DataFixtures/LocationFixture.php 0.00% 1 Missing ⚠️
src/DataFixtures/OccurrenceFixture.php 0.00% 1 Missing ⚠️
src/DataFixtures/OrganizationFixtures.php 0.00% 1 Missing ⚠️
src/DataFixtures/TagsFixtures.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop     #68      +/-   ##
============================================
- Coverage       0.57%   0.57%   -0.01%     
  Complexity      1205    1205              
============================================
  Files            156     156              
  Lines           4361    4362       +1     
============================================
  Hits              25      25              
- Misses          4336    4337       +1     
Flag Coverage Δ
8.4 0.57% <0.00%> (-0.01%) ⬇️
unittests 0.57% <0.00%> (-0.01%) ⬇️

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.

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