Commit 5fb09b518000b4a182de4f12d2bdb5366bff9de4
Exists in
master
and in
29 other branches
Merge branch 'stable'
Conflicts: po/pt/noosfero.po public/javascripts/application.js
Showing
22 changed files
with
144 additions
and
33 deletions
Show diff stats
app/controllers/admin/users_controller.rb
@@ -7,11 +7,12 @@ class UsersController < AdminController | @@ -7,11 +7,12 @@ class UsersController < AdminController | ||
7 | format.html | 7 | format.html |
8 | format.xml do | 8 | format.xml do |
9 | @users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) | 9 | @users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) |
10 | - render :xml => @users.to_xml( | ||
11 | - :skip_types => true, | ||
12 | - :only => %w[email login created_at updated_at], | ||
13 | - :include => { :person => {:only => %w[name updated_at created_at address birth_date contact_phone identifier lat lng] } } | ||
14 | - ) | 10 | + send_data @users.to_xml( |
11 | + :skip_types => true, | ||
12 | + :only => %w[email login created_at updated_at], | ||
13 | + :include => { :person => {:only => %w[name updated_at created_at address birth_date contact_phone identifier lat lng] } }), | ||
14 | + :type => 'text/xml', | ||
15 | + :disposition => "attachment; filename=users.xml" | ||
15 | end | 16 | end |
16 | format.csv do | 17 | format.csv do |
17 | @users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) | 18 | @users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) |
app/controllers/public/profile_controller.rb
@@ -212,9 +212,9 @@ class ProfileController < PublicController | @@ -212,9 +212,9 @@ class ProfileController < PublicController | ||
212 | begin | 212 | begin |
213 | scrap = current_user.person.scraps(params[:scrap_id]) | 213 | scrap = current_user.person.scraps(params[:scrap_id]) |
214 | scrap.destroy | 214 | scrap.destroy |
215 | - render :text => _('Scrap successfully removed.') | 215 | + finish_successful_removal 'Scrap successfully removed.' |
216 | rescue | 216 | rescue |
217 | - render :text => _('You could not remove this scrap') | 217 | + finish_unsuccessful_removal 'You could not remove this scrap.' |
218 | end | 218 | end |
219 | end | 219 | end |
220 | 220 | ||
@@ -227,9 +227,9 @@ class ProfileController < PublicController | @@ -227,9 +227,9 @@ class ProfileController < PublicController | ||
227 | else | 227 | else |
228 | activity.destroy | 228 | activity.destroy |
229 | end | 229 | end |
230 | - render :text => _('Activity successfully removed.') | 230 | + finish_successful_removal 'Activity successfully removed.' |
231 | rescue | 231 | rescue |
232 | - render :text => _('You could not remove this activity') | 232 | + finish_unsuccessful_removal 'You could not remove this activity.' |
233 | end | 233 | end |
234 | end | 234 | end |
235 | 235 | ||
@@ -244,6 +244,24 @@ class ProfileController < PublicController | @@ -244,6 +244,24 @@ class ProfileController < PublicController | ||
244 | end | 244 | end |
245 | end | 245 | end |
246 | 246 | ||
247 | + def finish_successful_removal(msg) | ||
248 | + if request.xhr? | ||
249 | + render :text => {'ok' => true}.to_json, :content_type => 'application/json' | ||
250 | + else | ||
251 | + session[:notice] = _(msg) | ||
252 | + redirect_to :action => :index | ||
253 | + end | ||
254 | + end | ||
255 | + | ||
256 | + def finish_unsuccessful_removal(msg) | ||
257 | + session[:notice] = _(msg) | ||
258 | + if request.xhr? | ||
259 | + render :text => {'redirect' => url_for(:action => :index)}.to_json, :content_type => 'application/json' | ||
260 | + else | ||
261 | + redirect_to :action => :index | ||
262 | + end | ||
263 | + end | ||
264 | + | ||
247 | def profile_info | 265 | def profile_info |
248 | begin | 266 | begin |
249 | @block = profile.blocks.find(params[:block_id]) | 267 | @block = profile.blocks.find(params[:block_id]) |
@@ -303,9 +321,10 @@ class ProfileController < PublicController | @@ -303,9 +321,10 @@ class ProfileController < PublicController | ||
303 | @comment = Comment.find(params[:comment_id]) | 321 | @comment = Comment.find(params[:comment_id]) |
304 | if (user == @comment.author || user == profile || user.has_permission?(:moderate_comments, profile)) | 322 | if (user == @comment.author || user == profile || user.has_permission?(:moderate_comments, profile)) |
305 | @comment.destroy | 323 | @comment.destroy |
306 | - session[:notice] = _('Comment successfully deleted') | 324 | + finish_successful_removal 'Comment successfully removed.' |
325 | + else | ||
326 | + finish_unsuccessful_removal 'You could not remove this comment.' | ||
307 | end | 327 | end |
308 | - redirect_to :action => :index | ||
309 | end | 328 | end |
310 | 329 | ||
311 | protected | 330 | protected |
app/helpers/search_helper.rb
@@ -50,7 +50,7 @@ module SearchHelper | @@ -50,7 +50,7 @@ module SearchHelper | ||
50 | end | 50 | end |
51 | 51 | ||
52 | def map_search? | 52 | def map_search? |
53 | - !@query.blank? and !multiple_search? and params[:display] == 'map' | 53 | + !@empty_query and !multiple_search? and params[:display] == 'map' |
54 | end | 54 | end |
55 | 55 | ||
56 | def search_page_title(title, category = nil) | 56 | def search_page_title(title, category = nil) |
@@ -107,7 +107,7 @@ module SearchHelper | @@ -107,7 +107,7 @@ module SearchHelper | ||
107 | @asset_class = asset_class(asset) | 107 | @asset_class = asset_class(asset) |
108 | render(:partial => 'facets_unselect_menu') | 108 | render(:partial => 'facets_unselect_menu') |
109 | end | 109 | end |
110 | - | 110 | + |
111 | def facet_javascript(input_id, facet, array) | 111 | def facet_javascript(input_id, facet, array) |
112 | array = [] if array.nil? | 112 | array = [] if array.nil? |
113 | hintText = _('Type in an option') | 113 | hintText = _('Type in an option') |
@@ -156,6 +156,7 @@ module SearchHelper | @@ -156,6 +156,7 @@ module SearchHelper | ||
156 | params = params.dup | 156 | params = params.dup |
157 | params[:facet].each do |id, value| | 157 | params[:facet].each do |id, value| |
158 | facet = klass.facet_by_id(id.to_sym) | 158 | facet = klass.facet_by_id(id.to_sym) |
159 | + next unless facet | ||
159 | if value.kind_of?(Hash) | 160 | if value.kind_of?(Hash) |
160 | label_hash = facet[:label].call(environment) | 161 | label_hash = facet[:label].call(environment) |
161 | value.each do |label_id, value| | 162 | value.each do |label_id, value| |
app/models/product.rb
1 | class Product < ActiveRecord::Base | 1 | class Product < ActiveRecord::Base |
2 | + | ||
2 | belongs_to :enterprise | 3 | belongs_to :enterprise |
3 | has_one :region, :through => :enterprise | 4 | has_one :region, :through => :enterprise |
4 | validates_presence_of :enterprise | 5 | validates_presence_of :enterprise |
@@ -163,7 +164,7 @@ class Product < ActiveRecord::Base | @@ -163,7 +164,7 @@ class Product < ActiveRecord::Base | ||
163 | 164 | ||
164 | def total_production_cost | 165 | def total_production_cost |
165 | return inputs_cost if price_details.empty? | 166 | return inputs_cost if price_details.empty? |
166 | - inputs_cost + price_details.map(&:price).inject { |sum,price| sum + price } | 167 | + inputs_cost + price_details.map(&:price).inject(0){ |sum,price| sum + price } |
167 | end | 168 | end |
168 | 169 | ||
169 | def price_described? | 170 | def price_described? |
app/models/uploaded_file.rb
@@ -67,7 +67,7 @@ class UploadedFile < Article | @@ -67,7 +67,7 @@ class UploadedFile < Article | ||
67 | 'upload-file' | 67 | 'upload-file' |
68 | end | 68 | end |
69 | end | 69 | end |
70 | - | 70 | + |
71 | def mime_type | 71 | def mime_type |
72 | content_type | 72 | content_type |
73 | end | 73 | end |
@@ -129,6 +129,12 @@ class UploadedFile < Article | @@ -129,6 +129,12 @@ class UploadedFile < Article | ||
129 | end | 129 | end |
130 | end | 130 | end |
131 | 131 | ||
132 | + def extension | ||
133 | + dotindex = self.filename.rindex('.') | ||
134 | + return nil unless dotindex | ||
135 | + self.filename[(dotindex+1)..-1].downcase | ||
136 | + end | ||
137 | + | ||
132 | def allow_children? | 138 | def allow_children? |
133 | false | 139 | false |
134 | end | 140 | end |
@@ -144,4 +150,5 @@ class UploadedFile < Article | @@ -144,4 +150,5 @@ class UploadedFile < Article | ||
144 | def uploaded_file? | 150 | def uploaded_file? |
145 | true | 151 | true |
146 | end | 152 | end |
153 | + | ||
147 | end | 154 | end |
app/views/friends/index.rhtml
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | :class => 'button icon-remove', | 31 | :class => 'button icon-remove', |
32 | :title => _('remove') %> | 32 | :title => _('remove') %> |
33 | <%= link_to content_tag('span',_('contact')), | 33 | <%= link_to content_tag('span',_('contact')), |
34 | - friend.url.merge(:controller => 'contact', :action => 'new'), | 34 | + friend.url.merge(:controller => 'contact', :action => 'new', :profile => friend.identifier), |
35 | :class => 'button icon-menu-mail', | 35 | :class => 'button icon-menu-mail', |
36 | :title => _('contact') %> | 36 | :title => _('contact') %> |
37 | </div><!-- end class="controll" --> | 37 | </div><!-- end class="controll" --> |
app/views/profile/_comment.rhtml
@@ -5,19 +5,35 @@ | @@ -5,19 +5,35 @@ | ||
5 | <li class="article-comment" style='border-bottom:none;'> | 5 | <li class="article-comment" style='border-bottom:none;'> |
6 | <div class="article-comment-inner"> | 6 | <div class="article-comment-inner"> |
7 | 7 | ||
8 | - <div class="comment-content comment-logged-in"> | 8 | + <div class="comment-content comment-logged-<%= comment.author ? 'in' : 'out' %>"> |
9 | 9 | ||
10 | <% if comment.author %> | 10 | <% if comment.author %> |
11 | <%= link_to image_tag(profile_icon(comment.author, :minor)), | 11 | <%= link_to image_tag(profile_icon(comment.author, :minor)), |
12 | - Person.find(comment.author_id).url, | 12 | + comment.author_url, |
13 | :class => 'comment-picture', | 13 | :class => 'comment-picture', |
14 | :title => comment.author_name | 14 | :title => comment.author_name |
15 | %> | 15 | %> |
16 | + <% else %> | ||
17 | + <% url_image, status_class = comment.author_id ? | ||
18 | + [comment.removed_user_image, 'icon-user-removed'] : | ||
19 | + [str_gravatar_url_for( comment.email ), 'icon-user-unknown'] %> | ||
20 | + | ||
21 | + <%= link_to( | ||
22 | + image_tag(url_image, :onerror=>'gravatarCommentFailback(this)', | ||
23 | + 'data-gravatar'=>str_gravatar_url_for(comment.email)) + | ||
24 | + content_tag('span', comment.author_name, :class => 'comment-info') + | ||
25 | + content_tag('span', comment.message, | ||
26 | + :class => 'comment-user-status comment-user-status-wall ' + status_class), | ||
27 | + gravatar_profile_url(comment.email), | ||
28 | + :target => '_blank', | ||
29 | + :class => 'comment-picture', | ||
30 | + :title => '%s %s' % [comment.author_name, comment.message] | ||
31 | + )%> | ||
16 | <% end %> | 32 | <% end %> |
17 | 33 | ||
18 | <div class="comment-details"> | 34 | <div class="comment-details"> |
19 | <div class="comment-text"> | 35 | <div class="comment-text"> |
20 | - <%= link_to(comment.author_name, comment.author.url) %> | 36 | + <%= comment.author.present? ? link_to(comment.author_name, comment.author.url) : content_tag('strong', comment.author_name) %> |
21 | <% unless comment.title.blank? %> | 37 | <% unless comment.title.blank? %> |
22 | <span class="comment-title"><%= comment.title %></span><br/> | 38 | <span class="comment-title"><%= comment.title %></span><br/> |
23 | <% end %> | 39 | <% end %> |
@@ -30,7 +46,7 @@ | @@ -30,7 +46,7 @@ | ||
30 | 46 | ||
31 | <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %> | 47 | <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %> |
32 | <% button_bar(:style => 'float: right; margin-top: 0px;') do %> | 48 | <% button_bar(:style => 'float: right; margin-top: 0px;') do %> |
33 | - <%= icon_button(:delete, _('Remove'), { :action => :remove_comment, :comment_id => comment.id }, :method => :get, :confirm => _('Are you sure you want to remove this comment and all its replies?')) %> | 49 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.article-comment'", url_for(:profile => params[:profile], :action => :remove_comment, :comment_id => comment.id, :view => params[:view]).to_json, _('Are you sure you want to remove this comment and all its replies?').to_json], :class => 'button icon-button icon-delete') %> |
34 | <% end %> | 50 | <% end %> |
35 | <% end %> | 51 | <% end %> |
36 | <br style="clear: both;" /> | 52 | <br style="clear: both;" /> |
app/views/profile/_create_article.rhtml
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> | 15 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
16 | <div class='profile-wall-actions'> | 16 | <div class='profile-wall-actions'> |
17 | <%= link_to s_('profile|Comment'), '#', { :class => 'focus-on-comment'} %> | 17 | <%= link_to s_('profile|Comment'), '#', { :class => 'focus-on-comment'} %> |
18 | - <%= link_to_remote(content_tag(:span, _('Remove')), :url =>{:action => 'remove_activity', :activity_id => activity.id, :only_hide => true}, :confirm => _('Are you sure?'), :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> | 18 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.profile-activity-item'", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :only_hide => true, :view => params[:view]).to_json, _('Are you sure you want to remove this activity and all its replies?').to_json]) if logged_in? && current_person == @profile %> |
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | 21 |
app/views/profile/_default_activity.rhtml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> | 6 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
7 | <div class='profile-wall-actions'> | 7 | <div class='profile-wall-actions'> |
8 | <%= link_to s_('profile|Comment'), '#', { :class => 'focus-on-comment'} %> | 8 | <%= link_to s_('profile|Comment'), '#', { :class => 'focus-on-comment'} %> |
9 | - <%= link_to_remote(content_tag(:span, _('Remove')), :confirm => _('Are you sure?'), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> | 9 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.profile-activity-item'", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]).to_json, _('Are you sure you want to remove this activity and all its replies?').to_json]) if logged_in? && current_person == @profile %> |
10 | </div> | 10 | </div> |
11 | </div> | 11 | </div> |
12 | 12 |
app/views/profile/_leave_scrap.rhtml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> | 5 | <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> |
6 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> | 6 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
7 | <div class='profile-wall-actions'> | 7 | <div class='profile-wall-actions'> |
8 | - <%= link_to_remote(content_tag(:span, _('Remove')), :confirm => _('Are you sure?'), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> | 8 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.profile-activity-item'", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]).to_json, _('Are you sure you want to remove this activity and all its replies?').to_json]) if logged_in? && current_person == @profile %> |
9 | </div> | 9 | </div> |
10 | </div> | 10 | </div> |
11 | 11 |
app/views/profile/_profile_scrap.rhtml
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | <%= link_to_function s_('profile|Comment'), "hide_and_show(['#profile-wall-message-response-#{scrap.id}'],['#profile-wall-reply-#{scrap.id}', '#profile-wall-reply-form-#{scrap.id}']);$('reply_content_#{scrap.id}').value='';$('reply_content_#{scrap.id}').focus();return false", :class => "profile-send-reply" %> | 12 | <%= link_to_function s_('profile|Comment'), "hide_and_show(['#profile-wall-message-response-#{scrap.id}'],['#profile-wall-reply-#{scrap.id}', '#profile-wall-reply-form-#{scrap.id}']);$('reply_content_#{scrap.id}').value='';$('reply_content_#{scrap.id}').focus();return false", :class => "profile-send-reply" %> |
13 | </span> | 13 | </span> |
14 | <% end %> | 14 | <% end %> |
15 | - <%= link_to_remote(content_tag(:span, _('Remove')), :confirm => _('Are you sure?'), :url =>{:action => 'remove_scrap', :scrap_id => scrap.id}, :update => "profile-activity-item-#{scrap.id}") if logged_in? && user.can_control_scrap?(scrap) %> | 15 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.profile-activity-item'", url_for(:profile => params[:profile], :action => :remove_scrap, :scrap_id => scrap.id, :view => params[:view]).to_json, _('Are you sure you want to remove this scrap and all its replies?').to_json]) if logged_in? && user.can_control_scrap?(scrap) %> |
16 | </div> | 16 | </div> |
17 | </div> | 17 | </div> |
18 | 18 |
app/views/profile/_upload_image.rhtml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> | 6 | <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> |
7 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> | 7 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
8 | <div class='profile-wall-actions'> | 8 | <div class='profile-wall-actions'> |
9 | - <%= link_to_remote(content_tag(:span, _('Remove')), :confirm => _('Are you sure?'), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> | 9 | + <%= link_to_function(_('Remove'), 'remove_item_wall(this, %s, %s, %s); return false ;' % ["'.profile-activity-item'", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]).to_json, _('Are you sure you want to remove this activity and all its replies?').to_json]) if logged_in? && current_person == @profile %> |
10 | </div> | 10 | </div> |
11 | </div> | 11 | </div> |
12 | </div> | 12 | </div> |
app/views/search/_image.rhtml
1 | <div class="search-image-container"> | 1 | <div class="search-image-container"> |
2 | 2 | ||
3 | <% if image.is_a? UploadedFile and image.filename %> | 3 | <% if image.is_a? UploadedFile and image.filename %> |
4 | - <% extension = image.filename[(image.filename.rindex('.')+1)..-1].downcase %> | 4 | + <% extension = image.extension %> |
5 | <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %> | 5 | <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %> |
6 | <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %> | 6 | <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %> |
7 | <% if image.width && image.height %> | 7 | <% if image.width && image.height %> |
app/views/search/communities.rhtml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <% if logged_in? %> | 4 | <% if logged_in? %> |
5 | <% button_bar do %> | 5 | <% button_bar do %> |
6 | <%# FIXME shouldn't the user create the community in the current environment instead of going to its home environment? %> | 6 | <%# FIXME shouldn't the user create the community in the current environment instead of going to its home environment? %> |
7 | - <%= button(:add, __('New community'), user.url.merge(:controller => 'memberships', :action => 'new_community')) %> | 7 | + <%= button(:add, __('New community'), user.url.merge(:controller => 'memberships', :action => 'new_community', :profile => user.identifier)) %> |
8 | <% end %> | 8 | <% end %> |
9 | <% end %> | 9 | <% end %> |
10 | 10 |
lib/acts_as_faceted.rb
@@ -8,7 +8,7 @@ module ActsAsFaceted | @@ -8,7 +8,7 @@ module ActsAsFaceted | ||
8 | # | 8 | # |
9 | #acts_as_faceted :fields => { | 9 | #acts_as_faceted :fields => { |
10 | # :f_type => {:label => _('Type'), :proc => proc{|klass| f_type_proc(klass)}}, | 10 | # :f_type => {:label => _('Type'), :proc => proc{|klass| f_type_proc(klass)}}, |
11 | - # :f_published_at => {:type => :date, :label => _('Published date'), :queries => {'[* TO NOW-1YEARS/DAY]' => _("Older than one year"), | 11 | + # :f_published_at => {:type => :date, :label => _('Published date'), :queries => {'[* TO NOW-1YEARS/DAY]' => _("Older than one year"), |
12 | # '[NOW-1YEARS TO NOW/DAY]' => _("Last year"), '[NOW-1MONTHS TO NOW/DAY]' => _("Last month"), '[NOW-7DAYS TO NOW/DAY]' => _("Last week"), '[NOW-1DAYS TO NOW/DAY]' => _("Last day")}}, | 12 | # '[NOW-1YEARS TO NOW/DAY]' => _("Last year"), '[NOW-1MONTHS TO NOW/DAY]' => _("Last month"), '[NOW-7DAYS TO NOW/DAY]' => _("Last week"), '[NOW-1DAYS TO NOW/DAY]' => _("Last day")}}, |
13 | # :f_profile_type => {:label => _('Author'), :proc => proc{|klass| f_profile_type_proc(klass)}}, | 13 | # :f_profile_type => {:label => _('Author'), :proc => proc{|klass| f_profile_type_proc(klass)}}, |
14 | # :f_category => {:label => _('Categories')}}, | 14 | # :f_category => {:label => _('Categories')}}, |
@@ -36,7 +36,7 @@ module ActsAsFaceted | @@ -36,7 +36,7 @@ module ActsAsFaceted | ||
36 | self.facets_order = options[:order] || self.facets.keys | 36 | self.facets_order = options[:order] || self.facets.keys |
37 | self.facets_results_containers = {:fields => 'facet_fields', :queries => 'facet_queries', :ranges => 'facet_ranges'} | 37 | self.facets_results_containers = {:fields => 'facet_fields', :queries => 'facet_queries', :ranges => 'facet_ranges'} |
38 | self.facets_option_for_solr = Hash[facets.select{ |id,data| ! data.has_key?(:queries) }].keys | 38 | self.facets_option_for_solr = Hash[facets.select{ |id,data| ! data.has_key?(:queries) }].keys |
39 | - self.facets_fields_for_solr = facets.map{ |id,data| {id => data[:type] || :facet} } | 39 | + self.facets_fields_for_solr = facets.map{ |id,data| {id => data[:type] || :facet} } |
40 | self.solr_fields_names = facets.map{ |id,data| id.to_s + '_' + get_solr_field_type(data[:type] || :facet) } | 40 | self.solr_fields_names = facets.map{ |id,data| id.to_s + '_' + get_solr_field_type(data[:type] || :facet) } |
41 | self.facet_category_query = options[:category_query] | 41 | self.facet_category_query = options[:category_query] |
42 | 42 | ||
@@ -67,6 +67,7 @@ module ActsAsFaceted | @@ -67,6 +67,7 @@ module ActsAsFaceted | ||
67 | raise 'Use map_facets_for before this method' if facet[:solr_field].nil? | 67 | raise 'Use map_facets_for before this method' if facet[:solr_field].nil? |
68 | facets_data = {} if facets_data.blank? # could be empty array | 68 | facets_data = {} if facets_data.blank? # could be empty array |
69 | solr_facet = to_solr_fields_names[facet[:solr_field]] | 69 | solr_facet = to_solr_fields_names[facet[:solr_field]] |
70 | + unfiltered_facets_data ||= {} | ||
70 | 71 | ||
71 | if facet[:queries] | 72 | if facet[:queries] |
72 | container = facets_data[facets_results_containers[:queries]] | 73 | container = facets_data[facets_results_containers[:queries]] |
@@ -158,13 +159,15 @@ module ActsAsFaceted | @@ -158,13 +159,15 @@ module ActsAsFaceted | ||
158 | end | 159 | end |
159 | 160 | ||
160 | def facet_label(facet) | 161 | def facet_label(facet) |
161 | - _ facet[:label] | 162 | + return nil unless facet |
163 | + _(facet[:label]) | ||
162 | end | 164 | end |
163 | 165 | ||
164 | def facets_find_options(facets_selected = {}, options = {}) | 166 | def facets_find_options(facets_selected = {}, options = {}) |
165 | browses = [] | 167 | browses = [] |
166 | facets_selected ||= {} | 168 | facets_selected ||= {} |
167 | facets_selected.map do |id, value| | 169 | facets_selected.map do |id, value| |
170 | + next unless facets[id.to_sym] | ||
168 | if value.kind_of?(Hash) | 171 | if value.kind_of?(Hash) |
169 | value.map do |label_id, value| | 172 | value.map do |label_id, value| |
170 | value.to_a.each do |value| | 173 | value.to_a.each do |value| |
lib/tasks/data.rake
@@ -3,7 +3,7 @@ namespace :db do | @@ -3,7 +3,7 @@ namespace :db do | ||
3 | task :minimal do | 3 | task :minimal do |
4 | sh './script/runner', "Environment.create!(:name => 'Noosfero', :is_default => true)" | 4 | sh './script/runner', "Environment.create!(:name => 'Noosfero', :is_default => true)" |
5 | unless ENV['NOOSFERO_DOMAIN'].blank? | 5 | unless ENV['NOOSFERO_DOMAIN'].blank? |
6 | - sh './script/runner', "environment.domains << Domain.new(:name => ENV['NOOSFERO_DOMAIN'])" | 6 | + sh './script/runner', "Environment.default.domains << Domain.new(:name => ENV['NOOSFERO_DOMAIN'])" |
7 | end | 7 | end |
8 | end | 8 | end |
9 | end | 9 | end |
po/pt/noosfero.po
@@ -14,7 +14,7 @@ msgid "" | @@ -14,7 +14,7 @@ msgid "" | ||
14 | msgstr "" | 14 | msgstr "" |
15 | "Project-Id-Version: noosfero 0.38.0\n" | 15 | "Project-Id-Version: noosfero 0.38.0\n" |
16 | "POT-Creation-Date: 2012-08-09 10:45-0300\n" | 16 | "POT-Creation-Date: 2012-08-09 10:45-0300\n" |
17 | -"PO-Revision-Date: 2012-08-09 11:10-0300\n" | 17 | +"PO-Revision-Date: 2012-10-01 01:32-0300\n" |
18 | "Last-Translator: Joenio Costa <joenio@colivre.coop.br>\n" | 18 | "Last-Translator: Joenio Costa <joenio@colivre.coop.br>\n" |
19 | "Language-Team: LANGUAGE TEAM <E-MAIL@ADDRESS or HOME PAGE>\n" | 19 | "Language-Team: LANGUAGE TEAM <E-MAIL@ADDRESS or HOME PAGE>\n" |
20 | "Language: \n" | 20 | "Language: \n" |
@@ -5915,7 +5915,13 @@ msgstr "Remover" | @@ -5915,7 +5915,13 @@ msgstr "Remover" | ||
5915 | #: app/views/profile/_default_activity.rhtml:9 | 5915 | #: app/views/profile/_default_activity.rhtml:9 |
5916 | #: app/views/profile/_leave_scrap_to_self.rhtml:8 | 5916 | #: app/views/profile/_leave_scrap_to_self.rhtml:8 |
5917 | #: app/views/profile/_upload_image.rhtml:9 | 5917 | #: app/views/profile/_upload_image.rhtml:9 |
5918 | +msgid "Are you sure you want to remove this activity and all its replies?" | ||
5919 | +msgstr "Você tem certeza que quer remover esta atividade e todas as suas respostas?" | ||
5920 | + | ||
5918 | #: app/views/profile/_profile_scrap.rhtml:15 | 5921 | #: app/views/profile/_profile_scrap.rhtml:15 |
5922 | +msgid "Are you sure you want to remove this scrap and all its replies?" | ||
5923 | +msgstr "Você tem certeza que quer remover esta mensagem e todas as suas respostas?" | ||
5924 | + | ||
5919 | #: plugins/bsc/views/bsc_plugin_myprofile/manage_contracts.html.erb:35 | 5925 | #: plugins/bsc/views/bsc_plugin_myprofile/manage_contracts.html.erb:35 |
5920 | msgid "Are you sure?" | 5926 | msgid "Are you sure?" |
5921 | msgstr "Você tem certeza?" | 5927 | msgstr "Você tem certeza?" |
public/javascripts/application.js
@@ -710,6 +710,24 @@ function remove_comment(button, url, msg) { | @@ -710,6 +710,24 @@ function remove_comment(button, url, msg) { | ||
710 | }); | 710 | }); |
711 | } | 711 | } |
712 | 712 | ||
713 | +function remove_item_wall(button, item, url, msg) { | ||
714 | + var $ = jQuery; | ||
715 | + var $wall_item = $(button).closest(item); | ||
716 | + $wall_item.addClass('remove-item-loading'); | ||
717 | + if (msg && !confirm(msg)) { | ||
718 | + $wall_item.removeClass('remove-item-loading'); | ||
719 | + return; | ||
720 | + } | ||
721 | + $.post(url, function(data) { | ||
722 | + if (data.ok) { | ||
723 | + $wall_item.slideUp(); | ||
724 | + } else { | ||
725 | + $wall_item.removeClass('remove-item-loading'); | ||
726 | + window.location.replace(data.redirect); | ||
727 | + } | ||
728 | + }); | ||
729 | +} | ||
730 | + | ||
713 | function original_image_dimensions(src) { | 731 | function original_image_dimensions(src) { |
714 | var img = new Image(); | 732 | var img = new Image(); |
715 | img.src = src; | 733 | img.src = src; |
public/stylesheets/application.css
@@ -460,6 +460,8 @@ div.pending-tasks { | @@ -460,6 +460,8 @@ div.pending-tasks { | ||
460 | .headline img { | 460 | .headline img { |
461 | float:left; | 461 | float:left; |
462 | margin: 5px; | 462 | margin: 5px; |
463 | + max-width: 100%; | ||
464 | + height: auto; | ||
463 | } | 465 | } |
464 | .news-area { | 466 | .news-area { |
465 | border: 1px solid black; | 467 | border: 1px solid black; |
@@ -1098,6 +1100,10 @@ a.comment-picture { | @@ -1098,6 +1100,10 @@ a.comment-picture { | ||
1098 | left: 33px; | 1100 | left: 33px; |
1099 | background-repeat: no-repeat; | 1101 | background-repeat: no-repeat; |
1100 | } | 1102 | } |
1103 | +.comment-user-status-wall { | ||
1104 | + top: 16px; | ||
1105 | + left: 16px; | ||
1106 | +} | ||
1101 | #article .article-comments-list, #article .article-comments-list ul, #article .article-comments-list li { | 1107 | #article .article-comments-list, #article .article-comments-list ul, #article .article-comments-list li { |
1102 | padding: 0; | 1108 | padding: 0; |
1103 | margin: 0; | 1109 | margin: 0; |
@@ -4802,6 +4808,10 @@ h1#agenda-title { | @@ -4802,6 +4808,10 @@ h1#agenda-title { | ||
4802 | color: #000; | 4808 | color: #000; |
4803 | } | 4809 | } |
4804 | 4810 | ||
4811 | +.remove-item-loading { | ||
4812 | + background: transparent url(../images/loading-small.gif) no-repeat left center !important; | ||
4813 | +} | ||
4814 | + | ||
4805 | li.profile-activity-item.upload_image .more, | 4815 | li.profile-activity-item.upload_image .more, |
4806 | li.profile-activity-item.upload_image .upimg { | 4816 | li.profile-activity-item.upload_image .upimg { |
4807 | display: block; | 4817 | display: block; |
test/functional/profile_controller_test.rb
@@ -1300,4 +1300,28 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1300,4 +1300,28 @@ class ProfileControllerTest < ActionController::TestCase | ||
1300 | assert_response :success | 1300 | assert_response :success |
1301 | assert_equal "Comment successfully added.", assigns(:message) | 1301 | assert_equal "Comment successfully added.", assigns(:message) |
1302 | end | 1302 | end |
1303 | + | ||
1304 | + should 'display comment in wall if user was removed' do | ||
1305 | + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | ||
1306 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | ||
1307 | + to_be_removed = create_user('removed_user').person | ||
1308 | + comment = Comment.create!(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | ||
1309 | + to_be_removed.destroy | ||
1310 | + | ||
1311 | + login_as(profile.identifier) | ||
1312 | + get :index, :profile => profile.identifier | ||
1313 | + | ||
1314 | + assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} | ||
1315 | + end | ||
1316 | + | ||
1317 | + should 'display comment in wall from non logged users' do | ||
1318 | + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | ||
1319 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | ||
1320 | + comment = Comment.create!(:name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | ||
1321 | + | ||
1322 | + login_as(profile.identifier) | ||
1323 | + get :index, :profile => profile.identifier | ||
1324 | + | ||
1325 | + assert_tag :tag => 'span', :content => '(unauthenticated user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-unknown'} | ||
1326 | + end | ||
1303 | end | 1327 | end |
test/functional/users_controller_test.rb
@@ -33,7 +33,7 @@ class UsersControllerTest < ActionController::TestCase | @@ -33,7 +33,7 @@ class UsersControllerTest < ActionController::TestCase | ||
33 | login_as('admin_user') | 33 | login_as('admin_user') |
34 | 34 | ||
35 | get :index, :format => 'xml' | 35 | get :index, :format => 'xml' |
36 | - assert_equal 'application/xml', @response.content_type | 36 | + assert_equal 'text/xml', @response.content_type |
37 | end | 37 | end |
38 | 38 | ||
39 | should 'response as CSV to export users' do | 39 | should 'response as CSV to export users' do |
test/unit/uploaded_file_test.rb
@@ -306,6 +306,11 @@ class UploadedFileTest < ActiveSupport::TestCase | @@ -306,6 +306,11 @@ class UploadedFileTest < ActiveSupport::TestCase | ||
306 | uses_sqlite | 306 | uses_sqlite |
307 | end | 307 | end |
308 | 308 | ||
309 | + should 'return extension' do | ||
310 | + file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => @profile) | ||
311 | + assert_equal 'png', file.extension | ||
312 | + end | ||
313 | + | ||
309 | should 'upload to path prefix folder if database is not postgresql' do | 314 | should 'upload to path prefix folder if database is not postgresql' do |
310 | uses_sqlite | 315 | uses_sqlite |
311 | file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => @profile) | 316 | file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => @profile) |