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 index 71f6c44..b8bb580 100644 --- 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 @@ -4,11 +4,14 @@ CreateOrganizationRatingComment.class_eval do after_save :clear_rejected_rating_values def clear_rejected_rating_values - if(self.status == Task::Status::CANCELLED) - rating = OrganizationRating.find(self.organization_rating_id) - rating.saved_value = 0 - rating.people_benefited = 0 - rating.save + 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/ext/organization_ratings_plugin_profile_controller.rb b/src/noosfero-spb/software_communities/lib/ext/organization_ratings_plugin_profile_controller.rb new file mode 100644 index 0000000..270bc73 --- /dev/null +++ b/src/noosfero-spb/software_communities/lib/ext/organization_ratings_plugin_profile_controller.rb @@ -0,0 +1,12 @@ +require_dependency "organization_ratings_plugin_profile_controller" + +OrganizationRatingsPluginProfileController.class_eval do + before_filter :xd + + def xd + if params[:organization_rating].present? && (params[:organization_rating][:people_benefited].present? || params[:organization_rating][:saved_value].present?) + params.merge!("comments" => {"body" => _("No comment") }) unless params[:comments][:body].present? + end + end + +end -- libgit2 0.21.2