interim_stream_hackiness_helper.rb 1.22 KB
Newer Older
1 2 3 4 5 6 7
module InterimStreamHackinessHelper
  def commenting_disabled?(post)
    return true unless user_signed_in?
    if defined?(@commenting_disabled)
      @commenting_disabled
    elsif defined?(@stream)
      !@stream.can_comment?(post)
8
    else
9 10 11 12
      false
    end
  end

13 14
  ##### These methods need to go away once we pass publisher object into the partial ######
  
15 16 17 18
  def publisher_prefill_text
    if params[:prefill].present?
      params[:prefill]
    elsif defined?(@stream)
19
      @stream.publisher.prefill
20 21 22 23
    else
      nil
    end
  end
24 25

  def from_group(post)
26
    if defined?(@stream) && params[:controller] == 'multis'
27 28
      @stream.post_from_group(post)
    else
29
     []
30 31 32
    end
  end

33 34
  def what_stream_sentence(post)
    from_group(post).map{|x| I18n.t("streams.#{x.to_s}")}.to_sentence
35
  end
36 37 38 39

  def stream_settings_link(post)
    link_to "", "#{edit_user_path}#stream-preferences"
  end
40 41 42 43 44 45 46 47

  def publisher_open
    if defined?(@stream)
      @stream.publisher.open?
    else
      false
    end
  end
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

  def publisher_public
    if defined?(@stream)
      @stream.publisher.public?
    else
      false
    end
  end

  def publisher_explain
    if defined?(@stream)
      @stream.publisher.public?
    else
      false
    end
  end
64
end