Sha256: 96672ffa79f7b1f53cef7ff5345aebadf2e56302a37ce818122ea858c69cec1e

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

module Formol
  module TopicsHelper
    include PostsHelper
    
    def link_to_subscription(topic, user)
      subscriber = topic.subscriber?(user)
      method = subscriber ? :delete : :post
      text = t('formol.topics.show.' + (subscriber ? 'unsubscribe' : 'subscribe'))
      switch_text = t('formol.topics.show.' + (subscriber ? 'subscribe' : 'unsubscribe'))
      
      link_to text, topic_subscriptions_path(topic),  :method => method, 
                                                      :remote => true,
                                                      :'data-switch-text' => switch_text
    end
    
    def attach_poll_checkbox(topic)
      %{<input type="checkbox" name="topic[attach_poll]" id="topic_attach_poll" value="1" #{'checked="checked"' if topic.attach_poll} />}.html_safe
    end
    
    def display_poll_form?(poll, topic, user)
      !poll.expired? && 
      !topic.locked? && 
      formol_authorized?(user, :vote_poll, topic) && 
      !poll.voted?(user)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
formol-0.0.4 app/helpers/formol/topics_helper.rb