Commit 111c51f
authored
Only create Contracts through Contractable (#12251)
## Summary of the problem
<!-- Why are these changes being made? What problem does it solve? Link
any related issues to provide more details. -->
https://appsignal.com/hack-club/sites/6596247683eb67648f30f807/exceptions/incidents/2394
Bug introduced in #12094 - since `Contract` and
`OrganizerPositionInvite` are now decoupled, there are some fields of
the `Contract` model that need to be set using info from the
`Contractable`. Notably, the `prefills` jsonb includes event data that
must be included in the `Contract` before creation, since it is used in
the after create callback that sends the payload to Docuseal. While we
were doing this in the `send_contract` method on
`OrganizerPositionInvite`, we were not doing this when creating a
contract using the create action in `ContractsController` (used when
sending a contract on a pre-existing invite or organizer position),
causing the above bug.
## Describe your changes
<!-- Explain your thought process to the solution and provide a quick
summary of the changes. -->
While this could have been fixed by just grabbing the necessary data
from the `Contractable` and passing it to `Contract.new` in
`ContractsController`, it's better to maintain that contracts should
only be created using methods on the `Contractable`. This way, changes
can be easily made to what data is passed to the `Contract`, and any
extra code (such as updating the `OrganizerPosition` or Airtable can be
done in one place.
This does involve updating the `OrganizerPositionInvite` after it has
been sent and accepted - I've fixed a validation to not fail when this
happens, but it would also be possible to modify the code so that this
model is essentially "frozen" after being accepted, and only update the
`is_signee` field before accepting.1 parent 9b09f84 commit 111c51f
File tree
10 files changed
+43
-45
lines changed- app
- controllers
- models
- policies
- views
- contract
- organizer_position_invites
- organizer_positions
- config
10 files changed
+43
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 6 | | |
17 | 7 | | |
18 | 8 | | |
| |||
48 | 38 | | |
49 | 39 | | |
50 | 40 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 41 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
This file was deleted.
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
338 | | - | |
| 339 | + | |
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| |||
0 commit comments