From e42535bdf1b77a8f041714f8d657119db89cfd4a Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Fri, 4 Dec 2015 01:10:00 +0000 Subject: [PATCH] Software Communities plugin rating improvements --- src/noosfero-spb/noosfero-spb-theme/css/software-pages.css | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb | 2 +- src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb | 11 +++++++++++ src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb | 19 +++++++++++++++++++ src/noosfero-spb/software_communities/features/software_block.feature | 3 ++- src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/noosfero-spb/software_communities/lib/ext/application_helper.rb | 8 ++++++++ src/noosfero-spb/software_communities/lib/ext/community.rb | 2 +- src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb | 17 +++++++++++++++++ src/noosfero-spb/software_communities/lib/software_communities_plugin.rb | 32 ++++++++++++++++++++++++++++---- src/noosfero-spb/software_communities/lib/software_info.rb | 2 +- src/noosfero-spb/software_communities/lib/statistic_block.rb | 12 +++++++++++- src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb | 50 ++++++++++++++------------------------------------ src/noosfero-spb/software_communities/test/functional/search_controller_test.rb | 2 +- src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb | 2 +- src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb | 7 ++++--- src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/communities_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/database_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/database_validation_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/download_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/download_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/library_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/library_validation_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/repository_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/search_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_database_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_info_test.rb | 4 ++-- src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_language_validation.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_registration_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb | 2 +- src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb | 2 +- src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb | 41 ++++++++++++++++++++--------------------- src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb | 13 ++++++------- src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb | 10 ++++++++++ src/noosfero-spb/software_communities/views/organization_ratings_extra_fields_show_data.html.erb | 10 ---------- src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb | 10 ++++++++++ src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb | 4 ++-- 50 files changed, 434 insertions(+), 118 deletions(-) create mode 100644 src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb create mode 100644 src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb create mode 100644 src/noosfero-spb/software_communities/lib/ext/application_helper.rb create mode 100644 src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb create mode 100644 src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb create mode 100644 src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb delete mode 100644 src/noosfero-spb/software_communities/views/organization_ratings_extra_fields_show_data.html.erb create mode 100644 src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb diff --git a/src/noosfero-spb/noosfero-spb-theme/css/software-pages.css b/src/noosfero-spb/noosfero-spb-theme/css/software-pages.css index 91dd1c2..3a6d9a4 100644 --- a/src/noosfero-spb/noosfero-spb-theme/css/software-pages.css +++ b/src/noosfero-spb/noosfero-spb-theme/css/software-pages.css @@ -631,3 +631,106 @@ } /*** end fo software internal pages ***/ + +/*** organization-rating review page (tasks of software) ***/ + +.task-list .task_boxes{ + font-family: Arial; +} + +.task-list .task_boxes .task_box .task_date{ + position: absolute; + left: 80px; +} + +.task_boxes .task_box .task_title{ + position: absolute; + left: 80px; + font-weight: 500; + margin-top: 10px; +} + +.task_boxes .task_box .task_responsible{ + text-align: right; +} + +.task_boxes .task_box .task_responsible span select{ + padding: 4px 15px 1px 4px; +} + +.task_boxes .task_box .task_decisions{ + float: right; + padding-right: 5px; +} + +.task_boxes .task_box .task_information{ + margin-top: 40px; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-people-benefited{ + float: left; + font-weight: 900; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-saved-value{ + font-weight: 900; + margin-left: 160px; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations{ + margin-top: 10px; + margin-bottom: 10px; + border-bottom: 1px solid #CDCDCD; + padding-bottom: 15px; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-user-institution span span{ + font-weight: 900; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-people-benefited span{ + font-weight: 100; +} + +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-saved-value span{ + font-weight: 100; +} + +.task_boxes .task_box .organization-rating-comment-body .task-comment span{ + font-weight: 600; + color: rgb(140, 140, 140); + font-size: 11px; +} + +.task_boxes .task_box .organization-rating-comment-body .task-comment{ + margin-bottom: 15px; +} + +.task_boxes .task_box .organization-rating-comment-body .task-comment span p{ + font-weight: 100; + font-size: 12px; + color: black; + line-height: 16px; +} + +.task_boxes .task_box .organization-rating-comment-body .task-comment{ + line-height: 25px; +} + +.task_boxes .task_box .organization-rating-comment-body .rating-notice{ + display: block; + color: #F11467; + padding: 5px 5px; + background: #ccc; +} + +.task_boxes .task_box .organization-rating-comment-body .task-star-container{ + margin-bottom: 30px; + margin-top: 10px; +} + +.action-tasks-index .task_box{ + padding: 10px; +} + +/*** end of organization-rating review page (tasks of software) ***/ diff --git a/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb b/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb index 4873301..a2b3acb 100644 --- a/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb +++ b/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb @@ -144,7 +144,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController add_admin_to_community - if !environment.admins.include?(current_user.person) + if !user.is_admin? session[:notice] = _('Your new software request will be evaluated by an'\ 'administrator. You will be notified.') redirect_to user.admin_url diff --git a/src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb b/src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb new file mode 100644 index 0000000..26832f4 --- /dev/null +++ b/src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb @@ -0,0 +1,11 @@ +class AddStatisticsToSoftwareInfo < ActiveRecord::Migration + def up + add_column :software_infos, :benefited_people, :integer, :default => 0 + add_column :software_infos, :saved_resources, :decimal, :default => 0 + end + + def down + remove_column :software_infos, :benefited_people + remove_column :software_infos, :saved_resources + end +end diff --git a/src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb b/src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb new file mode 100644 index 0000000..6f36dd4 --- /dev/null +++ b/src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb @@ -0,0 +1,19 @@ +class MoveSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration + def up + benefited_people = 0 + saved_resources = 0 + + select_all("SELECT * FROM tasks WHERE status=3 AND type='CreateOrganizationRatingComment'").each do |task| + settings = YAML.load(task['data']) + organization_rating = select_one("SELECT * FROM organization_ratings WHERE id=#{settings[:organization_rating_id]}") + + benefited_people += organization_rating["people_benefited"].to_i + saved_resources += organization_rating["saved_value"].to_f + execute("UPDATE software_infos SET benefited_people=#{benefited_people}, saved_resources=#{saved_resources} WHERE software_infos.community_id=#{organization_rating["organization_id"]}") + end + end + + def down + execute("UPDATE software_infos SET benefited_people=0, saved_resources=0") + end +end diff --git a/src/noosfero-spb/software_communities/features/software_block.feature b/src/noosfero-spb/software_communities/features/software_block.feature index 1f8cf8b..ac511ca 100644 --- a/src/noosfero-spb/software_communities/features/software_block.feature +++ b/src/noosfero-spb/software_communities/features/software_block.feature @@ -25,6 +25,7 @@ Feature: edit adherent fields Scenario: Change software block to generic software block Given I am logged in as mpog_admin + And I go to /myprofile/mpog_admin And I follow "Control panel" And I follow "Edit sideboxes" When I follow "Add a block" @@ -45,4 +46,4 @@ Feature: edit adherent fields And I follow "Edit" within ".softwares-block" And I select "Public" from "block_software_type" And I press "Save" - Then I should see "public software" \ No newline at end of file + Then I should see "public software" diff --git a/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb b/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb index fc5c507..5f4801d 100644 --- a/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb +++ b/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb @@ -64,6 +64,53 @@ Given /^I type in "([^"]*)" in autocomplete list "([^"]*)" and I choose "([^"]*) sleep 1 end +Given /^Institutions has initial default values on database$/ do + GovernmentalPower.create(:name => "Executivo") + GovernmentalPower.create(:name => "Legislativo") + GovernmentalPower.create(:name => "Judiciario") + + GovernmentalSphere.create(:name => "Federal") + + JuridicalNature.create(:name => "Autarquia") + JuridicalNature.create(:name => "Administracao Direta") + JuridicalNature.create(:name => "Empresa Publica") + JuridicalNature.create(:name => "Fundacao") + JuridicalNature.create(:name => "Orgao Autonomo") + JuridicalNature.create(:name => "Sociedade") + JuridicalNature.create(:name => "Sociedade Civil") + JuridicalNature.create(:name => "Sociedade de Economia Mista") + + national_region = NationalRegion.new + national_region.name = "Distrito Federal" + national_region.national_region_code = '35' + national_region.national_region_type_id = NationalRegionType::STATE + national_region.save +end + +Given /^the following organization ratings$/ do |table| + table.hashes.each do |item| + person = User.where(login: item[:user_login]).first.person + organization = Organization.where(name: item[:organization_name]).first + + rating = OrganizationRating.new + rating.value = item[:value] + rating.organization_id = organization.id + rating.person_id = person.id + rating.saved_value = item[:saved_value] + rating.institution_id = Institution.where(name: item[:institution_name]).first.id + rating.save + + comment_task = CreateOrganizationRatingComment.create!( + :body => "empty comment", + :requestor => person, + :organization_rating_id => rating.id, + :target => organization) + + comment_task.status = item[:task_status] + comment_task.save + end +end + Given /^the following public institutions?$/ do |table| # table is a Cucumber::Ast::Table table.hashes.each do |item| @@ -247,3 +294,7 @@ end Then /^there should be (\d+) divs? with class "([^"]*)"$/ do |count, klass| should have_selector("div.#{klass}", :count => count) end + +Given /^I should see "([^"]*)" in the page/ do |message| + assert_match message, page.body +end diff --git a/src/noosfero-spb/software_communities/lib/ext/application_helper.rb b/src/noosfero-spb/software_communities/lib/ext/application_helper.rb new file mode 100644 index 0000000..76f429a --- /dev/null +++ b/src/noosfero-spb/software_communities/lib/ext/application_helper.rb @@ -0,0 +1,8 @@ +require_dependency "application_helper" + +ApplicationHelper.class_eval do + + def number_to_human(value) + number_with_delimiter(value, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter) + end +end diff --git a/src/noosfero-spb/software_communities/lib/ext/community.rb b/src/noosfero-spb/software_communities/lib/ext/community.rb index 6f8602f..80ef7e7 100644 --- a/src/noosfero-spb/software_communities/lib/ext/community.rb +++ b/src/noosfero-spb/software_communities/lib/ext/community.rb @@ -18,7 +18,7 @@ class Community community = Community.new(attributes) if community.environment.enabled?('admin_must_approve_new_communities') && - !community.environment.admins.include?(requestor) + !community.is_admin?(requestor) cc = CreateCommunity.create(attributes.merge(:requestor => requestor)) else diff --git a/src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb b/src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb new file mode 100644 index 0000000..954164c --- /dev/null +++ b/src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb @@ -0,0 +1,17 @@ +require_dependency "create_organization_rating_comment" + +CreateOrganizationRatingComment.class_eval do + after_save :update_software_statistic + + def update_software_statistic + if(self.status == Task::Status::FINISHED) + rating = OrganizationRating.find_by_id(self.organization_rating_id) + software = SoftwareInfo.find_by_community_id(self.target_id) + if software.present? and rating.present? + software.saved_resources += rating.saved_value if rating.saved_value + software.benefited_people += rating.people_benefited if rating.people_benefited + software.save + end + end + end +end diff --git a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb index 976ad14..a20d035 100644 --- a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb +++ b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb @@ -100,14 +100,38 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin Proc::new do "

#{title}

" end end - def organization_ratings_plugin_extra_fields_show_data user_rating + def organization_ratings_plugin_container_extra_fields user_rating Proc::new { if logged_in? - is_admin = environment.admins.include?(current_user.person) - is_admin ||= user_rating.organization.admins.include?(current_user.person) + is_admin = user.is_admin? || user_rating.organization.is_admin?(user) if is_admin and profile.software? - render :file => 'organization_ratings_extra_fields_show_data', + + render :file => 'organization_ratings_container_extra_fields_show_statistics', + :locals => {:user_rating => user_rating} + end + end + } + end + + def organization_ratings_plugin_rating_created rating, params + if params[:organization_rating].present? && (params[:organization_rating][:people_benefited].present? || + params[:organization_rating][:saved_value].present?) + CreateOrganizationRatingComment.create!( + :requestor => rating.person, + :organization_rating_id => rating.id, + :target => rating.organization) unless params[:comments] && params[:comments][:body].present? + end + end + + def organization_ratings_plugin_task_extra_fields user_rating + Proc::new { + if logged_in? + is_admin = user.is_admin? || user_rating.organization.is_admin?(user) + + if is_admin and profile.software? + + render :file => 'organization_ratings_task_extra_fields_show_statistics', :locals => {:user_rating => user_rating} end end diff --git a/src/noosfero-spb/software_communities/lib/software_info.rb b/src/noosfero-spb/software_communities/lib/software_info.rb index 73e8a32..99404c7 100644 --- a/src/noosfero-spb/software_communities/lib/software_info.rb +++ b/src/noosfero-spb/software_communities/lib/software_info.rb @@ -166,7 +166,7 @@ class SoftwareInfo < ActiveRecord::Base another_license_link = attributes.delete(:another_license_link) software_info = SoftwareInfo.new(attributes) - unless environment.admins.include? requestor + if !requestor.is_admin? CreateSoftware.create!( attributes.merge( :requestor => requestor, diff --git a/src/noosfero-spb/software_communities/lib/statistic_block.rb b/src/noosfero-spb/software_communities/lib/statistic_block.rb index fd45f4f..54648cf 100644 --- a/src/noosfero-spb/software_communities/lib/statistic_block.rb +++ b/src/noosfero-spb/software_communities/lib/statistic_block.rb @@ -20,13 +20,15 @@ class StatisticBlock < Block end block = self + statistics = get_software_statistics lambda do |object| render( :file => 'blocks/software_statistics', :locals => { :block => block, - :total_downloads => downloads.sum + :total_downloads => downloads.sum, + :statistics => statistics } ) end @@ -49,4 +51,12 @@ class StatisticBlock < Block downloads.select! {|value| not value.nil? } downloads.sum end + + def get_software_statistics + statistics = {} + software = SoftwareInfo.find_by_community_id(self.owner.id) + statistics[:saved_resources] = software.saved_resources + statistics[:benefited_people] = software.benefited_people + statistics + end end diff --git a/src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb new file mode 100644 index 0000000..51d43db --- /dev/null +++ b/src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb @@ -0,0 +1,85 @@ +require 'test_helper' +require 'organization_ratings_plugin_profile_controller' +require File.dirname(__FILE__) + '/../helpers/software_test_helper' + +# Re-raise errors caught by the controller. +class OrganizationRatingsPluginProfileController; def rescue_action(e) raise e end; end + +class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCase + include SoftwareTestHelper + + def setup + @controller = OrganizationRatingsPluginProfileController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + @environment = Environment.default + @environment.enabled_plugins = ['OrganizationRatingsPlugin'] + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] + @environment.save + + LicenseInfo.create(:version=>"CC-GPL-V2", + :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt") + + @person = create_user('testuser').person + @software = create_software(software_fields) + @statistic_block = StatisticBlock.new + @software.community.blocks << @statistic_block + @software.community.save! + + login_as(@person.identifier) + @controller.stubs(:logged_in?).returns(true) + @controller.stubs(:current_user).returns(@person.user) + end + + test "should create a task with a valid benefited people value and no comment" do + assert_difference 'CreateOrganizationRatingComment.count' do + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""}, + :organization_rating_value => 3, :organization_rating => {:people_benefited => 50} + end + end + + test "should create a task with a valid saved value and no comment" do + assert_difference 'CreateOrganizationRatingComment.count' do + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""}, + :organization_rating_value => 3, :organization_rating => {:saved_value => 50000000} + end + end + + test "should not create a task with no saved value or benefited poeple, and no comment" do + assert_no_difference 'CreateOrganizationRatingComment.count' do + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""}, + :organization_rating_value => 3, :organization_rating => nil + end + end + + test "software statistics should be updated when task is accepted" do + @software.reload + assert_equal 0, @software.benefited_people + assert_equal 0.0, @software.saved_resources + + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""}, + :organization_rating_value => 3, + :organization_rating => {:saved_value => 500, :people_benefited => 10} + + CreateOrganizationRatingComment.last.finish + @software.reload + assert_equal 10, @software.benefited_people + assert_equal 500.0, @software.saved_resources + end + + test "software statistics should not be updated when task is cancelled" do + @software.reload + assert_equal 0, @software.benefited_people + assert_equal 0.0, @software.saved_resources + + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""}, + :organization_rating_value => 3, + :organization_rating => {:saved_value => 500, :people_benefited => 10} + + CreateOrganizationRatingComment.last.cancel + @software.reload + assert_equal 0, @software.benefited_people + assert_equal 0.0, @software.saved_resources + end +end diff --git a/src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb index b677a1d..f1b1607 100644 --- a/src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb @@ -1,4 +1,5 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/software_test_helper' +require 'test_helper' require( File.dirname(__FILE__) + '/../../../../app/controllers/my_profile/profile_editor_controller' @@ -7,13 +8,18 @@ require( class ProfileEditorController; def rescue_action(e) raise e end; end class ProfileEditorControllerTest < ActionController::TestCase - + include SoftwareTestHelper def setup @controller = ProfileEditorController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @profile = create_user('default_user').person + LicenseInfo.create( + :version=>"CC-GPL-V2", + :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt" + ) + Environment.default.affiliate( @profile, [Environment::Roles.admin(Environment.default.id)] + @@ -29,42 +35,14 @@ class ProfileEditorControllerTest < ActionController::TestCase @environment.save end - should "redirect to edit_software_community on edit community of software" do - software = create_software_info("Test Software") + def teardown + Community.destroy_all + SoftwareInfo.destroy_all + end + should "redirect to edit_software_community on edit community of software" do + software = create_software(software_fields) post :edit, :profile => software.community.identifier - assert_redirected_to :controller => 'profile_editor', :action => 'edit_software_community' end - - - protected - - def create_basic_user - user = fast_create(User) - user.person = fast_create(Person) - user.person.user = user - user.save! - user.person.save! - user - end - - def create_community name - community = fast_create(Community) - community.name = name - community.save - community - end - - def create_software_info name, finality = "something", acronym = "" - community = create_community(name) - software_info = SoftwareInfo.new - software_info.community = community - software_info.finality = finality - software_info.acronym = acronym - software_info.public_software = true - software_info.save - software_info - end - end diff --git a/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb index 606337d..6406a50 100644 --- a/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' require( File.dirname(__FILE__) + diff --git a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb index 78ae2e0..75309f6 100644 --- a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin_controller' class SoftwareCommunitiesPluginController; def rescue_action(e) raise e end; end diff --git a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb index c37616b..2af30f8 100644 --- a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb @@ -1,7 +1,8 @@ require 'test_helper' -require_relative '../helpers/software_test_helper' -require_relative( - '../../controllers/software_communities_plugin_myprofile_controller' +require File.dirname(__FILE__) + '/../helpers/software_test_helper' +require( + File.dirname(__FILE__) + + '/../../controllers/software_communities_plugin_myprofile_controller' ) class SoftwareCommunitiesPluginMyprofileController; def rescue_action(e) raise e end; diff --git a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb index 00c715e..d6299e7 100644 --- a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/software_test_helper' require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin_profile_controller' diff --git a/src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb b/src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb index a7e0bef..92b2746 100644 --- a/src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class CategoriesAndTagsBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb b/src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb index b02f9b4..326c1cd 100644 --- a/src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class CategoriesSoftwareBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/communities_block_test.rb b/src/noosfero-spb/software_communities/test/unit/communities_block_test.rb index e10251b..0a92eb3 100644 --- a/src/noosfero-spb/software_communities/test/unit/communities_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/communities_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class CommunitiesBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/database_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/database_helper_test.rb index d7f2444..9e5e0a4 100644 --- a/src/noosfero-spb/software_communities/test/unit/database_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/database_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class DatabaseHelperTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/database_validation_test.rb b/src/noosfero-spb/software_communities/test/unit/database_validation_test.rb index 5466779..73502ce 100644 --- a/src/noosfero-spb/software_communities/test/unit/database_validation_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/database_validation_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class DatabaseValidationTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/download_block_test.rb b/src/noosfero-spb/software_communities/test/unit/download_block_test.rb index adfcdd3..d63280d 100644 --- a/src/noosfero-spb/software_communities/test/unit/download_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/download_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class DownloadBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/download_test.rb b/src/noosfero-spb/software_communities/test/unit/download_test.rb index 4b301fd..1c636f9 100644 --- a/src/noosfero-spb/software_communities/test/unit/download_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/download_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class DownloadTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/library_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/library_helper_test.rb index 28e58e3..888e4e4 100644 --- a/src/noosfero-spb/software_communities/test/unit/library_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/library_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class LibraryHelperTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/library_validation_test.rb b/src/noosfero-spb/software_communities/test/unit/library_validation_test.rb index f45cc9e..1ce6ea9 100644 --- a/src/noosfero-spb/software_communities/test/unit/library_validation_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/library_validation_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class LibraryValidationTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb index 8b2e506..ec6056b 100644 --- a/src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' OperatingSystemName.create(:name=>"Debina") OperatingSystemName.create(:name=>"Fedora") diff --git a/src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb b/src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb index 1f4a42b..df81bc1 100644 --- a/src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class OperatingSystemValidationTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/repository_block_test.rb b/src/noosfero-spb/software_communities/test/unit/repository_block_test.rb index 2580e79..f7fd9ab 100644 --- a/src/noosfero-spb/software_communities/test/unit/repository_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/repository_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class RepositoryBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb b/src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb index 64376ef..2d10c5d 100644 --- a/src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class SearchCatalogBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/search_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/search_helper_test.rb index f9a38f8..19cc29b 100644 --- a/src/noosfero-spb/software_communities/test/unit/search_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/search_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../../lib/ext/search_helper.rb' class SearchHelperTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb b/src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb index 3db9473..c12962d 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class GovUserPluginPersonTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_database_test.rb b/src/noosfero-spb/software_communities/test/unit/software_database_test.rb index c73a359..e6e01a4 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_database_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_database_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareDatabaseTest < ActiveSupport::TestCase def setup diff --git a/src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb b/src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb index e0403b0..fc9818f 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class SoftwareEventsBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/software_helper_test.rb index cddadea..6be6dff 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareHelperTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_info_test.rb b/src/noosfero-spb/software_communities/test/unit/software_info_test.rb index 930436c..1fa477a 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_info_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_info_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class SoftwareInfoValidationTest < ActiveSupport::TestCase @@ -41,4 +41,4 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase assert_equal @software_info.license_info.link, another_license_link end -end \ No newline at end of file +end diff --git a/src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb b/src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb index b5324a6..ae77da7 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareInfoValidationTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb b/src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb index 9465f91..991743e 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareLanguageHelperTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_language_validation.rb b/src/noosfero-spb/software_communities/test/unit/software_language_validation.rb index 8a1b21d..8a2e4a3 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_language_validation.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_language_validation.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareLanguageValidationTest < ActiveSupport::TestCase def setup diff --git a/src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb b/src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb index 81ab2ee..e5d099e 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareDatabaseTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_registration_test.rb b/src/noosfero-spb/software_communities/test/unit/software_registration_test.rb index 397adf7..afb787e 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_registration_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_registration_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' class SoftwareRegistrationTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb b/src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb index aad8c8c..b62a2a1 100644 --- a/src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class SoftwareTabDataBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb b/src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb index 44b5064..36dfbcd 100644 --- a/src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb +++ b/src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' +require 'test_helper' require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class SoftwaresBlockTest < ActiveSupport::TestCase diff --git a/src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb b/src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb index b9f1cd1..cf9dd75 100644 --- a/src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb +++ b/src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb @@ -1,36 +1,35 @@
- * <%= _("Data estimated by the software administrator.") %> + * <%= _("Data estimated by the software administrator.") %>
diff --git a/src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb b/src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb index 48037c8..a0a9b8a 100644 --- a/src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb +++ b/src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb @@ -1,10 +1,9 @@
- <% suggestion_benefited_people = @block.owner.organization_ratings.collect{ |r| r.people_benefited.to_f }.inject(:+) || 0.0 %> - <% suggestion_saved_resources = @block.owner.organization_ratings.collect{ |r| r.saved_value.to_f }.inject(:+) || 0.0 %> + <% benefited_people = @block.owner.software_info.benefited_people + 5 %> + <% saved_resources = @block.owner.software_info.saved_resources + 5 %> - <%= labelled_form_field _('Benefited People'), text_field(:block, :benefited_people) %> -

<%= _("Portal suggested value: ") %> <%= "%d" % (suggestion_benefited_people) %>

- <%= labelled_form_field _('Saved Resources'), text_field(:block, :saved_resources) %> -

<%= _("Portal suggested value: ") %> <%= "R$%.2f" % (suggestion_saved_resources) %>

-
+

<%= _("Statistics to be displayed ") %> +

<%= _("People Benefited: ") %> <%= number_to_human(benefited_people) %>

+

<%= _("Saved Resources: ") %> <%= float_to_currency(saved_resources) %>

+ diff --git a/src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb b/src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb new file mode 100644 index 0000000..497b402 --- /dev/null +++ b/src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb @@ -0,0 +1,10 @@ +
+
+ <%=_("Benefited People")%>: <%= number_with_delimiter(user_rating.people_benefited, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter) unless user_rating.nil? %> +
+ +
+ <%=_("Saved Resources")%>: <%= float_to_currency(user_rating.saved_value) unless user_rating.nil? %> +
+
+ diff --git a/src/noosfero-spb/software_communities/views/organization_ratings_extra_fields_show_data.html.erb b/src/noosfero-spb/software_communities/views/organization_ratings_extra_fields_show_data.html.erb deleted file mode 100644 index 497b402..0000000 --- a/src/noosfero-spb/software_communities/views/organization_ratings_extra_fields_show_data.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
-
- <%=_("Benefited People")%>: <%= number_with_delimiter(user_rating.people_benefited, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter) unless user_rating.nil? %> -
- -
- <%=_("Saved Resources")%>: <%= float_to_currency(user_rating.saved_value) unless user_rating.nil? %> -
-
- diff --git a/src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb b/src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb new file mode 100644 index 0000000..0e57615 --- /dev/null +++ b/src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb @@ -0,0 +1,10 @@ +
+
+ <%=_("Benefited People")%> : <%= user_rating.people_benefited unless user_rating.nil? %> +
+ +
+ <%=_("Saved Resources")%> : <%= user_rating.saved_value unless user_rating.nil? %> +
+
+ diff --git a/src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb b/src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb index 5c181b8..323f3e1 100644 --- a/src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb +++ b/src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb @@ -13,7 +13,7 @@ <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %> - <% if environment.admins.include?(user) %> + <% if user.is_admin? %>
<%= labelled_check_box(_('This profile is a template'), 'profile_data[is_template]', true, @profile.is_template) %>
@@ -78,7 +78,7 @@ <% if user && user.has_permission?('destroy_profile', profile) && !@first_edit %> <% button_bar(:id => 'delete-profile') do %> <%= button(:remove, _('Delete software and community'), {:action => :destroy_profile}) %> - <% if environment.admins.include?(current_person) %> + <% if user.is_admin? %> <% if profile.visible? %> <%= button(:remove, _('Deactivate software and community'), {:action => :deactivate_profile, :id=>profile.id}, :id=>'deactivate_profile_button', :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> <% else %> -- libgit2 0.21.2