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 1Qjvm4-0002nZ-O3 for garchives@archives.gentoo.org; Thu, 21 Jul 2011 16:06:57 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0ACDE21C2D1; Thu, 21 Jul 2011 16:06:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BEED021C2D1 for ; Thu, 21 Jul 2011 16:06:33 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 469461B4013 for ; Thu, 21 Jul 2011 16:06:33 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 454548003D for ; Thu, 21 Jul 2011 16:06:32 +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: Subject: [gentoo-commits] proj/council-webapp:master commit in: site/db/ X-VCS-Repository: proj/council-webapp X-VCS-Files: site/db/seed.yml site/db/seeds.rb X-VCS-Directories: site/db/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: c531d629ebe56626b5263a96417701093dabf652 Date: Thu, 21 Jul 2011 16:06:32 +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: 113c556c4c93ff743c213ef5d86cbf94 commit: c531d629ebe56626b5263a96417701093dabf652 Author: Joachim Filip Ignacy Bartosik gmail com= > AuthorDate: Tue Jul 12 11:51:52 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Jul 13 16:12:09 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/council-webap= p.git;a=3Dcommit;h=3Dc531d629 Seed database for demos --- site/db/seed.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ site/db/seeds.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-) diff --git a/site/db/seed.yml b/site/db/seed.yml new file mode 100644 index 0000000..df649e8 --- /dev/null +++ b/site/db/seed.yml @@ -0,0 +1,42 @@ +- + state: open + agenda_items: + - + title: What shall we do with drunken sailor + body: Earl-aye in the morning? + voting_options: + - Shave his belly with a rusty razor + - "Put him in the long boat till he's sober" + - Put him in the scuppers with a hose-pipe on him + - "Put him in bed with the captain's daughter" + - + title: Some proposal + body: Description of some proposal + voting_options: + - Accept + - Reject +- + state: old + agenda_items: + - + title: Accepted item + body: Some item that was acepted on previous meeting + voting_options: + - Accept + - Reject + - + title: Rejected item + body: Some item that was rejected on previous meeting + voting_options: + - Accept + - Reject +- + agenda_items: + - + title: Pending idea + body: Some idea that was neither added to agenda nor rejected. + rejected: false + - + title: Rejected idea + body: Some idea that council rejected to discuss on. + rejected: true diff --git a/site/db/seeds.rb b/site/db/seeds.rb new file mode 100644 index 0000000..f276aa6 --- /dev/null +++ b/site/db/seeds.rb @@ -0,0 +1,46 @@ +require File.expand_path("../../spec/factories.rb", __FILE__) +require File.expand_path("../../spec/support/users_factory.rb", __FILE__= ) + +def vote(user, item, option_description) + option =3D VotingOption.agenda_item_is(item).description_is(option_des= cription).first + Factory(:vote, :voting_option =3D> option, :user =3D> user, :council_v= ote =3D> true) +end + +def make_votes(council, item_title, accepting_votes) + item =3D AgendaItem.find_by_title(item_title) + council.inject(0) do |counter, user| + if counter < accepting_votes + vote(user, item, "Accept") + else + vote(user, item, "Reject") + end + counter +=3D 1 + end +end + +yml_seed_path =3D File.expand_path("../seed.yml", __FILE__) +yml_seed_file =3D File.open(yml_seed_path) +seed =3D YAML::load(yml_seed_file) + +seed.each do |agenda_desc| + state =3D agenda_desc['state'] + agenda =3D state.nil? ? nil : Factory(:agenda, :state =3D> state) + + agenda_desc['agenda_items']._?.each do |item_desc| + rejected =3D item_desc['rejected'] + rejected =3D rejected.nil? ? false : rejected + item =3D Factory(:agenda_item, :title =3D> item_desc['title'], + :body =3D> item_desc['body'], + :rejected =3D> rejected, + :agenda =3D> agenda) + + item_desc['voting_options']._?.each do |option_desc| + Factory(:voting_option, :description =3D> option_desc, :agenda_ite= m =3D> item) + end + end +end + +council =3D users_factory([:council] * 7) + +make_votes(council, "Accepted item", 5) +make_votes(council, "Rejected item", 3)