Merge Request #84

Merged
softwarepublico/softwarepublico!84
Created by Gabriel Silva

Software Community and Gov User improvements

Improvements on Organiation Ratings plugin (related to gov_user and software_communities)

  • Move software statistics from blocks table to softwares table
  • Update methods called on view to display software statistics
  • Software now automagically sums saved_resources and benefited people when the task is accepted
  • Adds message to warn that a rating has an institution with active ratings
  • Adds one hotspot to insert content on ratings task and another one to ratings container (used on ratings page and ratings block)
  • Removes statistic block fields that are no longer used
  • Adds number_to_human method to get better visualization for numbers
  • Makes the software tasks page closer to the prototype (changes in the divs, sizes and aligns).
  • Fixed broken tests on software_profile_editor_controller
Assignee: Daniela Feitosa
Milestone: None

Merged by Daniela Feitosa

Source branch has been removed
Commits (3)
  • Dylan Guedes
     
  • - Adds message to warn that a rating has an institution with active ratings
    - Adds one hotspot to insert content on ratings task and another one to ratings container (used on
    ratings page and ratings block)
    - Adds number_to_human method to get better visualization for numbers
    - Makes the software tasks page closer to the prototype (changes in the divs, sizes and aligns).
    
    Signed-off-by: Dylan Guedes <djmgguedes@gmail.com>
    Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
    Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com>
    Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
    Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
    Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
    Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com>
    Gabriel Silva
     
  • - Move software statistics from blocks table to softwares table
    - Update methods called on view to display software statistics
    - Software now automagically sums saved_resources and benefited people  when the task is accepted
    - Adds one hotspot to insert content on ratings task and another one to ratings container (used on
    ratings page and ratings block)
    - Removes statistic block fields that are no longer used
    - Adds number_to_human method to get better visualization for numbers
    - Makes the software tasks page closer to the prototype (changes in the divs, sizes and aligns).
    - Fixed broken tests on software_profile_editor_controller
    
    Signed-off-by: Dylan Guedes <djmgguedes@gmail.com>
    Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
    Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com>
    Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
    Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
    Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
    Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com>
    Gabriel Silva
     
5 participants
Showing 60 changed files   Show diff stats
src/noosfero-spb/gov_user/controllers/gov_user_plugin_controller.rb
... ... @@ -111,7 +111,7 @@ class GovUserPluginController &lt; ApplicationController
111 111 params[:community] ||= {}
112 112 params[:institutions] ||= {}
113 113  
114   - @show_sisp_field = environment.admins.include?(current_user.person)
  114 + @show_sisp_field = user.is_admin?
115 115 @governmental_sphere = get_governmental_spheres()
116 116 @governmental_power = get_governmental_powers()
117 117 @juridical_nature = get_juridical_natures()
... ... @@ -209,7 +209,7 @@ class GovUserPluginController &lt; ApplicationController
209 209  
210 210 def add_environment_admins_to_institution institution
211 211 edit_page = params[:edit_institution_page] == false
212   - if environment.admins.include?(current_user.person) && edit_page
  212 + if user.is_admin? && edit_page
213 213 environment.admins.each do |adm|
214 214 institution.community.add_admin(adm)
215 215 end
... ...
src/noosfero-spb/gov_user/controllers/gov_user_plugin_myprofile_controller.rb
... ... @@ -5,7 +5,7 @@ class GovUserPluginMyprofileController &lt; MyProfileController
5 5 end
6 6  
7 7 def edit_institution
8   - @show_sisp_field = environment.admins.include?(current_user.person)
  8 + @show_sisp_field = user.is_admin?
