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 1Qntds-0002yq-Ju for garchives@archives.gentoo.org; Mon, 01 Aug 2011 14:38:52 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 482F521C1DA; Mon, 1 Aug 2011 14:38:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 1222F21C1DA for ; Mon, 1 Aug 2011 14:38:18 +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 7C0312AC00C for ; Mon, 1 Aug 2011 14:38:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B2E6045EFD for ; Mon, 1 Aug 2011 14:38:16 +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: <74f38784ddaf2a349ad96dc028a1e73250a34b5d.betelgeuse@gentoo> Subject: [gentoo-commits] proj/council-webapp:master commit in: site/app/models/ X-VCS-Repository: proj/council-webapp X-VCS-Files: site/app/models/approval.rb site/app/models/user.rb site/app/models/vote.rb site/app/models/voting_option.rb X-VCS-Directories: site/app/models/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 74f38784ddaf2a349ad96dc028a1e73250a34b5d Date: Mon, 1 Aug 2011 14:38:16 +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: 908a3baa8d86a083d2bdca6214b8cbd6 commit: 74f38784ddaf2a349ad96dc028a1e73250a34b5d Author: Joachim Filip Ignacy Bartosik gmail com= > AuthorDate: Tue Jul 26 19:11:48 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Mon Aug 1 10:20:06 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/council-webap= p.git;a=3Dcommit;h=3D74f38784 Add and cleanup validations --- site/app/models/approval.rb | 3 +-- site/app/models/user.rb | 4 ++++ site/app/models/vote.rb | 3 +-- site/app/models/voting_option.rb | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/site/app/models/approval.rb b/site/app/models/approval.rb index d36232c..923ba97 100644 --- a/site/app/models/approval.rb +++ b/site/app/models/approval.rb @@ -11,8 +11,7 @@ class Approval < ActiveRecord::Base belongs_to :user, :null =3D> false belongs_to :agenda, :null =3D> false =20 - validates_presence_of :user_id - validates_presence_of :agenda_id + validates_presence_of :user_id, :agenda_id validates_uniqueness_of :user_id, :scope =3D> :agenda_id =20 def view_permitted?(field) diff --git a/site/app/models/user.rb b/site/app/models/user.rb index 28195f3..cbcd021 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -12,6 +12,10 @@ class User < ActiveRecord::Base end =20 has_many :votes + + validates_presence_of :name, :irc_nick, :email + validates_uniqueness_of :name, :irc_nick, :email + # --- Signup lifecycle --- # =20 lifecycle do diff --git a/site/app/models/vote.rb b/site/app/models/vote.rb index 9307cce..a661c5e 100644 --- a/site/app/models/vote.rb +++ b/site/app/models/vote.rb @@ -13,8 +13,7 @@ class Vote < ActiveRecord::Base =20 index [:voting_option_id, :user_id], :unique =3D> true =20 - validates_presence_of :voting_option - validates_presence_of :user + validates_presence_of :voting_option, :user validates_uniqueness_of :voting_option_id, :scope =3D> :user_id validate :user_voted_only_once # --- Permissions --- # diff --git a/site/app/models/voting_option.rb b/site/app/models/voting_op= tion.rb index 9ece560..78e2fd1 100644 --- a/site/app/models/voting_option.rb +++ b/site/app/models/voting_option.rb @@ -10,7 +10,7 @@ class VotingOption < ActiveRecord::Base belongs_to :agenda_item, :null =3D> false has_many :votes =20 - validates_presence_of :agenda_item + validates_presence_of :agenda_item, :description validates_uniqueness_of :description, :scope =3D> :agenda_item_id =20 def name