aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-08 19:02:32 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-10 18:30:37 +0200
commit53201e0add36dd0ca796fa349108bc533890eedb (patch)
tree1284107c1b987b0fcd45ea70738b15f81df7710f /site/app/models/user.rb
parentHandle proxies attendance (diff)
downloadcouncil-webapp-53201e0add36dd0ca796fa349108bc533890eedb.tar.gz
council-webapp-53201e0add36dd0ca796fa349108bc533890eedb.tar.bz2
council-webapp-53201e0add36dd0ca796fa349108bc533890eedb.zip
Show slacking information in the application
Using participations
Diffstat (limited to 'site/app/models/user.rb')
-rw-r--r--site/app/models/user.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/site/app/models/user.rb b/site/app/models/user.rb
index 0cb75b4..f940ea4 100644
--- a/site/app/models/user.rb
+++ b/site/app/models/user.rb
@@ -53,6 +53,23 @@ class User < ActiveRecord::Base
true
end
+ def slacking_status_in_period(start_date, end_date)
+ num_status = 0
+ agendas = Agenda.all :conditions => ['agendas.meeting_time BETWEEN ? AND ?', start_date, end_date],
+ :order => :meeting_time
+ for agenda in agendas
+ if Participation.participant_is(self).agenda_is(agenda).count == 0
+ num_status += 1 if num_status < 3
+ else
+ num_status = 0 if num_status == 1
+ end
+ end
+
+ a = ['Was on last meeting', 'Skipped last meeting',
+ 'Slacker', 'No more a council']
+ a[num_status]
+ end
+
def can_appoint_a_proxy?(user)
return false unless council_member?
return false if user.council_member?