5
11
Fork
You've already forked tomato
1

Add flash messages if no alert email is set #19

Merged
edwardloveall merged 3 commits from el-org-email-crash into main 2025年08月20日 22:39:23 +02:00

Fixes #15

Picture a recurring event where future events have a volunteer but an earlier one does not. Adding that same volunteer to the earlier shift and all future shifts creates a "conflict" that we warn organizations about. That email is sent to the organization's internal_alerts_email.

If they don't have an email in that field, we would crash!! Instead of that, we put a message reminding them to fill out that email, and continue on successfully.

please add alert

Technically this works by returning a result object from the mutating EventsService methods (except delete ones). Before this, if a problem happens inside the EventService, we didn't have a great
way of dealing with it outside that service. update, update_into_future, and post_occurrence_details all now return an EventResult which contains an event and flash messages (sometimes empty). The controller can then still access the event, but also let the user know about other problems (or celebrations).

I didn't add them to the delete methods because nothing actually expected any events to be returned from them.

I also enabled mailer errors in development because they were off and it took me a while to figure out how to reproduce the bug.

Fixes #15 Picture a recurring event where future events have a volunteer but an earlier one does not. Adding that same volunteer to the earlier shift and all future shifts creates a "conflict" that we warn organizations about. That email is sent to the organization's `internal_alerts_email`. If they don't have an email in that field, we would crash!! Instead of that, we put a message reminding them to fill out that email, and continue on successfully. ![please add alert](/attachments/a1604305-12ee-4eeb-aaa9-a7810d0f3716) Technically this works by returning a result object from the mutating `EventsService` methods (except delete ones). Before this, if a problem happens inside the `EventService`, we didn't have a great way of dealing with it outside that service. `update`, `update_into_future`, and `post_occurrence_details` all now return an `EventResult` which contains an event and flash messages (sometimes empty). The controller can then still access the `event`, but also let the user know about other problems (or celebrations). I didn't add them to the delete methods because nothing actually expected any events to be returned from them. I also enabled mailer errors in development because they were off and it took me a while to figure out how to reproduce the bug.
edwardloveall force-pushed el-org-email-crash from 025e347c83
Some checks failed
Setup Successful
Jest Successful
Static Analysis Successful
RSpec Failed
to 9e81ed3a32
Some checks failed
Setup Successful
Jest Successful
Static Analysis Successful
RSpec Failed
2025年08月20日 15:26:59 +02:00
Compare
@ -0,0 +1,5 @@
EventResult = Data.define(:event, :flash_messages) do
First-time contributor
Copy link

I like using the struct for this so shape of what is returned is consistent. Definitely helps keep code clean in places expecting this return value.

I like using the struct for this so shape of what is returned is consistent. Definitely helps keep code clean in places expecting this return value.
@ -16,3 +16,3 @@
update_event(event, frequency_attributes, eventable_attributes)
end
event
EventResult.new(event:)
First-time contributor
Copy link

Not sure I'll ever get used to the "new" keyword args syntax that implicitly passes the variable with the same name. 😄

Not sure I'll ever get used to the "new" keyword args syntax that implicitly passes the variable with the same name. 😄
Author
Owner
Copy link

Oh you gotta. It's so good. It encourages a really nice coupling between argument and variable names that really helps you pick a good name for both.

Oh you gotta. It's so good. It encourages a really nice coupling between argument and variable names that really helps you pick a good name for both.
First-time contributor
Copy link

Side note: I had a thought about the 2 task_logs_controllers that I'm not sure is worth the effort unless you find yourself needing to modify how those work in a significant way. But they are almost identical so I would be tempted to try and combine them into a single controller.

Side note: I had a thought about the 2 `task_logs_controller`s that I'm not sure is worth the effort unless you find yourself needing to modify how those work in a significant way. But they are almost identical so I would be tempted to try and combine them into a single controller.
Author
Owner
Copy link

@thetizzo wrote in #19 (comment):

Side note: I had a thought about the 2 task_logs_controllers that I'm not sure is worth the effort unless you find yourself needing to modify how those work in a significant way. But they are almost identical so I would be tempted to try and combine them into a single controller.

Oh yeah, huh. I could probably do some responds_to magic as long as the auth works the same for both.

@thetizzo wrote in https://codeberg.org/rootable/tomato/pulls/19#issuecomment-6614950: > Side note: I had a thought about the 2 `task_logs_controller`s that I'm not sure is worth the effort unless you find yourself needing to modify how those work in a significant way. But they are almost identical so I would be tempted to try and combine them into a single controller. Oh yeah, huh. I could probably do some `responds_to` magic as long as the auth works the same for both.
edwardloveall force-pushed el-org-email-crash from 9e81ed3a32
Some checks failed
Setup Successful
Jest Successful
Static Analysis Successful
RSpec Failed
to 4be5322d27
All checks were successful
Setup Successful
Jest Successful
Static Analysis Successful
RSpec Successful
2025年08月20日 22:10:11 +02:00
Compare
Author
Owner
Copy link

Spec is flaky. Watched it pass locally.

Spec is flaky. Watched it pass locally.
edwardloveall deleted branch el-org-email-crash 2025年08月20日 22:39:28 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rootable/tomato!19
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-org-email-crash"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?