public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
Date: Mon,  1 Aug 2011 14:38:16 +0000 (UTC)	[thread overview]
Message-ID: <74f38784ddaf2a349ad96dc028a1e73250a34b5d.betelgeuse@gentoo> (raw)

commit:     74f38784ddaf2a349ad96dc028a1e73250a34b5d
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jul 26 19:11:48 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Aug  1 10:20:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=74f38784

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 => false
   belongs_to :agenda, :null => false
 
-  validates_presence_of :user_id
-  validates_presence_of :agenda_id
+  validates_presence_of :user_id, :agenda_id
   validates_uniqueness_of :user_id, :scope => :agenda_id
 
   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
 
   has_many  :votes
+
+  validates_presence_of :name, :irc_nick, :email
+  validates_uniqueness_of :name, :irc_nick, :email
+
   # --- Signup lifecycle --- #
 
   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
 
   index [:voting_option_id, :user_id], :unique => true
 
-  validates_presence_of :voting_option
-  validates_presence_of :user
+  validates_presence_of :voting_option, :user
   validates_uniqueness_of :voting_option_id, :scope => :user_id
   validate :user_voted_only_once
   # --- Permissions --- #

diff --git a/site/app/models/voting_option.rb b/site/app/models/voting_option.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 => false
   has_many    :votes
 
-  validates_presence_of :agenda_item
+  validates_presence_of :agenda_item, :description
   validates_uniqueness_of :description, :scope => :agenda_item_id
 
   def name



             reply	other threads:[~2011-08-01 14:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 14:38 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-01 14:38 [gentoo-commits] proj/council-webapp:master commit in: site/app/models/ Petteri Räty
2011-08-01 14:38 Petteri Räty
2011-08-01 14:38 Petteri Räty
2011-08-01 14:38 Petteri Räty
2011-06-18 15:42 Petteri Räty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74f38784ddaf2a349ad96dc028a1e73250a34b5d.betelgeuse@gentoo \
    --to=betelgeuse@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox