Commit a86306b1acc9b945fb1c5c33015724a1487b9fac
1 parent
d877a56d
Exists in
staging
and in
6 other branches
New feature archive articles to avoid create comments, associate children articles and perform votes
Showing
19 changed files
with
179 additions
and
6 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -99,6 +99,7 @@ class CmsController < MyProfileController | @@ -99,6 +99,7 @@ class CmsController < MyProfileController | ||
| 99 | @article.image.save! | 99 | @article.image.save! |
| 100 | end | 100 | end |
| 101 | @article.last_changed_by = user | 101 | @article.last_changed_by = user |
| 102 | + @article.old_parent_id = @article.parent_id | ||
| 1 |
|
||
| 102 | if @article.update_attributes(params[:article]) | 103 | if @article.update_attributes(params[:article]) |
| 103 | if !continue | 104 | if !continue |
| 104 | if @article.content_type.nil? || @article.image? | 105 | if @article.content_type.nil? || @article.image? |
app/helpers/article_helper.rb
| @@ -15,6 +15,13 @@ module ArticleHelper | @@ -15,6 +15,13 @@ module ArticleHelper | ||
| 15 | topic_creation(@article) + | 15 | topic_creation(@article) + |
| 16 | content_tag('h4', _('Options')) + | 16 | content_tag('h4', _('Options')) + |
| 17 | content_tag('div', | 17 | content_tag('div', |
| 18 | + content_tag('div', | ||
| 19 | + check_box(:article, :archived) + | ||
| 20 | + content_tag('span', ' ', :class => 'access-archived-icon') + | ||
| 21 | + content_tag('label', _('Read Only'), :for => 'article_archived_true') + | ||
| 22 | + content_tag('span', _('Archive to avoid create comments, votes, actions in children articles...'), :class => 'access-note'), | ||
| 23 | + :class => 'access-item' | ||
| 24 | + ) + | ||
| 18 | (article.profile.has_members? ? | 25 | (article.profile.has_members? ? |
| 19 | content_tag( | 26 | content_tag( |
| 20 | 'div', | 27 | 'div', |
| @@ -63,13 +70,20 @@ module ArticleHelper | @@ -63,13 +70,20 @@ module ArticleHelper | ||
| 63 | content_tag('div', | 70 | content_tag('div', |
| 64 | content_tag('div', | 71 | content_tag('div', |
| 65 | radio_button(:article, :published, true) + | 72 | radio_button(:article, :published, true) + |
| 66 | - content_tag('label', _('Public (visible to other people)'), :for => 'article_published_true') | 73 | + content_tag('span', ' ', :class => 'access-public-icon') + |
| 74 | + content_tag('label', _('Public'), :for => 'article_published_true') + | ||
| 75 | + content_tag('span', _('Visible to other people'), :class => 'access-note'), | ||
| 76 | + :class => 'access-item' | ||
| 67 | ) + | 77 | ) + |
| 68 | content_tag('div', | 78 | content_tag('div', |
| 69 | radio_button(:article, :published, false) + | 79 | radio_button(:article, :published, false) + |
| 70 | - content_tag('label', _('Private'), :for => 'article_published_false', :id => "label_private") | 80 | + content_tag('span', ' ', :class => 'access-private-icon') + |
| 81 | + content_tag('label', _('Private'), :for => 'article_published_false', :id => "label_private") + | ||
| 82 | + content_tag('span', _('Limit visibility of this article'), :class => 'access-note'), | ||
| 83 | + :class => 'access-item' | ||
| 71 | ) + | 84 | ) + |
| 72 | - privacity_exceptions(article, tokenized_children) | 85 | + privacity_exceptions(article, tokenized_children), |
| 86 | + :class => 'access-itens' | ||
| 73 | ) | 87 | ) |
| 74 | end | 88 | end |
| 75 | 89 |
app/helpers/folder_helper.rb
| @@ -61,7 +61,15 @@ module FolderHelper | @@ -61,7 +61,15 @@ module FolderHelper | ||
| 61 | @article = article | 61 | @article = article |
| 62 | 62 | ||
| 63 | visibility_options(article,tokenized_children) + | 63 | visibility_options(article,tokenized_children) + |
| 64 | + content_tag('h4', _('Options')) + | ||
| 64 | content_tag('div', | 65 | content_tag('div', |
| 66 | + content_tag('div', | ||
| 67 | + check_box(:article, :archived) + | ||
| 68 | + content_tag('span', ' ', :class => 'access-archived-icon') + | ||
| 69 | + content_tag('label', _('Read Only'), :for => 'article_archived_true') + | ||
| 70 | + content_tag('span', _('Archive to avoid votes and create new children articles'), :class => 'access-note'), | ||
| 71 | + :class => 'access-item' | ||
| 72 | + ) + | ||
| 65 | hidden_field_tag('article[accept_comments]', 0) | 73 | hidden_field_tag('article[accept_comments]', 0) |
| 66 | ) | 74 | ) |
| 67 | end | 75 | end |
app/models/article.rb
| @@ -9,7 +9,9 @@ class Article < ActiveRecord::Base | @@ -9,7 +9,9 @@ class Article < ActiveRecord::Base | ||
| 9 | :highlighted, :notify_comments, :display_hits, :slug, | 9 | :highlighted, :notify_comments, :display_hits, :slug, |
| 10 | :external_feed_builder, :display_versions, :external_link, | 10 | :external_feed_builder, :display_versions, :external_link, |
| 11 | :image_builder, :show_to_followers, | 11 | :image_builder, :show_to_followers, |
| 12 | - :author, :display_preview | 12 | + :author, :display_preview, :archived |
| 13 | + | ||
| 14 | + attr_accessor :old_parent_id | ||
| 1 |
|
||
| 13 | 15 | ||
| 14 | acts_as_having_image | 16 | acts_as_having_image |
| 15 | 17 | ||
| @@ -154,6 +156,8 @@ class Article < ActiveRecord::Base | @@ -154,6 +156,8 @@ class Article < ActiveRecord::Base | ||
| 154 | validate :no_self_reference | 156 | validate :no_self_reference |
| 155 | validate :no_cyclical_reference, :if => 'parent_id.present?' | 157 | validate :no_cyclical_reference, :if => 'parent_id.present?' |
| 156 | 158 | ||
| 159 | + validate :parent_archived? | ||
| 160 | + | ||
| 157 | def no_self_reference | 161 | def no_self_reference |
| 158 | errors.add(:parent_id, _('self-reference is not allowed.')) if id && parent_id == id | 162 | errors.add(:parent_id, _('self-reference is not allowed.')) if id && parent_id == id |
| 159 | end | 163 | end |
| @@ -484,6 +488,10 @@ class Article < ActiveRecord::Base | @@ -484,6 +488,10 @@ class Article < ActiveRecord::Base | ||
| 484 | end | 488 | end |
| 485 | end | 489 | end |
| 486 | 490 | ||
| 491 | + def archived? | ||
| 492 | + (self.parent && self.parent.archived) || self.archived | ||
| 493 | + end | ||
| 494 | + | ||
| 487 | def self.folder_types | 495 | def self.folder_types |
| 488 | ['Folder', 'Blog', 'Forum', 'Gallery'] | 496 | ['Folder', 'Blog', 'Forum', 'Gallery'] |
| 489 | end | 497 | end |
| @@ -842,4 +850,10 @@ class Article < ActiveRecord::Base | @@ -842,4 +850,10 @@ class Article < ActiveRecord::Base | ||
| 842 | sanitizer.sanitize(text) | 850 | sanitizer.sanitize(text) |
| 843 | end | 851 | end |
| 844 | 852 | ||
| 853 | + def parent_archived? | ||
| 854 | + if (self.old_parent_id != self.parent_id) && self.parent && self.parent.archived? | ||
| 2 |
|
||
| 855 | + errors.add(:parent_folder, N_('is archived!!')) | ||
| 856 | + end | ||
| 857 | + end | ||
| 858 | + | ||
| 845 | end | 859 | end |
app/models/comment.rb
app/models/folder.rb
app/views/cms/edit.html.erb
| 1 | <%= error_messages_for 'article' %> | 1 | <%= error_messages_for 'article' %> |
| 2 | 2 | ||
| 3 | +<% if @article.archived? %> | ||
| 4 | + <%= render :partial => 'archived_warning', :locals => {:article => @article} %> | ||
| 5 | +<% end %> | ||
| 3 | <div class='<%= (@article.display_media_panel? ? 'with_media_panel' : 'no_media_panel') %>'> | 6 | <div class='<%= (@article.display_media_panel? ? 'with_media_panel' : 'no_media_panel') %>'> |
| 4 | <%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %> | 7 | <%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %> |
| 5 | 8 | ||
| @@ -9,6 +12,7 @@ | @@ -9,6 +12,7 @@ | ||
| 9 | 12 | ||
| 10 | <%= hidden_field_tag('success_back_to', @success_back_to) %> | 13 | <%= hidden_field_tag('success_back_to', @success_back_to) %> |
| 11 | 14 | ||
| 15 | + | ||
| 12 | <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %> | 16 | <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %> |
| 13 | 17 | ||
| 14 | <% if environment.is_portal_community?(profile) %> | 18 | <% if environment.is_portal_community?(profile) %> |
app/views/content_viewer/_article_toolbar.html.erb
| @@ -29,7 +29,9 @@ | @@ -29,7 +29,9 @@ | ||
| 29 | <%= expirable_button @page, :locale, content, url %> | 29 | <%= expirable_button @page, :locale, content, url %> |
| 30 | <% end %> | 30 | <% end %> |
| 31 | 31 | ||
| 32 | - <%= modal_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:new, @page) %> | 32 | + <% if !@page.archived? %> |
| 33 | + <%= modal_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:new, @page) %> | ||
| 34 | + <% end %> | ||
| 33 | 35 | ||
| 34 | <% content = content_tag('span', label_for_clone_article(@page)) %> | 36 | <% content = content_tag('span', label_for_clone_article(@page)) %> |
| 35 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'new', :id => @page.id, :clone => true, :parent_id => (@page.folder? ? @page : @page.parent), :type => @page.class}) %> | 37 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'new', :id => @page.id, :clone => true, :parent_id => (@page.folder? ? @page : @page.parent), :type => @page.class}) %> |
| @@ -64,6 +66,9 @@ | @@ -64,6 +66,9 @@ | ||
| 64 | <% end %> | 66 | <% end %> |
| 65 | <%= button_without_text(:feed, _('RSS feed'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> | 67 | <%= button_without_text(:feed, _('RSS feed'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> |
| 66 | <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> | 68 | <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> |
| 69 | + <% if @page.archived? %> | ||
| 70 | + <%= render :partial => 'cms/archived_warning', :locals => {:article => @page} %> | ||
| 71 | + <% end %> | ||
| 67 | <%= render :partial => 'article_title', :locals => {:no_link => true} %> | 72 | <%= render :partial => 'article_title', :locals => {:no_link => true} %> |
| 68 | <%= article_translations(@page) %> | 73 | <%= article_translations(@page) %> |
| 69 | </div> | 74 | </div> |
app/views/content_viewer/view_page.html.erb
| @@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
| 85 | <% end %> | 85 | <% end %> |
| 86 | </ul> | 86 | </ul> |
| 87 | 87 | ||
| 88 | - <% if @page.accept_comments? %> | 88 | + <% if !@page.archived? || @page.accept_comments? %> |
| 89 | <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div> | 89 | <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div> |
| 90 | <% end %> | 90 | <% end %> |
| 91 | </div><!-- end class="comments" --> | 91 | </div><!-- end class="comments" --> |
166 Bytes
273 Bytes
570 Bytes
509 Bytes
public/javascripts/article.js
| @@ -212,4 +212,10 @@ jQuery(function($) { | @@ -212,4 +212,10 @@ jQuery(function($) { | ||
| 212 | $("#article_published_true").click(show_hide_privacy_options); | 212 | $("#article_published_true").click(show_hide_privacy_options); |
| 213 | $(".custom_privacy_option").click(show_hide_token_input); | 213 | $(".custom_privacy_option").click(show_hide_token_input); |
| 214 | 214 | ||
| 215 | + //Workaround to pointer-events:none CSS3 | ||
| 216 | + $('a.disabled').click(function(e){ | ||
| 217 | + e.preventDefault(); | ||
| 218 | + return false; | ||
| 219 | + }); | ||
| 220 | + | ||
| 215 | }); | 221 | }); |
public/stylesheets/cms.scss
| @@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
| 1 | +//Variables | ||
| 2 | +$icons-size: 24px; | ||
| 3 | +$warning-color: #e75e40; | ||
| 4 | +$description-color: #666; | ||
| 5 | +$access-types: public, private, archived; | ||
| 6 | + | ||
| 7 | +.text-warning { | ||
| 8 | + text-align: center; | ||
| 9 | + color: $warning-color; | ||
| 10 | + font: { | ||
| 11 | + size: 15px; | ||
| 12 | + weight: bold; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + p i.icon { | ||
| 16 | + display: inline-block; | ||
| 17 | + font-size: inherit; | ||
| 18 | + text-rendering: auto; | ||
| 19 | + background: url('images/icons-app/warning-icon.png'); | ||
| 20 | + vertical-align: middle; | ||
| 21 | + margin-top: -5px; | ||
| 22 | + width: $icons-size; | ||
| 23 | + height: $icons-size; | ||
| 24 | + border: none; | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +#edit-article-options { | ||
| 29 | + | ||
| 30 | + .access-itens .access-item { | ||
| 31 | + input,label { | ||
| 32 | + cursor: pointer; | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + .access-item { | ||
| 37 | + margin: 15px 0; | ||
| 38 | + label { | ||
| 39 | + font: { | ||
| 40 | + size: 13px; | ||
| 41 | + weight: bold; | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @each $access_type in $access-types { | ||
| 47 | + .access-#{$access_type}-icon, .access-#{$access_type}-icon { | ||
| 48 | + display: inline-block; | ||
| 49 | + margin-right: 5px; | ||
| 50 | + width: $icons-size; | ||
| 51 | + height: $icons-size; | ||
| 52 | + vertical-align: middle; | ||
| 53 | + background-image: url('images/icons-app/article-#{$access_type}-icon.png'); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + .access-note { | ||
| 58 | + display: block; | ||
| 59 | + margin: 0; | ||
| 60 | + color: $description-color; | ||
| 61 | + margin-left: 50px; | ||
| 62 | + font: { | ||
| 63 | + size: 12px; | ||
| 64 | + weight: normal; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | +} |
test/functional/cms_controller_test.rb
| @@ -697,6 +697,34 @@ class CmsControllerTest < ActionController::TestCase | @@ -697,6 +697,34 @@ class CmsControllerTest < ActionController::TestCase | ||
| 697 | end | 697 | end |
| 698 | end | 698 | end |
| 699 | 699 | ||
| 700 | + should "marks a article like archived" do | ||
| 701 | + article = create(Article, :profile => profile, :name => 'test', :published => true, :archived => false) | ||
| 702 | + | ||
| 703 | + post :edit, :profile => profile.identifier, :id => article.id, :article => {:archived => true} | ||
| 704 | + get :edit, :profile => profile.identifier, :id => article.id | ||
| 705 | + assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[archived]', :id => 'article_archived', :checked => 'checked' } | ||
| 706 | + | ||
| 707 | + end | ||
| 708 | + | ||
| 709 | + should "try add children into archived folders" do | ||
| 710 | + folder = create(Folder, :profile => profile, :name => 'test', :published => true, :archived => false) | ||
| 711 | + article_child = create(Article, :profile => profile, :name => 'test child', :parent_id => folder.id, :published => true, :archived => false) | ||
| 712 | + | ||
| 713 | + get :edit, :profile => profile.identifier, :id => folder.id | ||
| 714 | + assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[archived]', :id => 'article_archived' } | ||
| 715 | + | ||
| 716 | + post :edit, :profile => profile.identifier, :id => folder.id, :article => {:archived => true} | ||
| 717 | + | ||
| 718 | + get :edit, :profile => profile.identifier, :id => article_child.id | ||
| 719 | + assert_tag :tag => 'div', :attributes => { :class => 'text-warning'} | ||
| 720 | + | ||
| 721 | + err = assert_raises ActiveRecord::RecordInvalid do | ||
| 722 | + another_article_child = create(Article, :profile => profile, :name => 'other test child', :parent_id => folder.id, :published => true, :archived => false) | ||
| 723 | + end | ||
| 724 | + assert_match 'Parent folder is archived', err.message | ||
| 725 | + | ||
| 726 | + end | ||
| 727 | + | ||
| 700 | should 'be able to add image with alignment' do | 728 | should 'be able to add image with alignment' do |
| 701 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image <img src='#' align='right'/> right align..." } | 729 | post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'image-alignment', :body => "the text of the article with image <img src='#' align='right'/> right align..." } |
| 702 | saved = TinyMceArticle.find_by_name('image-alignment') | 730 | saved = TinyMceArticle.find_by_name('image-alignment') |
-
mentioned in commit a86306b1acc9b945fb1c5c33015724a1487b9fac