Last active
October 11, 2017 07:28
-
-
Save dmitriy-sqrt/c405c225e117043ad7db20f215df4556 to your computer and use it in GitHub Desktop.
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
class TrickyCancel | |
def initialize(submission = nil) | |
@submission = submission | |
@requester_user = User.find(1511) | |
end | |
def execute | |
@submissions = get_submissions | |
@submissions.each do |submission| | |
@submission = submission | |
cancel_submission | |
end | |
end | |
def cancel_submission | |
# @submission.cancel(@requester_user) | |
@submission.assign_attributes( | |
cancelled_at: Time.current, canceller: @requester_user | |
) | |
@submission.save(validate: false) | |
end | |
private | |
def get_submissions | |
Submission.where(uuid: | |
["7b67a330", | |
"a383cbfd", | |
"c51cb823", | |
"4653fd8d", | |
"1c1e8750", | |
"1bfd49b5", | |
"26a39e55"]) | |
end | |
def event_class | |
Event::CancelSubmission | |
end | |
def create_event | |
event_class.create!( | |
creator: @requester_user, | |
target: @submission, | |
at: Time.current | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment