small updates

This commit is contained in:
Nicolas Bally 2020-10-03 00:58:52 +02:00
parent ad4aa7a1b9
commit fb893ed4c3
4 changed files with 25 additions and 5 deletions

View File

@ -74,9 +74,9 @@ class KapsDay < ActiveRecord::Base
end
end
def total_points
self.kapsmes.sum(:point_to_count)
before_validation do
self.total_points = self.kapsmes.sum(:point_to_count)
self.points = self.total_points_earneds
end
def total_points_earneds
@ -85,7 +85,7 @@ class KapsDay < ActiveRecord::Base
def completed
(100.0 * self.total_points_earneds.to_f) / total_points.to_f
(100.0 * self.points.to_f) / total_points.to_f
end

View File

@ -30,6 +30,10 @@ class Kapsme < ActiveRecord::Base
end
after_save do
self.kaps_day.save
end
def generate_token
begin

View File

@ -1,6 +1,12 @@
%tr#kaps_day{:id => kaps_day.id}
%td= link_to l(kaps_day.date), [:public, kaps_day]
%td= kaps_day.total_points
%td= kaps_day.points
%td
#pourcentage_inner
=render(:partial => "pourcentage", :locals => {:kaps_day => kaps_day})

View File

@ -10,6 +10,16 @@
-KapsRappel.generate_rappels
-prev_day = @kaps_day.p_customer.kaps_days.order("date DESC").where("date < ?", @kaps_day.date).first
-if prev_day
=link_to "< Jour précédent", public_kaps_day_path(prev_day)
-next_day = @kaps_day.p_customer.kaps_days.order("date ASC").where("date > ?", @kaps_day.date).first
-if next_day
=link_to "Jour suivant >", public_kaps_day_path(next_day)
.qi_row
.qi_pannel.qi_plain.padding{:style => "position:relative;"}
#pourcentage_inner{:style => "position:absolute;top:0;left:0;right:0;"}