diff options
Diffstat (limited to 'site/app')
-rw-r--r-- | site/app/controllers/agendas_controller.rb | 4 | ||||
-rw-r--r-- | site/app/models/agenda.rb | 7 | ||||
-rw-r--r-- | site/app/models/participation.rb | 12 |
3 files changed, 15 insertions, 8 deletions
diff --git a/site/app/controllers/agendas_controller.rb b/site/app/controllers/agendas_controller.rb index e0fd813..8760069 100644 --- a/site/app/controllers/agendas_controller.rb +++ b/site/app/controllers/agendas_controller.rb @@ -14,7 +14,9 @@ class AgendasController < ApplicationController end def results - Agenda.process_results JSON.parse(request.env["rack.input"].read) + data = JSON.parse(request.env["rack.input"].read) + Agenda.process_results data + Participation.mark_participations data end def reminders diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb index 55bc6cd..5be2d82 100644 --- a/site/app/models/agenda.rb +++ b/site/app/models/agenda.rb @@ -19,14 +19,7 @@ class Agenda < ActiveRecord::Base transition :close, {:open => :submissions_closed}, :available_to => '::Agenda.transitions_available(acting_user)' transition :reopen, {:submissions_closed=> :open}, :available_to => '::Agenda.transitions_available(acting_user)' transition :archive, {:submissions_closed => :old}, :available_to => '::Agenda.transitions_available(acting_user)' do - ActiveRecord::Base.transaction do Agenda.new.save! - ::User.council_member_is(true).each do |participant| - Participation.create! :irc_nick => participant.irc_nick, - :participant => participant, - :agenda => self - end - end end end diff --git a/site/app/models/participation.rb b/site/app/models/participation.rb index 95c4142..b7ca39a 100644 --- a/site/app/models/participation.rb +++ b/site/app/models/participation.rb @@ -31,4 +31,16 @@ class Participation < ActiveRecord::Base def name participant.name end + + def self.mark_participations(results) + participant_nicks = results.values.*.keys.flatten.uniq + agenda = Agenda.current + for nick in participant_nicks + user = ::User.find_by_irc_nick(nick) + next if user.nil? + Participation.create! :irc_nick => user.irc_nick, + :participant => user, + :agenda => agenda + end + end end |