Commit 7d9f05ae9c478baa8a29cdb21880ae9e6251d219
1 parent
5fe95a75
Exists in
organization_rating_style_changes
Added software ratings statistics auto sum
- Software now automagically sums saved_resources and benefited people when the task is accepted Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
2 changed files
with
20 additions
and
5 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/ext/create_organization_rating_comment.rb
@@ -4,11 +4,14 @@ CreateOrganizationRatingComment.class_eval do | @@ -4,11 +4,14 @@ CreateOrganizationRatingComment.class_eval do | ||
4 | after_save :clear_rejected_rating_values | 4 | after_save :clear_rejected_rating_values |
5 | 5 | ||
6 | def clear_rejected_rating_values | 6 | def clear_rejected_rating_values |
7 | - if(self.status == Task::Status::CANCELLED) | ||
8 | - rating = OrganizationRating.find(self.organization_rating_id) | ||
9 | - rating.saved_value = 0 | ||
10 | - rating.people_benefited = 0 | ||
11 | - rating.save | 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 | ||
12 | end | 15 | end |
13 | end | 16 | end |
14 | end | 17 | end |
src/noosfero-spb/software_communities/lib/ext/organization_ratings_plugin_profile_controller.rb
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +require_dependency "organization_ratings_plugin_profile_controller" | ||
2 | + | ||
3 | +OrganizationRatingsPluginProfileController.class_eval do | ||
4 | + before_filter :xd | ||
5 | + | ||
6 | + def xd | ||
7 | + if params[:organization_rating].present? && (params[:organization_rating][:people_benefited].present? || params[:organization_rating][:saved_value].present?) | ||
8 | + params.merge!("comments" => {"body" => _("No comment") }) unless params[:comments][:body].present? | ||
9 | + end | ||
10 | + end | ||
11 | + | ||
12 | +end |