diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb index 56c4688..87e24f6 100644 --- a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb @@ -59,6 +59,10 @@ class CommentParagraphPlugin < Noosfero::Plugin [CommentParagraphPlugin::API] end + def content_types + [CommentParagraphPlugin::Discussion] + end + end require_dependency 'comment_paragraph_plugin/macros/allow_comment' diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion.rb new file mode 100644 index 0000000..58bf799 --- /dev/null +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion.rb @@ -0,0 +1,26 @@ +class CommentParagraphPlugin::Discussion < Event + + def self.type_name + _('Comments Discussion') + end + + def self.short_description + _('Comments Discussion') + end + + def self.description + _('Article with paragraph comments') + end + + def accept_comments? + current_time = Time.now + super && + (start_date.nil? || current_time >= start_date) && + (end_date.nil? || current_time <= end_date) + end + + def comment_paragraph_plugin_activated? + environment.plugin_enabled?(CommentParagraphPlugin) + end + +end diff --git a/plugins/comment_paragraph/test/unit/discussion_test.rb b/plugins/comment_paragraph/test/unit/discussion_test.rb new file mode 100644 index 0000000..b7dfd6a --- /dev/null +++ b/plugins/comment_paragraph/test/unit/discussion_test.rb @@ -0,0 +1,31 @@ +require_relative '../test_helper' + +class DiscussionTest < ActiveSupport::TestCase + + def setup + @profile = fast_create(Community) + @discussion = fast_create(TextArticle, :profile_id => profile.id) + @environment = Environment.default + @environment.enable_plugin(CommentParagraphPlugin) + end + + attr_reader :discussion, :environment, :profile + + should 'parse html when save discussion' do + discussion = CommentParagraphPlugin::Discussion.new(profile: profile, name: "discussion", start_date: Time.now, end_date: Time.now + 1.day) + discussion.body = '