Sha256: 52e606058fb448673d7bf2d1eeb2b50e11854b2992e2f34379f9fdaa36d15333

Contents?: true

Size: 1001 Bytes

Versions: 21

Compression:

Stored size: 1001 Bytes

Contents

class GoAction < Action

  has_many :tickets, :foreign_key => "validated_action_id"

  def show
    subject
  end
  
  def action_type
    "Go"
  end
  
  def verb
    "went"
  end

  def sentence
    #TODO: YUK. Do we still have to do this to discriminate from manually logged actions?
    if subject.is_a? Show
      verb + " " + self.details
    else
      " to a show"
    end
  end
  
  def self.for(show, person, occurred_at=nil, &block)
    existing_action = GoAction.where({:subject_id => show.id, :person_id => person.id}).first
    return existing_action || GoAction.new.tap do |go_action|
      go_action.person = person
      go_action.subject = show
      go_action.details = "to #{show.event.name} on #{I18n.l show.datetime_local_to_event, :format => :short}"
      go_action.organization = show.organization
      go_action.occurred_at = ( occurred_at.nil? ? show.datetime : occurred_at )
      block.call(go_action) if block.present?
    end
  end

  def self.subtypes
    []
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.23 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.21 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.20 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.19 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.18 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.17 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.16 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.15 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.12 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.11 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.10 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.9 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.8 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.7 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.6 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.5 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.4 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.3 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.2 app/models/actions/go_action.rb
artfully_ose-1.2.0.pre.1 app/models/actions/go_action.rb