9 9 @state_list = NationalRegion.find(
10 10 :all,
11 11 :conditions => { :national_region_type_id => 2 },
... ...
src/noosfero-spb/gov_user/features/rate_community.feature 0 → 100644
... ... @@ -0,0 +1,61 @@
  1 +Feature: rate_community
  2 + As an admin
  3 + I want to see a warning in the task if a software already has a rating related to an specific institution
  4 + So it will be clear when the saved value will be updated
  5 +
  6 + Background:
  7 + Given the environment domain is "localhost"
  8 + And "OrganizationRatings" plugin is enabled
  9 + And "SoftwareCommunities" plugin is enabled
  10 + And "GovUser" plugin is enabled
  11 + And I am logged in as mpog_admin
  12 + And I go to /admin/plugins
  13 + And I check "Organization Ratings"
  14 + And I check "GovUserPlugin"
  15 + And I check "SoftwareCommunitiesPlugin"
  16 + And I press "Save changes"
  17 + And the following user
  18 + | login | name |
  19 + | joaosilva | Joao Silva |
  20 + And the following softwares
  21 + | name | public_software | finality |
  22 + | mycommunity | true | basic software finality |
  23 + | anothercommunity | true | basic software finality |
  24 + And the following blocks
  25 + | owner | type |
  26 + | mycommunity | OrganizationRatingsBlock |
  27 + And Institutions has initial default values on database
  28 + And the following public institutions
  29 + | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | corporate_name |
  30 + | Ministerio das Cidades | MC | BR | DF | Gama | 58.745.189/0001-21 | Autarquia | Executivo | Federal | Ministerio das Cidades |
  31 + | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento |
  32 +
  33 + Scenario: display message on task when a rating with the same institution exists on the same software
  34 + Given the following organization ratings
  35 + | value | organization_name | user_login | institution_name | task_status |
  36 + | 5 | mycommunity | joaosilva | Ministerio das Cidades | 3 |
  37 + | 4 | mycommunity | joaosilva | Ministerio das Cidades | 1 |
  38 + And I go to mycommunity's control panel
  39 + And I follow "Process requests" within ".pending-tasks"
  40 + And I choose "Accept" within ".task_decisions"
  41 + Then I should see "This instiution already has an accepted rating" in the page
  42 +
  43 + Scenario: do not display message on task when a rating with the same institution does not exist on the same software
  44 + Given the following organization ratings
  45 + | value | organization_name | user_login | institution_name | task_status |
  46 + | 5 | mycommunity | joaosilva | Ministerio das Cidades | 3 |
  47 + | 4 | mycommunity | joaosilva | Ministerio do Planejamento | 1 |
  48 + And I go to mycommunity's control panel
  49 + And I follow "Process requests" within ".pending-tasks"
  50 + And I choose "Accept" within ".task_decisions"
  51 + Then I should not see "This instiution already has an accepted rating" within ".task_box"
  52 +
  53 + Scenario: do not display message on task when a rating with the same institution exist on different softwares
  54 + Given the following organization ratings
  55 + | value | organization_name | user_login | institution_name | task_status |
  56 + | 5 | mycommunity | joaosilva | Ministerio das Cidades | 3 |
  57 + | 4 | anothercommunity | joaosilva | Ministerio das Cidades | 1 |
  58 + And I go to anothercommunity's control panel
  59 + And I follow "Process requests" within ".pending-tasks"
  60 + And I choose "Accept" within ".task_decisions"
  61 + Then I should not see "This instiution already has an accepted rating" within ".task_box"
... ...
src/noosfero-spb/gov_user/lib/gov_user_plugin.rb
... ... @@ -54,9 +54,7 @@ class GovUserPlugin &lt; Noosfero::Plugin
54 54 def profile_editor_controller_filters
55 55 block = proc do
56 56 if request.post? && params[:institution]
57   - is_admin = environment.admins.include?(current_user.person)
58   -
59   - unless is_admin
  57 + unless user.is_admin?
60 58 institution = profile.user.institutions
61 59  
62 60 if !params[:institution].blank? && params[:institution].class == Hash && !params[:institution][:sisp].nil?
... ... @@ -241,16 +239,30 @@ class GovUserPlugin &lt; Noosfero::Plugin
241 239 Proc::new do render :file => 'ratings_extra_field' end
242 240 end
243 241  
244   - def organization_ratings_plugin_extra_fields_show_data user_rating
  242 + def organization_ratings_plugin_task_extra_fields user_rating
  243 + gov_user_self = self
  244 +
  245 + Proc::new {
  246 + if logged_in?
  247 + is_admin = user.is_admin? || user_rating.organization.is_admin?(user)
  248 +
  249 + if is_admin and gov_user_self.context.profile.software?
  250 + render :file => 'organization_ratings_task_extra_fields_show_institution',
  251 + :locals => {:user_rating => user_rating}
  252 + end
  253 + end
  254 + }
  255 + end
  256 +
  257 + def organization_ratings_plugin_container_extra_fields user_rating
245 258 gov_user_self = self
246 259  
247 260 Proc::new {
248 261 if logged_in?
249   - is_admin = environment.admins.include?(current_user.person)
250   - is_admin ||= user_rating.organization.admins.include?(current_user.person)
  262 + is_admin = user.is_admin? || user_rating.organization.is_admin?(user)
251 263  
252 264 if is_admin and gov_user_self.context.profile.software?
253   - render :file => 'organization_ratings_extra_fields_show_institution',
  265 + render :file => 'organization_ratings_container_extra_fields_show_institution',
254 266 :locals => {:user_rating => user_rating}
255 267 end
256 268 end
... ...
src/noosfero-spb/gov_user/lib/institution.rb
... ... @@ -36,6 +36,14 @@ class Institution &lt; ActiveRecord::Base
36 36 :verify_institution_type, :validate_format_cnpj
37 37  
38 38  
  39 + def has_accepted_rating? user_rating
  40 + rating_ids = OrganizationRating.where(institution_id: self.id, organization_id: user_rating.organization_id).map(&:id)
  41 + finished_tasks = CreateOrganizationRatingComment.finished.select {|task| rating_ids.include?(task.organization_rating_id)}
  42 + pending_tasks = CreateOrganizationRatingComment.pending.select{|c| c.organization_rating_id == user_rating.id}
  43 +
  44 + !finished_tasks.empty? && !pending_tasks.empty?
  45 + end
  46 +
39 47 protected
40 48  
41 49 def verify_institution_type
... ...
src/noosfero-spb/gov_user/test/functional/gov_user_plugin_controller_test.rb
... ... @@ -230,7 +230,7 @@ class GovUserPluginControllerTest &lt; ActionController::TestCase
230 230 fields[:edit_institution_page] = false
231 231 post :new_institution, fields
232 232  
233   - assert(Institution.last.community.admins.include?(admin2) )
  233 + assert(Institution.last.community.is_admin?(admin2) )
234 234 end
235 235  
236 236 end
... ...
src/noosfero-spb/gov_user/test/functional/profile_editor_controller_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/institution_test_helper'
3 3 require(
4 4 File.dirname(__FILE__) +
... ...
src/noosfero-spb/gov_user/views/organization_ratings_container_extra_fields_show_institution.html.erb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<% if user_rating.institution %>
  2 +<div class="aditional-informations">
  3 + <div class="comments-user-institution">
  4 + <span><%=_("Institution")%> :</span> <%= user_rating.institution.name %>
  5 + </div>
  6 +</div>
  7 +<% end %>
... ...
src/noosfero-spb/gov_user/views/organization_ratings_task_extra_fields_show_institution.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<% if user_rating.institution %>
  2 +<div class="aditional-informations">
  3 + <div class="comments-user-institution">
  4 + <span><%=_("Institution")%> :</span> <%= user_rating.institution.name %>
  5 + </div>
  6 +
  7 + <% if user_rating.institution.has_accepted_rating?(user_rating) %>
  8 + <div class="">
  9 + <span><%=_("This instiution already has an accepted rating. Accepting it will automatically update the saved value.") %></span>
  10 + </div>
  11 + <% end %>
  12 +</div>
  13 +<% end %>
... ...
src/noosfero-spb/noosfero-spb-theme/css/software-pages.css
... ... @@ -630,3 +630,107 @@
630 630 }
631 631  
632 632 /*** end fo software internal pages ***/
  633 +
  634 +/*** organization-rating review page (tasks of software) ***/
  635 +
  636 +.task-list .task_boxes{
  637 + font-family: Arial;
  638 +}
  639 +
  640 +.task-list .task_boxes .task_box .task_date{
  641 + position: absolute;
  642 + left: 80px;
  643 +}
  644 +
  645 +.task_boxes .task_box .task_title{
  646 + position: absolute;
  647 + left: 80px;
  648 + font-weight: 500;
  649 + margin-top: 10px;
  650 +}
  651 +
  652 +.task_boxes .task_box .task_responsible{
  653 + text-align: right;
  654 +}
  655 +
  656 +.task_boxes .task_box .task_responsible span select{
  657 + padding: 4px 15px 1px 4px;
  658 +}
  659 +
  660 +.task_boxes .task_box .task_decisions{
  661 + float: right;
  662 + padding-right: 5px;
  663 +}
  664 +
  665 +.task_boxes .task_box .task_information{
  666 + margin-top: 40px;
  667 + font-size: 13px;
  668 +}
  669 +
  670 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-people-benefited{
  671 + float: left;
  672 + font-weight: 900;
  673 +}
  674 +
  675 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-saved-value{
  676 + font-weight: 900;
  677 + margin-left: 160px;
  678 +}
  679 +
  680 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations{
  681 + margin-top: 10px;
  682 + margin-bottom: 10px;
  683 + border-bottom: 1px solid #CDCDCD;
  684 + padding-bottom: 15px;
  685 +}
  686 +
  687 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-user-institution span span{
  688 + font-weight: 900;
  689 +}
  690 +
  691 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-people-benefited span{
  692 + font-weight: 100;
  693 +}
  694 +
  695 +.task_boxes .task_box .organization-rating-comment-body .aditional-informations .comments-saved-value span{
  696 + font-weight: 100;
  697 +}
  698 +
  699 +.task_boxes .task_box .organization-rating-comment-body .task-comment span{
  700 + font-weight: 600;
  701 + color: rgb(140, 140, 140);
  702 + font-size: 11px;
  703 +}
  704 +
  705 +.task_boxes .task_box .organization-rating-comment-body .task-comment{
  706 + margin-bottom: 15px;
  707 +}
  708 +
  709 +.task_boxes .task_box .organization-rating-comment-body .task-comment span p{
  710 + font-weight: 100;
  711 + font-size: 12px;
  712 + color: black;
  713 + line-height: 16px;
  714 +}
  715 +
  716 +.task_boxes .task_box .organization-rating-comment-body .task-comment{
  717 + line-height: 25px;
  718 +}
  719 +
  720 +.task_boxes .task_box .organization-rating-comment-body .rating-notice{
  721 + display: block;
  722 + color: #F11467;
  723 + padding: 5px 5px;
  724 + background: #ccc;
  725 +}
  726 +
  727 +.task_boxes .task_box .organization-rating-comment-body .task-star-container{
  728 + margin-bottom: 30px;
  729 + margin-top: 10px;
  730 +}
  731 +
  732 +.action-tasks-index .task_box{
  733 + padding: 10px;
  734 +}
  735 +
  736 +/*** end of organization-rating review page (tasks of software) ***/
... ...
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
... ... @@ -144,7 +144,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
144 144  
145 145 add_admin_to_community
146 146  
147   - if !environment.admins.include?(current_user.person)
  147 + if !user.is_admin?
148 148 session[:notice] = _('Your new software request will be evaluated by an'\
149 149 'administrator. You will be notified.')
150 150 redirect_to user.admin_url
... ...
src/noosfero-spb/software_communities/db/migrate/20151116134125_add_statistics_to_software_info.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class AddStatisticsToSoftwareInfo < ActiveRecord::Migration
  2 + def up
  3 + add_column :software_infos, :benefited_people, :integer, :default => 0
  4 + add_column :software_infos, :saved_resources, :decimal, :default => 0
  5 + end
  6 +
  7 + def down
  8 + remove_column :software_infos, :benefited_people
  9 + remove_column :software_infos, :saved_resources
  10 + end
  11 +end
... ...
src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +class MoveSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration
  2 + def up
  3 + benefited_people = 0
  4 + saved_resources = 0
  5 +
  6 + select_all("SELECT * FROM tasks WHERE status=3 AND type='CreateOrganizationRatingComment'").each do |task|
  7 + settings = YAML.load(task['data'])
  8 + organization_rating = select_one("SELECT * FROM organization_ratings WHERE id=#{settings[:organization_rating_id]}")
  9 +
  10 + benefited_people += organization_rating["people_benefited"].to_i
  11 + saved_resources += organization_rating["saved_value"].to_f
  12 + execute("UPDATE software_infos SET benefited_people=#{benefited_people}, saved_resources=#{saved_resources} WHERE software_infos.community_id=#{organization_rating["organization_id"]}")
  13 + end
  14 + end
  15 +
  16 + def down
  17 + execute("UPDATE software_infos SET benefited_people=0, saved_resources=0")
  18 + end
  19 +end
... ...
src/noosfero-spb/software_communities/features/software_block.feature
... ... @@ -25,6 +25,7 @@ Feature: edit adherent fields
25 25  
26 26 Scenario: Change software block to generic software block
27 27 Given I am logged in as mpog_admin
  28 + And I go to /myprofile/mpog_admin
28 29 And I follow "Control panel"
29 30 And I follow "Edit sideboxes"
30 31 When I follow "Add a block"
... ... @@ -45,4 +46,4 @@ Feature: edit adherent fields
45 46 And I follow "Edit" within ".softwares-block"
46 47 And I select "Public" from "block_software_type"
47 48 And I press "Save"
48   - Then I should see "public software"
49 49 \ No newline at end of file
  50 + Then I should see "public software"
... ...
src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb
... ... @@ -64,6 +64,53 @@ Given /^I type in &quot;([^&quot;]*)&quot; in autocomplete list &quot;([^&quot;]*)&quot; and I choose &quot;([^&quot;]*)
64 64 sleep 1
65 65 end
66 66  
  67 +Given /^Institutions has initial default values on database$/ do
  68 + GovernmentalPower.create(:name => "Executivo")
  69 + GovernmentalPower.create(:name => "Legislativo")
  70 + GovernmentalPower.create(:name => "Judiciario")
  71 +
  72 + GovernmentalSphere.create(:name => "Federal")
  73 +
  74 + JuridicalNature.create(:name => "Autarquia")
  75 + JuridicalNature.create(:name => "Administracao Direta")
  76 + JuridicalNature.create(:name => "Empresa Publica")
  77 + JuridicalNature.create(:name => "Fundacao")
  78 + JuridicalNature.create(:name => "Orgao Autonomo")
  79 + JuridicalNature.create(:name => "Sociedade")
  80 + JuridicalNature.create(:name => "Sociedade Civil")
  81 + JuridicalNature.create(:name => "Sociedade de Economia Mista")
  82 +
  83 + national_region = NationalRegion.new
  84 + national_region.name = "Distrito Federal"
  85 + national_region.national_region_code = '35'
  86 + national_region.national_region_type_id = NationalRegionType::STATE
  87 + national_region.save
  88 +end
  89 +
  90 +Given /^the following organization ratings$/ do |table|
  91 + table.hashes.each do |item|
  92 + person = User.where(login: item[:user_login]).first.person
  93 + organization = Organization.where(name: item[:organization_name]).first
  94 +
  95 + rating = OrganizationRating.new
  96 + rating.value = item[:value]
  97 + rating.organization_id = organization.id
  98 + rating.person_id = person.id
  99 + rating.saved_value = item[:saved_value]
  100 + rating.institution_id = Institution.where(name: item[:institution_name]).first.id
  101 + rating.save
  102 +
  103 + comment_task = CreateOrganizationRatingComment.create!(
  104 + :body => "empty comment",
  105 + :requestor => person,
  106 + :organization_rating_id => rating.id,
  107 + :target => organization)
  108 +
  109 + comment_task.status = item[:task_status]
  110 + comment_task.save
  111 + end
  112 +end
  113 +
67 114 Given /^the following public institutions?$/ do |table|
68 115 # table is a Cucumber::Ast::Table
69 116 table.hashes.each do |item|
... ... @@ -247,3 +294,7 @@ end
247 294 Then /^there should be (\d+) divs? with class "([^"]*)"$/ do |count, klass|
248 295 should have_selector("div.#{klass}", :count => count)
249 296 end
  297 +
  298 +Given /^I should see "([^"]*)" in the page/ do |message|
  299 + assert_match message, page.body
  300 +end
