From 232f45b7a5b4096e10cfc34edd080e7605b06c1b Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Mon, 27 Jun 2011 17:36:20 +0200 Subject: Application receives meeting log from IRC bot --- site/app/controllers/agendas_controller.rb | 2 ++ site/app/models/agenda.rb | 6 +++++- site/db/schema.rb | 3 ++- site/spec/models/agenda_spec.rb | 10 ++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/site/app/controllers/agendas_controller.rb b/site/app/controllers/agendas_controller.rb index 18a178d..669f364 100644 --- a/site/app/controllers/agendas_controller.rb +++ b/site/app/controllers/agendas_controller.rb @@ -17,6 +17,8 @@ class AgendasController < ApplicationController data = JSON.parse(request.env["rack.input"].read) Agenda.update_voting_options data['agenda'] Agenda.process_results data data['votes'] + agenda = Agenda.current + agenda.meeting_log = data['lines'] Participation.mark_participations data end diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb index 46cf2d8..5580828 100644 --- a/site/app/models/agenda.rb +++ b/site/app/models/agenda.rb @@ -5,6 +5,7 @@ class Agenda < ActiveRecord::Base fields do meeting_time :datetime email_reminder_sent :boolean, :null => false, :default => false + meeting_log :text, :null => false, :default => '' timestamps end @@ -32,7 +33,10 @@ class Agenda < ActiveRecord::Base end def update_permitted? - acting_user.council_member? || acting_user.administrator? + return false if meeting_log_changed? + return true if acting_user.council_member? + return true if acting_user.administrator? + false end def destroy_permitted? diff --git a/site/db/schema.rb b/site/db/schema.rb index bc8535a..39dd08b 100644 --- a/site/db/schema.rb +++ b/site/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110624141720) do +ActiveRecord::Schema.define(:version => 20110627151021) do create_table "agenda_items", :force => true do |t| t.string "title" @@ -34,6 +34,7 @@ ActiveRecord::Schema.define(:version => 20110624141720) do t.string "state", :default => "open" t.datetime "key_timestamp" t.boolean "email_reminder_sent", :default => false, :null => false + t.text "meeting_log", :default => "", :null => false end add_index "agendas", ["state"], :name => "index_agendas_on_state" diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb index b84f462..12b38a3 100644 --- a/site/spec/models/agenda_spec.rb +++ b/site/spec/models/agenda_spec.rb @@ -31,6 +31,16 @@ describe Agenda do end end + it 'should allow no one to edit or change meeting_log' do + a = Factory(:agenda) + a.meeting_log = 'changed' + + for u in users_factory(AllRoles) + a.should_not be_editable_by(u, :meeting_log) + a.should_not be_updatable_by(u) + end + end + def test_migration(object, migration, prohibited, allowed, final_state) # object - object to migrate # migration - migration name -- cgit v1.2.3-65-gdbad