Commit 8307cfb7bad6190e840e8313de539d02ec539c86

Authored by Leandro Santos
2 parents 3c582887 f9687c15
Exists in staging and in 1 other branch production

merge with master

app/models/article.rb
... ... @@ -8,9 +8,8 @@ class Article < ActiveRecord::Base
8 8 :accept_comments, :feed, :published, :source, :source_name,
9 9 :highlighted, :notify_comments, :display_hits, :slug,
10 10 :external_feed_builder, :display_versions, :external_link,
11   - :image_builder, :show_to_followers,
12   - :author, :display_preview, :published_at, :person_followers,
13   - :archived
  11 + :image_builder, :show_to_followers, :archived,
  12 + :author, :display_preview, :published_at, :person_followers
14 13  
15 14 acts_as_having_image
16 15 include Noosfero::Plugin::HotSpot
... ...
app/models/comment.rb
... ... @@ -221,13 +221,13 @@ class Comment < ActiveRecord::Base
221 221 end
222 222  
223 223 def archived?
224   - self.article.archived? if self.article.present? && self.article.respond_to?(:archived?)
  224 + self.source && self.source.is_a?(Article) && self.source.archived?
225 225 end
226 226  
227 227 protected
228 228  
229 229 def article_archived?
230   - errors.add(:article, N_('associated with this comment is achived!')) if archived?
  230 + errors.add(:article, N_('associated with this comment is archived!')) if archived?
231 231 end
232 232  
233 233 end
... ...
app/views/content_viewer/view_page.html.erb
... ... @@ -85,7 +85,7 @@
85 85 <% end %>
86 86 </ul>
87 87  
88   - <% if !@page.archived? || @page.accept_comments? %>
  88 + <% if !@page.archived? && @page.accept_comments? %>
89 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 90 <% end %>
91 91 </div><!-- end class="comments" -->
... ...
plugins/vote/lib/ext/vote.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +require_dependency 'models/vote'
  2 +
  3 +class Vote
  4 +
  5 + validate :verify_target_archived
  6 +
  7 + def verify_target_archived
  8 +
  9 + if voteable.kind_of?(Article) || voteable.kind_of?(Comment)
  10 + if voteable.archived?
  11 + errors.add(:base, _("The target is achived and can't accept votes"))
  12 + false
  13 + end
  14 + end
  15 +
  16 + end
  17 +
  18 +end
... ...
public/javascripts/article.js
... ... @@ -206,4 +206,15 @@ jQuery(function($) {
206 206 return false;
207 207 });
208 208  
  209 + //Hide / Show the text area
  210 + $("#article_published_false").click(show_hide_privacy_options);
  211 + $("#article_published_true").click(show_hide_privacy_options);
  212 + $(".custom_privacy_option").click(show_hide_token_input);
  213 +
  214 + //Workaround to pointer-events:none CSS3
  215 + $('a.disabled').click(function(e){
  216 + e.preventDefault();
  217 + return false;
  218 + });
  219 +
209 220 });
... ...
test/unit/article_test.rb
... ... @@ -2232,27 +2232,6 @@ class ArticleTest &lt; ActiveSupport::TestCase
2232 2232 assert !a.display_preview?
2233 2233 end
2234 2234  
2235   - should 'check if a article is archived' do
2236   - folder = Folder.create!(:name => 'Parent Archived', :profile => profile)
2237   - a1 = Article.create!(:name => 'Test', :profile => profile, :parent_id => folder.id, :archived => false)
2238   - a2 = Article.create!(:name => 'Test 2', :profile => profile, :archived => true)
2239   - folder.update_attributes(:archived => true)
2240   - a1.reload
2241   -
2242   - assert a1.archived?
2243   - assert a2.archived?
2244   - end
2245   -
2246   - should 'try add a child article to a archived folder' do
2247   - folder = Folder.create!(:name => 'Parent Archived', :profile => profile, :archived => true)
2248   -
2249   - err = assert_raises ActiveRecord::RecordInvalid do
2250   - a1 = Article.create!(:name => 'Test', :profile => profile, :parent_id => folder.id, :archived => false)
2251   - end
2252   -
2253   - assert_match 'Parent folder is archived', err.message
2254   - end
2255   -
2256 2235 should 'return full_path' do
2257 2236 p1 = fast_create(Profile)
2258 2237 p2 = fast_create(Profile)
... ... @@ -2320,5 +2299,25 @@ class ArticleTest &lt; ActiveSupport::TestCase
2320 2299 assert_equal 10, article.reload.person_followers.count
2321 2300 end
2322 2301  
  2302 + should 'check if a article is archived' do
  2303 + folder = Folder.create!(:name => 'Parent Archived', :profile => profile)
  2304 + a1 = Article.create!(:name => 'Test', :profile => profile, :parent_id => folder.id, :archived => false)
  2305 + a2 = Article.create!(:name => 'Test 2', :profile => profile, :archived => true)
  2306 + folder.update_attributes(:archived => true)
  2307 + a1.reload
  2308 +
  2309 + assert a1.archived?
  2310 + assert a2.archived?
  2311 + end
  2312 +
  2313 + should 'try add a child article to a archived folder' do
  2314 + folder = Folder.create!(:name => 'Parent Archived', :profile => profile, :archived => true)
  2315 +
  2316 + err = assert_raises ActiveRecord::RecordInvalid do
  2317 + a1 = Article.create!(:name => 'Test', :profile => profile, :parent_id => folder.id, :archived => false)
  2318 + end
  2319 +
  2320 + assert_match 'Parent folder is archived', err.message
  2321 + end
2323 2322  
2324 2323 end
... ...
test/unit/comment_test.rb
... ... @@ -103,7 +103,7 @@ class CommentTest &lt; ActiveSupport::TestCase
103 103 comment = create(Comment, :source => article, :author_id => person.id)
104 104 end
105 105  
106   - assert_match 'Article associated with this comment is achived', err.message
  106 + assert_match 'Article associated with this comment is archived', err.message
107 107 end
108 108  
109 109 should 'provide author name for authenticated authors' do
... ...