... ...
src/noosfero-spb/software_communities/lib/ext/application_helper.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +require_dependency "application_helper"
  2 +
  3 +ApplicationHelper.class_eval do
  4 +
  5 + def number_to_human(value)
  6 + number_with_delimiter(value, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter)
  7 + end
  8 +end
... ...
src/noosfero-spb/software_communities/lib/ext/community.rb
... ... @@ -18,7 +18,7 @@ class Community
18 18 community = Community.new(attributes)
19 19  
20 20 if community.environment.enabled?('admin_must_approve_new_communities') &&
21   - !community.environment.admins.include?(requestor)
  21 + !community.is_admin?(requestor)
22 22  
23 23 cc = CreateCommunity.create(attributes.merge(:requestor => requestor))
24 24 else
... ...
src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +require_dependency "create_organization_rating_comment"
  2 +
  3 +CreateOrganizationRatingComment.class_eval do
  4 + after_save :update_software_statistic
  5 +
  6 + def update_software_statistic
  7 + if(self.status == Task::Status::FINISHED)
  8 + rating = OrganizationRating.find_by_id(self.organization_rating_id)
  9 + software = SoftwareInfo.find_by_community_id(self.target_id)
  10 + if software.present? and rating.present?
  11 + software.saved_resources += rating.saved_value if rating.saved_value
  12 + software.benefited_people += rating.people_benefited if rating.people_benefited
  13 + software.save
  14 + end
  15 + end
  16 + end
  17 +end
