Commit 1c211c7895f7fe67191329fc837693eebc9df423
1 parent
1121fdb7
Exists in
master
and in
28 other branches
create_topics: Corrections for merge-request.
(ActionItem2997) Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
5 changed files
with
45 additions
and
10 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -30,8 +30,8 @@ class CmsController < MyProfileController |
30 | 30 | |
31 | 31 | protect_if :only => :new do |c, user, profile| |
32 | 32 | article_id = c.params[:parent_id] |
33 | - (!article_id.blank? && profile.articles.find(article_id).forum? && profile.articles.find(article_id).allows_create_topics ) && | |
34 | - (profile.community? && profile.members.include?(user)) || (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) | |
33 | + (!article_id.blank? && (profile.articles.find(article_id).allow_create?(user) || profile.articles.find(article_id).parent.allow_create?(user))) || | |
34 | + (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) | |
35 | 35 | end |
36 | 36 | |
37 | 37 | protect_if :only => [:destroy, :publish] do |c, user, profile| | ... | ... |
app/helpers/article_helper.rb
... | ... | @@ -51,11 +51,11 @@ module ArticleHelper |
51 | 51 | content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions') |
52 | 52 | ) : '') + |
53 | 53 | |
54 | - (article.forum? ? | |
54 | + (article.forum? && article.profile.community? ? | |
55 | 55 | content_tag( |
56 | 56 | 'div', |
57 | - check_box(:article, :allows_create_topics) + | |
58 | - content_tag('label', _('Allow member to create topics'), :for => 'article_allows_create_topics') | |
57 | + check_box(:article, :allows_members_to_create_topics) + | |
58 | + content_tag('label', _('Allow member to create topics'), :for => 'article_allows_members_to_create_topics') | |
59 | 59 | ) : '') |
60 | 60 | ) |
61 | 61 | end | ... | ... |
app/models/forum.rb
... | ... | @@ -5,7 +5,7 @@ class Forum < Folder |
5 | 5 | |
6 | 6 | settings_items :terms_of_use, :type => :string, :default => "" |
7 | 7 | settings_items :has_terms_of_use, :type => :boolean, :default => false |
8 | - settings_items :allows_create_topics, :type => :boolean, :default => true | |
8 | + settings_items :allows_members_to_create_topics, :type => :boolean, :default => false | |
9 | 9 | has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people' |
10 | 10 | |
11 | 11 | before_save do |forum| |
... | ... | @@ -68,6 +68,10 @@ class Forum < Folder |
68 | 68 | end |
69 | 69 | |
70 | 70 | def can_create_topic?(user, profile) |
71 | - return profile.community? && profile.members.include?(user) && self.allows_create_topics | |
71 | + return profile.community? && profile.members.include?(user) && self.allows_members_to_create_topics | |
72 | + end | |
73 | + | |
74 | + def allow_create?(user) | |
75 | + super || can_create_topic?(user, profile) | |
72 | 76 | end |
73 | 77 | end | ... | ... |
app/views/content_viewer/_article_toolbar.rhtml
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | <%= expirable_button @page, :spread, content, url if url %> |
27 | 27 | <% end %> |
28 | 28 | |
29 | - <% if !@page.gallery? && ( @page.allow_create?(user) || (@page.forum? && @page.can_create_topic?(user, profile))) %> | |
29 | + <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %> | |
30 | 30 | <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %> |
31 | 31 | <% content = _('Add translation') %> |
32 | 32 | <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %> | ... | ... |
features/forum.feature
... | ... | @@ -230,7 +230,7 @@ Feature: forum |
230 | 230 | Then I should not see "New discussion topic" |
231 | 231 | |
232 | 232 | @selenium |
233 | - Scenario: community member should be able to create the discussion topic button | |
233 | + Scenario: community member should be able to create a topic with the discussion topic button | |
234 | 234 | Given the following community |
235 | 235 | | identifier | name | owner | |
236 | 236 | | sample-community | Sample Community | joaosilva | |
... | ... | @@ -252,4 +252,35 @@ Feature: forum |
252 | 252 | And I follow "Text article with visual editor" |
253 | 253 | And I fill in "Title" with "Test" |
254 | 254 | And I press "Save" |
255 | - Then I should see "Test" | |
256 | 255 | \ No newline at end of file |
256 | + Then I should see "Test" | |
257 | + | |
258 | + @selenium | |
259 | + Scenario: community member should be able to create a topic on a topic page | |
260 | + Given the following community | |
261 | + | identifier | name | owner | | |
262 | + | sample-community | Sample Community | joaosilva | | |
263 | + And the following forums | |
264 | + | owner | name | | |
265 | + | sample-community | Forum | | |
266 | + And the following users | |
267 | + | login | name | | |
268 | + | mariasilva | Maria Silva| | |
269 | + And "Maria Silva" is a member of "Sample Community" | |
270 | + And I am logged in as "joaosilva" | |
271 | + When I go to /sample-community/forum | |
272 | + And I follow "Configure forum" | |
273 | + And I check "Allow member to create topics" | |
274 | + And I press "Save" | |
275 | + And I am logged in as "mariasilva" | |
276 | + And I go to /sample-community/forum | |
277 | + And I follow "New discussion topic" | |
278 | + And I follow "Text article with visual editor" | |
279 | + And I fill in "Title" with "Test" | |
280 | + And I press "Save" | |
281 | + And I go to /sample-community/forum/test | |
282 | + And I follow "New discussion topic" | |
283 | + And I follow "Text article with visual editor" | |
284 | + And I fill in "Title" with "Test inside the topic page" | |
285 | + And I press "Save" | |
286 | + And I go to /sample-community/forum | |
287 | + Then I should see "Test inside the topic page" | |
257 | 288 | \ No newline at end of file | ... | ... |