-
Notifications
You must be signed in to change notification settings - Fork 73
Move contracts to a new Contract model
#12094
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
1bafab4
Add new contract model
polypixeldev 4cef2f8
Factor out invite relation into the contractable polymorphic relation…
polypixeldev 77cc7ce
Replace other usages of OrganizerPosition::Contract
polypixeldev 474be6e
Rename references to organizer_position_contract
polypixeldev cb8dbdd
Rename controller and view
polypixeldev 893401e
Rename opc_params object
polypixeldev 0a66aff
Rename path helpers
polypixeldev be297ba
Remove old contracts mailer
polypixeldev 700acb3
Rename remaining usage of contract.opi
polypixeldev 02b4872
Copy over records in db migration
polypixeldev 0db93f3
Fix model and migration
polypixeldev ef63d31
Fix use of contract.opi_id
polypixeldev cbde0c5
Fix undefined instance variable
polypixeldev f84f606
Move contract mailers
polypixeldev c1571e7
Reset pk sequence for contracts after migration
polypixeldev ae8a528
Move contract policy
polypixeldev 987421e
Rename ContractPolicy
polypixeldev 00fc45b
Fix sending contracts for existing members
polypixeldev a43ca31
Merge branch 'main' into polypixeldev/new-contract-model
polypixeldev e0ee624
Merge branch 'main' into polypixeldev/new-contract-model
polypixeldev 9ce83bd
Rename opc to contract in controller
polypixeldev c18535b
Remove redundant batches setting
polypixeldev 33f5dfe
Make one_non_void_contract validation private
polypixeldev 10dd5f6
Wrap db updates in send_contract method in transaction
polypixeldev 2cfac02
Move set airtable status within transaction
polypixeldev 4150a1e
Remove unnecessary transaction
polypixeldev fc48eec
Add note about reset_pk_sequence
polypixeldev 93b8b60
Use relations to improve Contractable performance
polypixeldev 44ccbe2
Remove override guards in Contractable
polypixeldev 8344c06
Add STI to contracts table
polypixeldev 8e56fe4
Merge branch 'main' into polypixeldev/new-contract-model
polypixeldev f29816c
Fix STI implementation
polypixeldev c3f9b90
Add relation to contract from organizer position
polypixeldev b872564
Disable ddl transaction
polypixeldev cbc3e9d
Add contract reference to op
polypixeldev 0b9024e
Fix migration
polypixeldev 47e5def
Merge branch 'main' into polypixeldev/new-contract-model
polypixeldev ce6fa21
Undo schema change
polypixeldev 41d4a9d
Rename contract reference to fiscal sponsorship contract
polypixeldev b8a821d
Add validation to make sure fs contract is a fiscal sponsorship contract
polypixeldev 5550428
Various small fixes
polypixeldev 844f5cc
Discard testing template id
polypixeldev 174ed22
Remove testing code
polypixeldev 0263d02
Fix typo
garyhtou b630365
Add comment about `create` action usage
garyhtou 6f62552
Fix FS contract validation
polypixeldev d52372d
Add prefills jsonb to contract
polypixeldev d24c2a5
Move OP contracts backfill into a one time job
polypixeldev 47bc8de
Use string keys in prefill jsonb
polypixeldev 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ContractsController < ApplicationController | ||
| before_action :set_opc, only: [:void, :resend_to_user, :resend_to_cosigner] | ||
|
|
||
| def create | ||
| @contract = Contract.new(opc_params) | ||
| authorize @contract | ||
| @contract.save! | ||
| flash[:success] = "Contract sent succesfully." | ||
| redirect_back(fallback_location: event_team_path(@contract.event)) | ||
| end | ||
|
|
||
| def void | ||
| authorize @contract | ||
| @contract.mark_voided! | ||
| flash[:success] = "Contract voided succesfully." | ||
| redirect_back(fallback_location: event_team_path(@contract.event)) | ||
| end | ||
|
|
||
| def resend_to_user | ||
| authorize @contract | ||
|
|
||
| ContractMailer.with(contract: @contract).notify.deliver_later | ||
|
|
||
| flash[:success] = "Contract resent to user succesfully." | ||
| redirect_back(fallback_location: event_team_path(@contract.event)) | ||
| end | ||
|
|
||
| def resend_to_cosigner | ||
| authorize @contract | ||
|
|
||
| if @contract.cosigner_email.present? | ||
| ContractMailer.with(contract: @contract).notify_cosigner.deliver_later | ||
| flash[:success] = "Contract resent to cosigner succesfully." | ||
| else | ||
| flash[:error] = "This contract has no cosigner." | ||
| end | ||
|
|
||
| redirect_back(fallback_location: event_team_path(@contract.event)) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def set_opc | ||
| @contract = Contract.find(params[:id]) | ||
| end | ||
|
|
||
| def opc_params | ||
| params.require(:contract).permit(:contractable_id, :contractable_type, :cosigner_email, :include_videos) | ||
| end | ||
|
|
||
| end | ||
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
53 changes: 0 additions & 53 deletions
53
app/controllers/organizer_position_contracts_controller.rb
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ContractMailer < ApplicationMailer | ||
| def notify | ||
| @contract = params[:contract] | ||
|
|
||
| mail to: @contract.user.email_address_with_name, subject: "You've been invited to sign a contract for #{@contract.event.name} on HCB 📝" | ||
| end | ||
|
|
||
| def notify_cosigner | ||
| @contract = params[:contract] | ||
|
|
||
| mail to: @contract.cosigner_email, subject: "You've been invited to sign a contract for #{@contract.event.name} on HCB 📝" | ||
| end | ||
|
|
||
| def pending_cosigner | ||
| @contract = params[:contract] | ||
|
|
||
| mail to: @contract.user.email_address_with_name, subject: "We're waiting for your cosigner to sign your HCB contract 📝" | ||
| end | ||
|
|
||
| def pending_hcb | ||
| @contract = params[:contract] | ||
|
|
||
| mail to: @contract.user.email_address_with_name, subject: "We're processing your HCB contract 📝" | ||
| end | ||
|
|
||
| end |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Contractable | ||
| extend ActiveSupport::Concern | ||
|
|
||
| included do | ||
| has_many :contracts, as: :contractable, dependent: :destroy | ||
|
|
||
| def on_contract_signed | ||
| # This method is a callback that can be overwritten in specific classes | ||
| nil | ||
| end | ||
|
|
||
| def on_contract_voided | ||
| # This method is a callback that can be overwritten in specific classes | ||
| nil | ||
| end | ||
|
|
||
| def contract_docuseal_template_id | ||
| # This method should be overwritten in specific classes | ||
| raise NotImplementedError, "The #{self.class.name} model includes Contractable, but hasn't implemented its own version of contract_docuseal_template_id." | ||
| end | ||
|
|
||
| def contract_user | ||
| # This method should be overwritten in specific classes | ||
| raise NotImplementedError, "The #{self.class.name} model includes Contractable, but hasn't implemented its own version of contract_user." | ||
| end | ||
|
|
||
| def contract_event | ||
| # This method should be overwritten in specific classes | ||
| raise NotImplementedError, "The #{self.class.name} model includes Contractable, but hasn't implemented its own version of contract_event." | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.