egman24
6/2/2015 - 1:41 PM

gistfile1.txt

REOPEN KEY (allow manual completion with date of EVAL in interface as completion date)

class Key
  def force(date_string)
    if activated?
      create_event(action: 'completed')
      self.completed_at = Time.zone.parse(date_string) # 'Wed, 18 Mar 2015 23:09:22'
      completed!
      passed!
      self
    else
      raise "Invalid transition from #{self.state} to completed."
    end
  end
end

def keyupdate(email, date)
  Key.find_by(user_id: User.find_by(email: email)).force(date)
  a = User.find_by(email: email).keys.first.events.last
  a.created_at = date
  a.save!
end
  
  


keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
keyupdate("jpiccolo90@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")

kathleen.steffe@comcast.net
lekkerding54@gmail.com
messickpz@gmail.com
rhauser@stonehaus.net
saralessler@verizon.net
seananderica@triad.rr.com
shelton2031@yahoo.com
skins4life2420@gmail.com
sunitha_60@hotmail.com
svadapalli@gmail.com
virginiadaileys@gmail.com
xjohnniox@triad.rr.com

irb(main):059:0> keyupdate("beadolphinswimmer@gmail.com", "Tue, 26 May 2015 00:25:43 +0000")
RuntimeError: Invalid transition from available to completed.


SEPERATE?

Attach Key DPVKJLZZ8 (Sara Mccartney - saramc1210@verizon.net) to the Central Maryland Swim League OKM (Org 14)
Reset key GAFRZRHJC also attached to Sara Mccartney - saramc1210@verizon.net (Need that Key to be back in inventory as available)
Attach Key YWKEJA8KR (Tom Swiss tswiss4636@comcast.net) to the Central Maryland Swim League (Org 14) Instead of Scitent Demo Org (Org 10) + Change the user who assigned the key to Joe Cucchiaro 
Reset key YD4E7NN03 (Debbie Swiss - dswiss2871@aol.com) and attach it to Scitent Demo Org (Org 10) instead of Central Maryland Swim League (Org 14)