Module: Formol::TopicsHelper
- Includes:
- PostsHelper
- Defined in:
- app/helpers/formol/topics_helper.rb
Instance Method Summary
collapse
-
#attach_poll_checkbox(topic) ⇒ Object
-
#display_edit_topic?(user, topic) ⇒ Boolean
-
#display_lock_topic?(user, topic) ⇒ Boolean
-
#display_pin_topic?(user, topic) ⇒ Boolean
-
#display_poll_form?(poll, topic, user) ⇒ Boolean
-
#display_reply_topic?(user, topic) ⇒ Boolean
-
#display_subscribe_topic?(user, topic) ⇒ Boolean
-
#display_unlock_topic?(user, topic) ⇒ Boolean
-
#display_unpin_topic?(user, topic) ⇒ Boolean
-
#link_to_subscription(topic, user) ⇒ Object
#avatar_for, #default_avatar, #display_avatars?, #display_signatures?, #link_to_last_fives_post_position, #link_to_post_position
Instance Method Details
#attach_poll_checkbox(topic) ⇒ Object
16
17
18
|
# File 'app/helpers/formol/topics_helper.rb', line 16
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
|
#display_edit_topic?(user, topic) ⇒ Boolean
27
28
29
|
# File 'app/helpers/formol/topics_helper.rb', line 27
def display_edit_topic?(user, topic)
!topic.locked? && formol_authorized?(user, :edit_topic, topic)
end
|
#display_lock_topic?(user, topic) ⇒ Boolean
47
48
49
|
# File 'app/helpers/formol/topics_helper.rb', line 47
def display_lock_topic?(user, topic)
!topic.locked? && formol_authorized?(user, :lock_topic)
end
|
#display_pin_topic?(user, topic) ⇒ Boolean
39
40
41
|
# File 'app/helpers/formol/topics_helper.rb', line 39
def display_pin_topic?(user, topic)
!topic.locked? && !topic.pinned? && formol_authorized?(user, :pin_topic)
end
|
20
21
22
23
24
25
|
# File 'app/helpers/formol/topics_helper.rb', line 20
def display_poll_form?(poll, topic, user)
!poll.expired? &&
!topic.locked? &&
formol_authorized?(user, :vote_poll, topic) &&
!poll.voted?(user)
end
|
#display_reply_topic?(user, topic) ⇒ Boolean
35
36
37
|
# File 'app/helpers/formol/topics_helper.rb', line 35
def display_reply_topic?(user, topic)
!topic.locked? && formol_authorized?(user, :create_post, topic)
end
|
#display_subscribe_topic?(user, topic) ⇒ Boolean
31
32
33
|
# File 'app/helpers/formol/topics_helper.rb', line 31
def display_subscribe_topic?(user, topic)
!topic.locked? && formol_authorized?(user, :subscribe_topic, topic)
end
|
#display_unlock_topic?(user, topic) ⇒ Boolean
51
52
53
|
# File 'app/helpers/formol/topics_helper.rb', line 51
def display_unlock_topic?(user, topic)
topic.locked? && formol_authorized?(user, :lock_topic)
end
|
#display_unpin_topic?(user, topic) ⇒ Boolean
43
44
45
|
# File 'app/helpers/formol/topics_helper.rb', line 43
def display_unpin_topic?(user, topic)
!topic.locked? && topic.pinned? && formol_authorized?(user, :pin_topic)
end
|
#link_to_subscription(topic, user) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'app/helpers/formol/topics_helper.rb', line 5
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
|