1 |
commit: 74f38784ddaf2a349ad96dc028a1e73250a34b5d |
2 |
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Jul 26 19:11:48 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 1 10:20:06 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=74f38784 |
7 |
|
8 |
Add and cleanup validations |
9 |
|
10 |
--- |
11 |
site/app/models/approval.rb | 3 +-- |
12 |
site/app/models/user.rb | 4 ++++ |
13 |
site/app/models/vote.rb | 3 +-- |
14 |
site/app/models/voting_option.rb | 2 +- |
15 |
4 files changed, 7 insertions(+), 5 deletions(-) |
16 |
|
17 |
diff --git a/site/app/models/approval.rb b/site/app/models/approval.rb |
18 |
index d36232c..923ba97 100644 |
19 |
--- a/site/app/models/approval.rb |
20 |
+++ b/site/app/models/approval.rb |
21 |
@@ -11,8 +11,7 @@ class Approval < ActiveRecord::Base |
22 |
belongs_to :user, :null => false |
23 |
belongs_to :agenda, :null => false |
24 |
|
25 |
- validates_presence_of :user_id |
26 |
- validates_presence_of :agenda_id |
27 |
+ validates_presence_of :user_id, :agenda_id |
28 |
validates_uniqueness_of :user_id, :scope => :agenda_id |
29 |
|
30 |
def view_permitted?(field) |
31 |
|
32 |
diff --git a/site/app/models/user.rb b/site/app/models/user.rb |
33 |
index 28195f3..cbcd021 100644 |
34 |
--- a/site/app/models/user.rb |
35 |
+++ b/site/app/models/user.rb |
36 |
@@ -12,6 +12,10 @@ class User < ActiveRecord::Base |
37 |
end |
38 |
|
39 |
has_many :votes |
40 |
+ |
41 |
+ validates_presence_of :name, :irc_nick, :email |
42 |
+ validates_uniqueness_of :name, :irc_nick, :email |
43 |
+ |
44 |
# --- Signup lifecycle --- # |
45 |
|
46 |
lifecycle do |
47 |
|
48 |
diff --git a/site/app/models/vote.rb b/site/app/models/vote.rb |
49 |
index 9307cce..a661c5e 100644 |
50 |
--- a/site/app/models/vote.rb |
51 |
+++ b/site/app/models/vote.rb |
52 |
@@ -13,8 +13,7 @@ class Vote < ActiveRecord::Base |
53 |
|
54 |
index [:voting_option_id, :user_id], :unique => true |
55 |
|
56 |
- validates_presence_of :voting_option |
57 |
- validates_presence_of :user |
58 |
+ validates_presence_of :voting_option, :user |
59 |
validates_uniqueness_of :voting_option_id, :scope => :user_id |
60 |
validate :user_voted_only_once |
61 |
# --- Permissions --- # |
62 |
|
63 |
diff --git a/site/app/models/voting_option.rb b/site/app/models/voting_option.rb |
64 |
index 9ece560..78e2fd1 100644 |
65 |
--- a/site/app/models/voting_option.rb |
66 |
+++ b/site/app/models/voting_option.rb |
67 |
@@ -10,7 +10,7 @@ class VotingOption < ActiveRecord::Base |
68 |
belongs_to :agenda_item, :null => false |
69 |
has_many :votes |
70 |
|
71 |
- validates_presence_of :agenda_item |
72 |
+ validates_presence_of :agenda_item, :description |
73 |
validates_uniqueness_of :description, :scope => :agenda_item_id |
74 |
|
75 |
def name |