Commit 06f96ca80964d78c07ec03cbbed14d2971c16040
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
fix conflit with add_members_community
Showing
6 changed files
with
58 additions
and
38 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -606,24 +606,14 @@ module ApplicationHelper |
| 606 | 606 | trigger_class = 'enterprise-trigger' |
| 607 | 607 | end |
| 608 | 608 | end |
| 609 | - | |
| 610 | - extra_info_tag = '' | |
| 611 | - img_class = 'profile-image' | |
| 612 | - | |
| 613 | - if extra_info.is_a? Hash | |
| 614 | - extra_info_tag = content_tag( 'span', extra_info[:value], :class => 'extra_info '+extra_info[:class]) | |
| 615 | - img_class +=' '+extra_info[:class] | |
| 616 | - else | |
| 617 | - extra_info_tag = content_tag( 'span', extra_info, :class => 'extra_info' ) | |
| 618 | - end | |
| 619 | - #extra_info = extra_info.nil? ? '' : content_tag( 'span', extra_info, :class => 'extra_info' ) | |
| 609 | + extra_info = extra_info.nil? ? '' : content_tag( 'span', extra_info, :class => 'extra_info' ) | |
| 620 | 610 | links = links_for_balloon(profile) |
| 621 | 611 | content_tag('div', content_tag(tag, |
| 622 | 612 | (environment.enabled?(:show_balloon_with_profile_links_when_clicked) ? popover_menu(_('Profile links'),profile.short_name,links,{:class => trigger_class, :url => url}) : "") + |
| 623 | 613 | link_to( |
| 624 | - content_tag( 'span', profile_image( profile, size ), :class => img_class ) + | |
| 614 | + content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + | |
| 625 | 615 | content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + |
| 626 | - extra_info_tag + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
| 616 | + extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
| 627 | 617 | profile.url, |
| 628 | 618 | :class => 'profile_link url', |
| 629 | 619 | :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, | ... | ... |
app/models/profile.rb
| ... | ... | @@ -735,6 +735,29 @@ private :generate_url, :url_options |
| 735 | 735 | end |
| 736 | 736 | end |
| 737 | 737 | |
| 738 | + # Adds many people to profile by id's | |
| 739 | + def add_members_by_id(people_ids) | |
| 740 | + | |
| 741 | + unless people_ids.nil? && people_ids.empty? | |
| 742 | + | |
| 743 | + people = Person.where(id: people_ids) | |
| 744 | + people.each do |person| | |
| 745 | + | |
| 746 | + add_member(person) unless person.is_member_of?(self) | |
| 747 | + end | |
| 748 | + end | |
| 749 | + end | |
| 750 | + | |
| 751 | + # Adds many people to profile by email's | |
| 752 | + def add_members_by_email(people_emails) | |
| 753 | + | |
| 754 | + people = User.where(email: people_emails) | |
| 755 | + people.each do |user| | |
| 756 | + | |
| 757 | + add_member(user.person) unless user.person.is_member_of?(self) | |
| 758 | + end | |
| 759 | + end | |
| 760 | + | |
| 738 | 761 | def remove_member(person) |
| 739 | 762 | self.disaffiliate(person, Profile::Roles.all_roles(environment.id)) |
| 740 | 763 | end | ... | ... |
lib/add_members_job.rb
| ... | ... | @@ -4,7 +4,12 @@ class AddMembersJob < Struct.new(:people_ids, :profile_id, :locale) |
| 4 | 4 | Noosfero.with_locale(locale) do |
| 5 | 5 | |
| 6 | 6 | profile = Profile.find(profile_id) |
| 7 | - profile.add_members people_ids | |
| 7 | + | |
| 8 | + if people_ids.first =~ /\@/ | |
| 9 | + profile.add_members_by_email people_ids | |
| 10 | + else | |
| 11 | + profile.add_members_by_id people_ids | |
| 12 | + end | |
| 8 | 13 | |
| 9 | 14 | end |
| 10 | 15 | end | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -2232,21 +2232,6 @@ a.button.disabled, input.disabled { |
| 2232 | 2232 | .profile-list .extra_info { |
| 2233 | 2233 | font-size: 9px; |
| 2234 | 2234 | } |
| 2235 | - | |
| 2236 | -/* New members of community added | |
| 2237 | -* by admin of environment feature | |
| 2238 | -* #issue 227 | |
| 2239 | -*/ | |
| 2240 | -.profile-list .extra_info.new-profile { | |
| 2241 | - margin-top: 5px; | |
| 2242 | - color: #0A0; | |
| 2243 | - font-weight: bold; | |
| 2244 | -} | |
| 2245 | - | |
| 2246 | -span.new-profile img{ | |
| 2247 | - border-top: solid 2px #0A0; | |
| 2248 | - margin-top: -2px; | |
| 2249 | -} | |
| 2250 | 2235 | /* ==> blocks/recent-documents-block.css <<= */ |
| 2251 | 2236 | |
| 2252 | 2237 | #content .recent-documents-block { | ... | ... |
test/functional/invite_controller_test.rb
| ... | ... | @@ -284,11 +284,6 @@ class InviteControllerTest < ActionController::TestCase |
| 284 | 284 | assert_empty json_response |
| 285 | 285 | end |
| 286 | 286 | |
| 287 | - #@todo Copy this test and create a another version | |
| 288 | - #of this, for test add members in a community | |
| 289 | - #logged as admin of environment! | |
| 290 | - # #issue227 | |
| 291 | - # | |
| 292 | 287 | should 'invite registered users through profile id' do |
| 293 | 288 | friend1 = create_user('testuser1').person |
| 294 | 289 | friend2 = create_user('testuser2').person |
| ... | ... | @@ -302,7 +297,7 @@ class InviteControllerTest < ActionController::TestCase |
| 302 | 297 | end |
| 303 | 298 | end |
| 304 | 299 | |
| 305 | - should 'add registered users imediatly instead invite if logged user is a environment admin' do | |
| 300 | + should 'add registered users by id imediatly instead invite if logged user is a environment admin' do | |
| 306 | 301 | |
| 307 | 302 | #Add user like a environment admin |
| 308 | 303 | Environment.default.add_admin profile |
| ... | ... | @@ -313,7 +308,29 @@ class InviteControllerTest < ActionController::TestCase |
| 313 | 308 | assert_difference 'Delayed::Job.count', 1 do |
| 314 | 309 | assert_equal 0,community.members.count |
| 315 | 310 | |
| 316 | - post :invite_registered_friend, :profile => @community.identifier, :q => [friend1.id,friend2.id] | |
| 311 | + post :invite_registered_friend, :profile => @community.identifier, :q => "#{friend1.id},#{friend2.id}" | |
| 312 | + | |
| 313 | + assert_response :redirect | |
| 314 | + assert_redirected_to :controller => 'profile', :action => 'members' | |
| 315 | + end | |
| 316 | + | |
| 317 | + Delayed::Worker.new.run(Delayed::Job.last) | |
| 318 | + | |
| 319 | + assert_equal 2,community.members.count | |
| 320 | + | |
| 321 | + end | |
| 322 | + | |
| 323 | + should 'add registered users by email imediatly instead invite if logged user is a environment admin' do | |
| 324 | + | |
| 325 | + Environment.default.add_admin profile | |
| 326 | + | |
| 327 | + friend1 = create_user('testuser1', {email: 'friend1@test.com.br'}) | |
| 328 | + friend2 = create_user('testuser2', {email: 'friend2@test.com.br'}) | |
| 329 | + | |
| 330 | + assert_difference 'Delayed::Job.count', 1 do | |
| 331 | + assert_equal 0,community.members.count | |
| 332 | + | |
| 333 | + post :invite_registered_friend, :profile => @community.identifier, :q => "#{friend1.email},#{friend2.email}" | |
| 317 | 334 | |
| 318 | 335 | assert_response :redirect |
| 319 | 336 | assert_redirected_to :controller => 'profile', :action => 'members' | ... | ... |
vendor/plugins/access_control/lib/acts_as_accessible.rb
| ... | ... | @@ -19,9 +19,9 @@ module ActsAsAccessible |
| 19 | 19 | nil |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | - def affiliate(accessor, roles) | |
| 22 | + def affiliate(accessor, roles, attributes = {}) | |
| 23 | 23 | roles = [roles] unless roles.kind_of?(Array) |
| 24 | - roles.map {|role| accessor.add_role(role, self)}.any? | |
| 24 | + roles.map {|role| accessor.add_role(role, self, attributes)}.any? | |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | def disaffiliate(accessor, roles) | ... | ... |