... ...
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
... ... @@ -100,14 +100,38 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
100 100 Proc::new do "<h1 class='title'>#{title}</h1>" end
101 101 end
102 102  
103   - def organization_ratings_plugin_extra_fields_show_data user_rating
  103 + def organization_ratings_plugin_container_extra_fields user_rating
104 104 Proc::new {
105 105 if logged_in?
106   - is_admin = environment.admins.include?(current_user.person)
107   - is_admin ||= user_rating.organization.admins.include?(current_user.person)
  106 + is_admin = user.is_admin? || user_rating.organization.is_admin?(user)
108 107  
109 108 if is_admin and profile.software?
110   - render :file => 'organization_ratings_extra_fields_show_data',
  109 +
  110 + render :file => 'organization_ratings_container_extra_fields_show_statistics',
  111 + :locals => {:user_rating => user_rating}
  112 + end
  113 + end
  114 + }
  115 + end
  116 +
  117 + def organization_ratings_plugin_rating_created rating, params
  118 + if params[:organization_rating].present? && (params[:organization_rating][:people_benefited].present? ||
  119 + params[:organization_rating][:saved_value].present?)
  120 + CreateOrganizationRatingComment.create!(
  121 + :requestor => rating.person,
  122 + :organization_rating_id => rating.id,
  123 + :target => rating.organization) unless params[:comments] && params[:comments][:body].present?
  124 + end
  125 + end
  126 +
  127 + def organization_ratings_plugin_task_extra_fields user_rating
  128 + Proc::new {
  129 + if logged_in?
  130 + is_admin = user.is_admin? || user_rating.organization.is_admin?(user)
  131 +
  132 + if is_admin and profile.software?
  133 +
  134 + render :file => 'organization_ratings_task_extra_fields_show_statistics',
111 135 :locals => {:user_rating => user_rating}
112 136 end
113 137 end
... ...
src/noosfero-spb/software_communities/lib/software_info.rb
... ... @@ -166,7 +166,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
166 166 another_license_link = attributes.delete(:another_license_link)
167 167  
168 168 software_info = SoftwareInfo.new(attributes)
169   - unless environment.admins.include? requestor
  169 + if !requestor.is_admin?
170 170 CreateSoftware.create!(
171 171 attributes.merge(
172 172 :requestor => requestor,
... ...
src/noosfero-spb/software_communities/lib/statistic_block.rb
... ... @@ -20,13 +20,15 @@ class StatisticBlock &lt; Block
20 20 end
21 21  
22 22 block = self
  23 + statistics = get_software_statistics
23 24  
24 25 lambda do |object|
25 26 render(
26 27 :file => 'blocks/software_statistics',
27 28 :locals => {
28 29 :block => block,
29   - :total_downloads => downloads.sum
  30 + :total_downloads => downloads.sum,
  31 + :statistics => statistics
30 32 }
31 33 )
32 34 end
... ... @@ -49,4 +51,12 @@ class StatisticBlock &lt; Block
49 51 downloads.select! {|value| not value.nil? }
50 52 downloads.sum
51 53 end
  54 +
  55 + def get_software_statistics
  56 + statistics = {}
  57 + software = SoftwareInfo.find_by_community_id(self.owner.id)
  58 + statistics[:saved_resources] = software.saved_resources
  59 + statistics[:benefited_people] = software.benefited_people
  60 + statistics
  61 + end
52 62 end
... ...
src/noosfero-spb/software_communities/test/functional/organization_ratings_plugin_profile_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,85 @@
  1 +require 'test_helper'
  2 +require 'organization_ratings_plugin_profile_controller'
  3 +require File.dirname(__FILE__) + '/../helpers/software_test_helper'
  4 +
  5 +# Re-raise errors caught by the controller.
  6 +class OrganizationRatingsPluginProfileController; def rescue_action(e) raise e end; end
  7 +
  8 +class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCase
  9 + include SoftwareTestHelper
  10 +
  11 + def setup
  12 + @controller = OrganizationRatingsPluginProfileController.new
  13 + @request = ActionController::TestRequest.new
  14 + @response = ActionController::TestResponse.new
  15 +
  16 + @environment = Environment.default
  17 + @environment.enabled_plugins = ['OrganizationRatingsPlugin']
  18 + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin']
  19 + @environment.save
  20 +
  21 + LicenseInfo.create(:version=>"CC-GPL-V2",
  22 + :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt")
  23 +
  24 + @person = create_user('testuser').person
  25 + @software = create_software(software_fields)
  26 + @statistic_block = StatisticBlock.new
  27 + @software.community.blocks << @statistic_block
  28 + @software.community.save!
  29 +
  30 + login_as(@person.identifier)
  31 + @controller.stubs(:logged_in?).returns(true)
  32 + @controller.stubs(:current_user).returns(@person.user)
  33 + end
  34 +
  35 + test "should create a task with a valid benefited people value and no comment" do
  36 + assert_difference 'CreateOrganizationRatingComment.count' do
  37 + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""},
  38 + :organization_rating_value => 3, :organization_rating => {:people_benefited => 50}
  39 + end
  40 + end
  41 +
  42 + test "should create a task with a valid saved value and no comment" do
  43 + assert_difference 'CreateOrganizationRatingComment.count' do
  44 + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""},
  45 + :organization_rating_value => 3, :organization_rating => {:saved_value => 50000000}
  46 + end
  47 + end
  48 +
  49 + test "should not create a task with no saved value or benefited poeple, and no comment" do
  50 + assert_no_difference 'CreateOrganizationRatingComment.count' do
  51 + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""},
  52 + :organization_rating_value => 3, :organization_rating => nil
  53 + end
  54 + end
  55 +
  56 + test "software statistics should be updated when task is accepted" do
  57 + @software.reload
  58 + assert_equal 0, @software.benefited_people
  59 + assert_equal 0.0, @software.saved_resources
  60 +
  61 + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""},
  62 + :organization_rating_value => 3,
  63 + :organization_rating => {:saved_value => 500, :people_benefited => 10}
  64 +
  65 + CreateOrganizationRatingComment.last.finish
  66 + @software.reload
  67 + assert_equal 10, @software.benefited_people
  68 + assert_equal 500.0, @software.saved_resources
  69 + end
  70 +
  71 + test "software statistics should not be updated when task is cancelled" do
  72 + @software.reload
  73 + assert_equal 0, @software.benefited_people
  74 + assert_equal 0.0, @software.saved_resources
  75 +
  76 + post :new_rating, profile: @software.community.identifier, :comments => {:body => ""},
  77 + :organization_rating_value => 3,
  78 + :organization_rating => {:saved_value => 500, :people_benefited => 10}
  79 +
  80 + CreateOrganizationRatingComment.last.cancel
  81 + @software.reload
  82 + assert_equal 0, @software.benefited_people
  83 + assert_equal 0.0, @software.saved_resources
  84 + end
  85 +end
