aboutsummaryrefslogtreecommitdiff
path: root/site/app
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-08 13:59:09 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-10 18:21:02 +0200
commit551ce28e97d8c7a9b29c810c1427a4f810598a01 (patch)
tree2631c22d29b02d48b734dc6853063807a7185f14 /site/app
parentPlugin that sends reminders to users (diff)
downloadcouncil-webapp-551ce28e97d8c7a9b29c810c1427a4f810598a01.tar.gz
council-webapp-551ce28e97d8c7a9b29c810c1427a4f810598a01.tar.bz2
council-webapp-551ce28e97d8c7a9b29c810c1427a4f810598a01.zip
Receive list of meeting participants from IRC bot
Diffstat (limited to 'site/app')
-rw-r--r--site/app/controllers/agendas_controller.rb4
-rw-r--r--site/app/models/agenda.rb7
-rw-r--r--site/app/models/participation.rb12
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