Merge branch 'master' into rails3

Conflicts:
	.gitignore
	app/models/task.rb
	app/models/workgroup.rb
	app/views/shared/_group_form.html.haml
	config/locales/de.yml
	db/schema.rb
This commit is contained in:
benni 2012-06-24 21:59:46 +02:00
commit 182742fbec
10 changed files with 46 additions and 26 deletions

View file

@ -63,6 +63,12 @@ class Ordergroup < Group
stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0
end
# This is the ordergroup job per euro performance
# in comparison to the hole foodcoop average
def apples
((avg_jobs_per_euro / Ordergroup.avg_jobs_per_euro) * 100).to_i rescue 0
end
# Global average
def self.avg_jobs_per_euro
stats = Ordergroup.all.collect(&:stats)

View file

@ -5,18 +5,19 @@ class Workgroup < Group
# returns all non-finished tasks
has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC'
validates_presence_of :task_name, :weekday, :task_required_users,
:if => Proc.new {|workgroup| workgroup.weekly_task }
validates_presence_of :task_name, :weekday, :task_required_users, :next_weekly_tasks_number,
:if => :weekly_task
validates_numericality_of :next_weekly_tasks_number, :greater_than => 0, :less_than => 21, :only_integer => true,
:if => :weekly_task
validate :last_admin_on_earth, :on => :update
before_destroy :check_last_admin_group
def self.weekdays
[["Montag", "1"], ["Dienstag", "2"], ["Mittwoch","3"],["Donnerstag","4"],["Freitag","5"],["Samstag","6"],["Sonntag","0"]]
end
# Returns an Array with date-objects to represent the next weekly-tasks
def next_weekly_tasks(number = 8)
def next_weekly_tasks
# our system starts from 0 (sunday) to 6 (saturday)
# get difference between groups weekday and now
diff = self.weekday - Time.now.wday
@ -29,7 +30,7 @@ class Workgroup < Group
end
# now generate the Array
nextTasks = Array.new
number.times do
next_weekly_tasks_number.times do
nextTasks << nextTask.to_date
nextTask = 1.week.from_now(nextTask)
end

View file

@ -14,7 +14,7 @@ unless global_avg == 0 or global_avg.nan?
%>
Engagement Deiner Bestellgruppe
<div class="stats-bar" style="width:<%= length_of_group_bar -%>px; background-color:<%= color -%>">
<%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%>
<%= @ordergroup.apples -%><%= " Äpfel" if length_of_group_bar > 50 -%>
</div>
Durchschnittsengagement
<div class="stats-bar" style="width:<%= length_of_global_bar -%>px">