From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QOuvw-0003Ov-Gp for garchives@archives.gentoo.org; Tue, 24 May 2011 16:58:16 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D3D241C4E1; Tue, 24 May 2011 16:58:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 938DB1C586 for ; Tue, 24 May 2011 16:58:03 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0EC4E1B4037 for ; Tue, 24 May 2011 16:58:03 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6616080508 for ; Tue, 24 May 2011 16:58:02 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: <8fcbeab8bf791e9b2b793bb85ee5faea80338ac7.betelgeuse@gentoo> Subject: [gentoo-commits] proj/council-webapp:master commit in: site/db/, site/features/, site/app/models/, site/spec/models/, site/spec/, ... X-VCS-Repository: proj/council-webapp X-VCS-Files: site/app/models/agenda.rb site/app/models/agenda_item.rb site/app/models/participation.rb site/app/viewhints/agenda_hints.rb site/db/schema.rb site/features/participations.feature site/features/step_definitions/participations_steps.rb site/spec/factories.rb site/spec/models/agenda_item_spec.rb site/spec/models/agenda_spec.rb site/spec/models/participation_spec.rb X-VCS-Directories: site/db/ site/features/ site/app/models/ site/spec/models/ site/spec/ site/features/step_definitions/ site/app/viewhints/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 8fcbeab8bf791e9b2b793bb85ee5faea80338ac7 Date: Tue, 24 May 2011 16:58:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: b63221fadac97da07c2e10c7e7a19b11 commit: 8fcbeab8bf791e9b2b793bb85ee5faea80338ac7 Author: Joachim Filip Ignacy Bartosik gmail com= > AuthorDate: Tue May 17 15:14:01 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Tue May 24 16:55:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/council-webap= p.git;a=3Dcommit;h=3D8fcbeab8 Basic meeting participation tracing When archiving agenda mark all council members as participants. Remember their names and irc_nicks. --- site/app/models/agenda.rb | 10 +++++- site/app/models/agenda_item.rb | 4 +- site/app/models/participation.rb | 34 ++++++++++++++= ++++++ site/app/viewhints/agenda_hints.rb | 2 +- site/db/schema.rb | 14 +++++++- site/features/participations.feature | 10 ++++++ .../step_definitions/participations_steps.rb | 24 ++++++++++++++ site/spec/factories.rb | 2 + site/spec/models/agenda_item_spec.rb | 2 +- site/spec/models/agenda_spec.rb | 11 ++++++ site/spec/models/participation_spec.rb | 20 +++++++++++ 11 files changed, 127 insertions(+), 6 deletions(-) diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb index 5998ae8..f8f90df 100644 --- a/site/app/models/agenda.rb +++ b/site/app/models/agenda.rb @@ -8,6 +8,7 @@ class Agenda < ActiveRecord::Base end =20 has_many :agenda_items + has_many :participations =20 lifecycle do state :open, :default =3D> true @@ -16,7 +17,14 @@ class Agenda < ActiveRecord::Base transition :close, {:open =3D> :submissions_closed}, :available_to =3D= > '::Agenda.transitions_available(acting_user)' transition :reopen, {:submissions_closed=3D> :open}, :available_to =3D= > '::Agenda.transitions_available(acting_user)' transition :archive, {:submissions_closed =3D> :old}, :available_to = =3D> '::Agenda.transitions_available(acting_user)' do - Agenda.new.save! + ActiveRecord::Base.transaction do + Agenda.new.save! + ::User.council_member_is(true).each do |participant| + Participation.create! :irc_nick =3D> participant.irc_nick, + :participant =3D> participant, + :agenda =3D> self + end + end end end =20 diff --git a/site/app/models/agenda_item.rb b/site/app/models/agenda_item= .rb index 1bb3a36..f5108bd 100644 --- a/site/app/models/agenda_item.rb +++ b/site/app/models/agenda_item.rb @@ -21,7 +21,7 @@ class AgendaItem < ActiveRecord::Base end =20 def update_permitted? - return false if agenda._?.state =3D=3D 'archived' + return false if agenda._?.state =3D=3D 'old' return false if user_changed? return true if acting_user.council_member? return true if acting_user.administrator? @@ -42,7 +42,7 @@ class AgendaItem < ActiveRecord::Base def edit_permitted?(field) return false if field =3D=3D :rejected && !agenda.nil? return false if field =3D=3D :agenda && rejected? - return false if agenda._?.state =3D=3D 'archived' + return false if agenda._?.state =3D=3D 'old' return false if field =3D=3D :user return true if acting_user.administrator? return true if acting_user.council_member? diff --git a/site/app/models/participation.rb b/site/app/models/participa= tion.rb new file mode 100644 index 0000000..95c4142 --- /dev/null +++ b/site/app/models/participation.rb @@ -0,0 +1,34 @@ +class Participation < ActiveRecord::Base + + hobo_model # Don't put anything above this + + fields do + irc_nick :string + timestamps + end + + belongs_to :participant, :class_name =3D> 'User' + belongs_to :agenda + + # --- Permissions --- # + + def create_permitted? + false + end + + def update_permitted? + false + end + + def destroy_permitted? + false + end + + def view_permitted?(field) + true + end + + def name + participant.name + end +end diff --git a/site/app/viewhints/agenda_hints.rb b/site/app/viewhints/agen= da_hints.rb index 05c7b96..46daf34 100644 --- a/site/app/viewhints/agenda_hints.rb +++ b/site/app/viewhints/agenda_hints.rb @@ -1,5 +1,5 @@ class AgendaHints < Hobo::ViewHints =20 - children :agenda_items + children :agenda_items, :participations =20 end diff --git a/site/db/schema.rb b/site/db/schema.rb index edd7ee0..cf1a791 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. =20 -ActiveRecord::Schema.define(:version =3D> 20110523180314) do +ActiveRecord::Schema.define(:version =3D> 20110523180453) do =20 create_table "agenda_items", :force =3D> true do |t| t.string "title" @@ -36,6 +36,18 @@ ActiveRecord::Schema.define(:version =3D> 201105231803= 14) do =20 add_index "agendas", ["state"], :name =3D> "index_agendas_on_state" =20 + create_table "participations", :force =3D> true do |t| + t.string "name" + t.string "irc_nick" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "participant_id" + t.integer "agenda_id" + end + + add_index "participations", ["agenda_id"], :name =3D> "index_participa= tions_on_agenda_id" + add_index "participations", ["participant_id"], :name =3D> "index_part= icipations_on_participant_id" + create_table "users", :force =3D> true do |t| t.string "salt", :limit =3D> 40 t.string "remember_token" diff --git a/site/features/participations.feature b/site/features/partici= pations.feature new file mode 100644 index 0000000..69cb5dd --- /dev/null +++ b/site/features/participations.feature @@ -0,0 +1,10 @@ +Feature: In order to track presence on the council meetings + I want the application to store participations + + Scenario: When archiving agenda mark all council members as participan= ts + Given some council members + And I am logged in as council member + And an closed agenda + When I am on the current agenda page + And I archive current agenda + Then I should see all council members as participants diff --git a/site/features/step_definitions/participations_steps.rb b/sit= e/features/step_definitions/participations_steps.rb new file mode 100644 index 0000000..fe3966c --- /dev/null +++ b/site/features/step_definitions/participations_steps.rb @@ -0,0 +1,24 @@ +Given /^some council members$/ do + (1..8).each do |n| + u =3D User.new + u.name =3D "Member no #{n}" + u.email =3D "member-#{n}@example.com" + u.irc_nick =3D "member-#{n}" + u.password =3D "Example" + u.council_member =3D true + u.save! + end +end + +Given /^I am logged in as council member$/ do + When 'I am on the login page' + When 'I fill in "login" with "member-1@example.com"' + When 'I fill in "password" with "Example"' + When 'I press "Login"' +end + +Then /^I should see all council members as participants$/ do + User.council_member_is(true).each do |m| + Then "I should see \"#{m.name}\" within \".collection.participations= .participations-collection\"" + end +end diff --git a/site/spec/factories.rb b/site/spec/factories.rb index 3211032..7405ee9 100644 --- a/site/spec/factories.rb +++ b/site/spec/factories.rb @@ -11,3 +11,5 @@ end Factory.define :agenda do |a|; end =20 Factory.define :agenda_item do |a|; end + +Factory.define :participation do |p|; end diff --git a/site/spec/models/agenda_item_spec.rb b/site/spec/models/agen= da_item_spec.rb index 95d7659..3df2a59 100644 --- a/site/spec/models/agenda_item_spec.rb +++ b/site/spec/models/agenda_item_spec.rb @@ -49,7 +49,7 @@ describe AgendaItem do =20 it 'should allow no one edit and update items assigned to archived age= nda' do owner =3D Factory(:user) - agenda =3D Factory(:agenda, :state =3D> 'archived') + agenda =3D Factory(:agenda, :state =3D> 'old') a =3D Factory(:agenda_item, :user =3D> owner, :agenda =3D> agenda) for u in users_factory(AllRoles) + [owner] a.should_not be_editable_by(u) diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_sp= ec.rb index 0a69551..14a1178 100644 --- a/site/spec/models/agenda_spec.rb +++ b/site/spec/models/agenda_spec.rb @@ -93,4 +93,15 @@ describe Agenda do a1.meeting_time.strftime('%Y-%m-%d').should =3D=3D today a2.meeting_time.strftime('%Y-%m-%d').should_not =3D=3D today end + + it 'should add all council members and only them as participants when = archived' do + users_factory(:user, :admin) + users_factory(:council, :council) + council_names =3D User.council_member_is(true).collect{ |c| c.name } + agenda =3D Factory(:agenda, :state =3D> 'submissions_closed') + agenda.lifecycle.archive!(User.council_member_is(true).first) + + (council_names - agenda.participations.*.participant.*.name).should = be_empty + (agenda.participations.*.participant.*.name - council_names).should = be_empty + end end diff --git a/site/spec/models/participation_spec.rb b/site/spec/models/pa= rticipation_spec.rb new file mode 100644 index 0000000..eb2ecba --- /dev/null +++ b/site/spec/models/participation_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe Participation do + it 'should not allow anyone to create, edit, update or destroy' do + p =3D Factory(:participation) + for u in users_factory(AllRoles) + p.should_not be_creatable_by(u) + p.should_not be_editable_by(u) + p.should_not be_updatable_by(u) + p.should_not be_destroyable_by(u) + end + end + + it 'should allow everybody to view' do + p =3D Factory(:participation) + for u in users_factory(AllRoles) + p.should be_viewable_by(u) + end + end +end