... ...
src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require File.dirname(__FILE__) + '/../helpers/software_test_helper'
  2 +require 'test_helper'
2 3 require(
3 4 File.dirname(__FILE__) +
4 5 '/../../../../app/controllers/my_profile/profile_editor_controller'
... ... @@ -7,13 +8,18 @@ require(
7 8 class ProfileEditorController; def rescue_action(e) raise e end; end
8 9  
9 10 class ProfileEditorControllerTest < ActionController::TestCase
10   -
  11 + include SoftwareTestHelper
11 12 def setup
12 13 @controller = ProfileEditorController.new
13 14 @request = ActionController::TestRequest.new
14 15 @response = ActionController::TestResponse.new
15 16 @profile = create_user('default_user').person
16 17  
  18 + LicenseInfo.create(
  19 + :version=>"CC-GPL-V2",
  20 + :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt"
  21 + )
  22 +
17 23 Environment.default.affiliate(
18 24 @profile,
19 25 [Environment::Roles.admin(Environment.default.id)] +
... ... @@ -29,42 +35,14 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
29 35 @environment.save
30 36 end
31 37  
32   - should "redirect to edit_software_community on edit community of software" do
33   - software = create_software_info("Test Software")
  38 + def teardown
  39 + Community.destroy_all
  40 + SoftwareInfo.destroy_all
  41 + end
34 42  
  43 + should "redirect to edit_software_community on edit community of software" do
  44 + software = create_software(software_fields)
35 45 post :edit, :profile => software.community.identifier
36   -
37 46 assert_redirected_to :controller => 'profile_editor', :action => 'edit_software_community'
38 47 end
39   -
40   -
41   - protected
42   -
43   - def create_basic_user
44   - user = fast_create(User)
45   - user.person = fast_create(Person)
46   - user.person.user = user
47   - user.save!
48   - user.person.save!
49   - user
50   - end
51   -
52   - def create_community name
53   - community = fast_create(Community)
54   - community.name = name
55   - community.save
56   - community
57   - end
58   -
59   - def create_software_info name, finality = "something", acronym = ""
60   - community = create_community(name)
61   - software_info = SoftwareInfo.new
62   - software_info.community = community
63   - software_info.finality = finality
64   - software_info.acronym = acronym
65   - software_info.public_software = true
66   - software_info.save
67   - software_info
68   - end
69   -
70 48 end
... ...
src/noosfero-spb/software_communities/test/functional/search_controller_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3 require(
4 4 File.dirname(__FILE__) +
... ...
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_controller_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin_controller'
3 3  
4 4 class SoftwareCommunitiesPluginController; def rescue_action(e) raise e end; end
... ...
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb
1 1 require 'test_helper'
2   -require_relative '../helpers/software_test_helper'
3   -require_relative(
4   - '../../controllers/software_communities_plugin_myprofile_controller'
  2 +require File.dirname(__FILE__) + '/../helpers/software_test_helper'
  3 +require(
  4 + File.dirname(__FILE__) +
  5 + '/../../controllers/software_communities_plugin_myprofile_controller'
5 6 )
6 7  
7 8 class SoftwareCommunitiesPluginMyprofileController; def rescue_action(e) raise e end;
... ...
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_profile_controller_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/software_test_helper'
3 3 require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin_profile_controller'
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class CategoriesAndTagsBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/categories_software_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class CategoriesSoftwareBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class CommunitiesBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/database_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class DatabaseHelperTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/database_validation_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class DatabaseValidationTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/download_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class DownloadBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/download_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class DownloadTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/library_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class LibraryHelperTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/library_validation_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class LibraryValidationTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 OperatingSystemName.create(:name=>"Debina")
4 4 OperatingSystemName.create(:name=>"Fedora")
... ...
src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class OperatingSystemValidationTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/repository_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class RepositoryBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/search_catalog_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class SearchCatalogBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/search_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../../lib/ext/search_helper.rb'
3 3  
4 4 class SearchHelperTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb
1 1 # encoding: utf-8
2 2  
3   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  3 +require 'test_helper'
4 4 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
5 5  
6 6 class GovUserPluginPersonTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/software_database_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareDatabaseTest < ActiveSupport::TestCase
4 4 def setup
... ...
src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class SoftwareEventsBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/software_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareHelperTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/software_info_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class SoftwareInfoValidationTest < ActiveSupport::TestCase
... ... @@ -41,4 +41,4 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
41 41 assert_equal @software_info.license_info.link, another_license_link
42 42 end
43 43  
44   -end
45 44 \ No newline at end of file
  45 +end
... ...
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareInfoValidationTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareLanguageHelperTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/software_language_validation.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareLanguageValidationTest < ActiveSupport::TestCase
4 4 def setup
... ...
src/noosfero-spb/software_communities/test/unit/software_license_info_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareDatabaseTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/software_registration_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2  
3 3 class SoftwareRegistrationTest < ActiveSupport::TestCase
4 4  
... ...
src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class SoftwareTabDataBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
  1 +require 'test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
3 3  
4 4 class SoftwaresBlockTest < ActiveSupport::TestCase
... ...
src/noosfero-spb/software_communities/views/blocks/software_statistics.html.erb
1 1 <div class="software-metrics-block">
2 2 <ul class="metrics-list">
3 3 <li>
4   - <span class="arrow-globe-icon"></span>
5   - <span id="visit-count">
6   - <%= pluralize(profile.hits, 'visita', 'visitas') %>
7   - </span>
  4 + <span class="arrow-globe-icon"></span>
  5 + <span id="visit-count">
  6 + <%= pluralize(profile.hits, 'visita', 'visitas') %>
  7 + </span>
8 8 </li>
9 9 <li>
10   - <span class="downloads-icon"></span>
11   - <span id="downloads-count">
12   - <%= pluralize(total_downloads, 'download', 'downloads') %>
13   - </span>
  10 + <span class="downloads-icon"></span>
  11 + <span id="downloads-count">
  12 + <%= pluralize(total_downloads, 'download', 'downloads') %>
  13 + </span>
14 14 </li>
15 15 <li>
16   - <span class="face-icon"></span>
17   - <span id="benefited-people">
18   - <%= block.benefited_people.to_s + _(' benefited people*') %>
19   - </span>
  16 + <span class="face-icon"></span>
  17 + <span id="benefited-people">
  18 + <%= number_to_human(statistics[:benefited_people]) + _(' benefited people*') %>
  19 + </span>
20 20 </li>
21 21 <li>
22   - <span class="pig-safe-icon"></span>
23   - <span id="saved-resources">
24   - <strong class="saved-money">
25   - <%= number_to_currency(block.saved_resources, unit: 'R$ ',
26   - separator: ',', delimiter: '.') %>
27   - </strong>
28   - <%= _(' saved resources*') %>
29   - </span>
  22 + <span class="pig-safe-icon"></span>
  23 + <span id="saved-resources">
  24 + <strong class="saved-money">
  25 + <%= float_to_currency(statistics[:saved_resources]) %>
  26 + </strong>
  27 + <%= _(' saved resources*') %>
  28 + </span>
30 29 </li>
31 30 </ul>
32 31  
33 32 <div class="admin-estimation">
34   - * <%= _("Data estimated by the software administrator.") %>
  33 + * <%= _("Data estimated by the software administrator.") %>
35 34 </div>
36 35 </div>
... ...
src/noosfero-spb/software_communities/views/box_organizer/_statistic_block.html.erb
1 1 <div id='edit-softwares-block'>
2   - <% suggestion_benefited_people = @block.owner.organization_ratings.collect{ |r| r.people_benefited.to_f }.inject(:+) || 0.0 %>
3   - <% suggestion_saved_resources = @block.owner.organization_ratings.collect{ |r| r.saved_value.to_f }.inject(:+) || 0.0 %>
  2 + <% benefited_people = @block.owner.software_info.benefited_people + 5 %>
  3 + <% saved_resources = @block.owner.software_info.saved_resources + 5 %>
4 4  
5   - <%= labelled_form_field _('Benefited People'), text_field(:block, :benefited_people) %>
6   - <p> <%= _("Portal suggested value: ") %> <span> <%= "%d" % (suggestion_benefited_people) %> <span> </p>
7   - <%= labelled_form_field _('Saved Resources'), text_field(:block, :saved_resources) %>
8   - <p> <%= _("Portal suggested value: ") %> <span> <%= "R$%.2f" % (suggestion_saved_resources) %> <span> </p>
9   -</div>
  5 + <p> <%= _("Statistics to be displayed ") %>
10 6  
  7 + <p> <%= _("People Benefited: ") %> <span> <%= number_to_human(benefited_people) %> </span> </p>
  8 + <p> <%= _("Saved Resources: ") %> <span> <%= float_to_currency(saved_resources) %> </span> </p>
  9 +</div>
... ...
src/noosfero-spb/software_communities/views/organization_ratings_container_extra_fields_show_statistics.html.erb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +<div class="aditional-informations">
  2 + <div class="comments-people-benefited">
  3 + <span><%=_("Benefited People")%>:</span> <%= number_with_delimiter(user_rating.people_benefited, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter) unless user_rating.nil? %>
  4 + </div>
  5 +
  6 + <div class="comments-saved-value">
  7 + <span><%=_("Saved Resources")%>:</span> <%= float_to_currency(user_rating.saved_value) unless user_rating.nil? %>
  8 + </div>
  9 +</div>
  10 +
... ...
src/noosfero-spb/software_communities/views/organization_ratings_task_extra_fields_show_statistics.html.erb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +<div class="aditional-informations">
  2 + <div class="comments-people-benefited">
  3 + <span><%=_("Benefited People")%> :</span> <%= user_rating.people_benefited unless user_rating.nil? %>
  4 + </div>
  5 +
  6 + <div class="comments-saved-value">
  7 + <span><%=_("Saved Resources")%> :</span> <%= user_rating.saved_value unless user_rating.nil? %>
  8 + </div>
  9 +</div>
  10 +
... ...
src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb
... ... @@ -13,7 +13,7 @@
13 13  
14 14 <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %>
15 15  
16   - <% if environment.admins.include?(user) %>
  16 + <% if user.is_admin? %>
17 17 <div id="profile-is-template">
18 18 <%= labelled_check_box(_('This profile is a template'), 'profile_data[is_template]', true, @profile.is_template) %>
19 19 </div>
... ... @@ -78,7 +78,7 @@
78 78 <% if user && user.has_permission?('destroy_profile', profile) && !@first_edit %>
79 79 <% button_bar(:id => 'delete-profile') do %>
80 80 <%= button(:remove, _('Delete software and community'), {:action => :destroy_profile}) %>
81   - <% if environment.admins.include?(current_person) %>
  81 + <% if user.is_admin? %>
82 82 <% if profile.visible? %>
83 83 <%= 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?")}) %>
84 84 <% else %>
... ...
  • 79ebee40dd44c661fc4ad27b3656be68?s=40&d=identicon
    Álvaro Fernando Matos de Souza @alvarofernandoms

    Added 1 new commit:

    • 4b450038 - New style for software review moderation page
    Choose File ...   File name...
    Cancel
  • B6dd822230d315124f3352380142d943?s=40&d=identicon
    Dylan Guedes @dylanguedes

    Added 1 new commit:

    • 47c22ee7 - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • B6dd822230d315124f3352380142d943?s=40&d=identicon
    Dylan Guedes @dylanguedes

    Added 1 new commit:

    • 8c218b42 - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    Added 3 new commits:

    • 2890d7a8 - Software Communities plugin rating improvements
    • a4f5818b - Organiztion Ratings plugin improvements
    • 3d42d2b1 - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    Added 2 new commits:

    • bd661e1a - Gov User plugin rating improvements
    • d05b613e - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • 800e3af93350753db9dee1864cef10ff?s=40&d=identicon
    Thiago Ribeiro @thiago

    Added 3 new commits:

    • 6aa39a4c - Software Communities plugin rating improvements
    • 870bb27c - Gov User plugin rating improvements
    • 0b9ecfcd - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    Added 3 new commits:

    • afbf7a84 - Software Communities plugin rating improvements
    • 8dd68f13 - Gov User plugin rating improvements
    • 223ef36a - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    Added 3 new commits:

    • 489447fa - Software Communities plugin rating improvements
    • bf3b1f06 - Gov User plugin rating improvements
    • f21eea08 - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • 800e3af93350753db9dee1864cef10ff?s=40&d=identicon
    Thiago Ribeiro @thiago

    Added 60 new commits:

    • fb8bf07a - Updates kalibro-configurations spec
    • dbdf7b11 - Added password validator for gitlab
    • dce5c218 - Add modal to create institution in use report.
    • 69653c91 - API improvements for spb plugins
    • 353a9563 - Merge branch 'api_for_colab' into 'master'
    • c31fef04 - Add software communities endpoint to API
    • f093099b - Merge branch 'software_communities_api' into 'master'
    • dc4912df - Only admin can edit if software is public
    • 73f3aa5b - Merge branch 'admin_public_software_fields_edit' into 'master'
    • e1f7033e - doc: support for push with HTTPS and multiples repos
    • 93a39ae6 - Merge branch 'update_doc' into 'master'
    • 6aacc037 - Regenerate private_token when token is expired.
    • d828cc68 - Merge branch 'noosfero_regenerate_expired_token' into 'master'
    • dfbf2427 - Unified release process
    • 413e0d3b - Merge branch 'release-process-v2'
    • 45340488 - Added masks for use report fields
    • 22cd99c6 - Merge branch 'refactor_saved_value' into 'master'
    • fe196cc3 - Created migration to remove softwares without community
    • aedd76a8 - Merge branch 'bug_bloco_sei' into 'master'
    • 4c195680 - Add institution in social menu.
    • 89190395 - Merge branch 'add_institution_in_social_menu' into 'master'
    • cf86f45e - colab_test: fix "settings is in place" test
    • dfd6263e - Refactor software_communities.
    • 3ab32308 - Merge branch 'fix_create_software_without_community' into 'master'
    • 1326ae47 - Adding namespace to app.py
    • e35b38be - Merge branch 'removing_namespace' into 'master'
    • 76ab812b - Allow Colab to request Gitlab API using self signed certs
    • 73f57c97 - Adding tutorial for environment with noosfero+colab - #413
    • 233bad74 - Fixing theme on search for institutions - #416
    • 94738abb - Adjustments in the area of blog and blog tab - #437
    • c0192640 - Formatting question mark for use report - #418
    • 827d1dce - Alignment posts 2,3 and 4 blog page - #437
    • e69828c8 - Fixed height image for the home area of news - #329
    • 47a88afc - Fixes of sprint 40
    • 30933c38 - Add software event block css
    • 9181939c - improve solution of image height overflow on homepage's news section
    • 65888ef9 - fix image margin on first page of blog
    • 829ddd20 - hide read-more link of each post on profile blog tab
    • 6fb4392c - tmp solution of report use - govuser fields for development modification on plugin view
    • 39a81339 - Additional improvements on search institutions page
    • 80febdec - hide border bottom from last item on event block
    • a11b751e - Merge branch 'design_41' into 'master'
    • 824fdd6d - solve conflicts - that was only redundancy - on event block style
    • c73f1bbf - Software events block, only display on profile page in - Need to develop
    • 01abb668 - fix agenda button opacity on calendar page and display event block on edit sideblocks page
    • 83de26da - Merge branch 'design_42' into 'master'
    • c896d5f4 - ajust details for average rating on catalog
    • 6f2cc74e - Add rating and favorite filter to software catalog
    • 536d9288 - apply software catalog average rating design
    • ca88bc8c - Merge branch 'software_rating_on_catalog' into 'master'
    • f77c83ab - Fix css/html in institution modal
    • b7d62204 - Update gov_user translations.
    • 517180c6 - Merge branch 'create_institution_bootstrap_modal' into 'master'
    • 76337877 - Merge branch 'master' of beta.softwarepublico.gov.br:softwarepublico/softwarepublico
    • b70e437f - Update kalibro-configurations and deps versions
    • 2f40b2e4 - Bump kalibro-configuration-deps release
    • f50cbb93 - Fix kalibro-processor-deps version and release
    • 6e93d102 - Software Communities plugin rating improvements
    • fd35a912 - Gov User plugin rating improvements
    • 6e887087 - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa started a discussion on the outdated diff
    last updated by Daniela Feitosa
    src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb 0 → 100644
      1 +class MoveSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration
      2 + def up
      3 + select_all("SELECT * FROM software_infos").each do |software|
    1
    • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
      Daniela Feitosa @daniela

      Só o "id" do software é usado, então o select pode ser só SELECT id FROM software_infos

      Choose File ...   File name...
      Cancel
    0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa started a discussion on the outdated diff
    last updated by Daniela Feitosa
    src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb 0 → 100644
      1 +class MoveSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration
      2 + def up
      3 + select_all("SELECT * FROM software_infos").each do |software|
      4 + benefited_people = 0
      5 + saved_resources = 0
      6 +
      7 + select_all("SELECT * FROM tasks WHERE status=3 AND type='CreateOrganizationRatingComment'").each do |task|
    1
    • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
      Daniela Feitosa @daniela

      O select pode ser só SELECT data FROM tasks WHERE status=3 AND type='CreateOrganizationRatingComment'

      Choose File ...   File name...
      Cancel
    0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa started a discussion on the outdated diff
    last updated by Daniela Feitosa
    src/noosfero-spb/software_communities/db/migrate/20151116140329_move_software_statistics_from_block_to_software_info.rb 0 → 100644
      1 +class MoveSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration
      2 + def up
      3 + select_all("SELECT * FROM software_infos").each do |software|
      4 + benefited_people = 0
      5 + saved_resources = 0
      6 +
      7 + select_all("SELECT * FROM tasks WHERE status=3 AND type='CreateOrganizationRatingComment'").each do |task|
      8 + settings = YAML.load(task['data'])
      9 + organization_rating = select_all("SELECT * FROM organization_ratings WHERE id=#{settings[:organization_rating_id]}").first
    1
    • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
      Daniela Feitosa @daniela

      Como você só precisa retornar um rating, pode colocar limite no select para não ter que usar o .first: SELECT * FROM organization_ratings WHERE id=#{settings[:organization_rating_id]} LIMIT 1

      Choose File ...   File name...
      Cancel
    0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa started a discussion on the outdated diff
    last updated by Daniela Feitosa
    src/noosfero-spb/gov_user/views/organization_ratings_task_extra_fields_show_institution.html.erb 0 → 100644
      1 +<% if user_rating.institution %>
      2 +<div class="aditional-informations">
      3 + <div class="comments-user-institution">
      4 + <span><%=_("Institution")%> :<span> <%= user_rating.institution.name %>
    1
  • 800e3af93350753db9dee1864cef10ff?s=40&d=identicon
    Thiago Ribeiro @thiago

    Added 3 new commits:

    • 32df146e - Software Communities plugin rating improvements
    • fc0c1093 - Gov User plugin rating improvements
    • acd2fbca - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa started a discussion on the outdated diff
    last updated by Daniela Feitosa
    src/noosfero-spb/software_communities/views/profile_editor/edit_software_community.html.erb
    78 78 <% if user && user.has_permission?('destroy_profile', profile) && !@first_edit %>
    79 79 <% button_bar(:id => 'delete-profile') do %>
    80 80 <%= button(:remove, _('Delete software and community'), {:action => :destroy_profile}) %>
    81   - <% if environment.admins.include?(current_person) %>
    82   - <% if profile.visible? %>
      81 + <% if user.is_admin? %>
      82 + <% iprofile.visible? %>
    1
  • 800e3af93350753db9dee1864cef10ff?s=40&d=identicon
    Thiago Ribeiro @thiago

    Added 3 new commits:

    • 53ef4b90 - Software Communities plugin rating improvements
    • 15a66159 - Gov User plugin rating improvements
    • 083c4e4a - Changes box size of task status list, changes task message size.
    Choose File ...   File name...
    Cancel
  • 0743c2eb05e68c92baa5f8c498995a20?s=40&d=identicon
    Daniela Feitosa @daniela
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva started a discussion on commit 53ef4b90
    last updated by Gabriel Silva
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    mentioned in commit 5f605edf575fd8627fea2df965cd52cb7d3ed669

    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva started a discussion on commit 15a66159
    last updated by Gabriel Silva
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva
    Choose File ...   File name...
    Cancel
  • Df604377056e7cd36436e90bf2b9af70?s=40&d=identicon
    Gabriel Silva @gabrielssilva

    mentioned in commit 8511989a2d030b1390b24c1b68ba75b3e6885281

    Choose File ...   File name...
    Cancel
  • B6dd822230d315124f3352380142d943?s=40&d=identicon
    Dylan Guedes started a discussion on commit 083c4e4a
    last updated by Dylan Guedes
  • B6dd822230d315124f3352380142d943?s=40&d=identicon
    Dylan Guedes @dylanguedes
    Choose File ...   File name...
    Cancel
  • B6dd822230d315124f3352380142d943?s=40&d=identicon
    Dylan Guedes @dylanguedes

    mentioned in commit e7c60eda2dc24a888a6b9d6f74d4cad37ec89f7b

    Choose File ...   File name...
    Cancel