* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-06-18 15:42 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-06-18 15:42 UTC (permalink / raw
To: gentoo-commits
commit: e3d89bd4b32a0348eca0a736261d32d625345717
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Mon Jun 13 13:04:32 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun 17 18:39:26 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=e3d89bd4
Change names to communicative
To improve UncommunicativeName reports
---
site/app/models/agenda.rb | 28 ++++++++++++++--------------
site/app/models/proxy.rb | 6 +++---
site/app/models/user.rb | 4 ++--
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb
index 8f05e09..16dc2e7 100644
--- a/site/app/models/agenda.rb
+++ b/site/app/models/agenda.rb
@@ -43,8 +43,8 @@ class Agenda < ActiveRecord::Base
true
end
- before_create do |a|
- a.meeting_time ||= Time.now
+ before_create do |agenda|
+ agenda.meeting_time ||= Time.now
end
def self.current
@@ -58,14 +58,14 @@ class Agenda < ActiveRecord::Base
end
def self.process_results(results)
- a = Agenda.current
+ agenda = Agenda.current
for item_title in results.keys
- i = AgendaItem.first :conditions => { :agenda_id => a, :title => item_title }
+ item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_title }
votes = results[item_title]
for voter in votes.keys
- o = VotingOption.first :conditions => { :agenda_item_id => i.id, :description => votes[voter] }
- u = ::User.find_by_irc_nick voter
- Vote.create! :voting_option => o, :user => u
+ option = VotingOption.first :conditions => { :agenda_item_id => item.id, :description => votes[voter] }
+ user = ::User.find_by_irc_nick voter
+ Vote.create! :voting_option => option, :user => user
end
end
end
@@ -137,16 +137,16 @@ class Agenda < ActiveRecord::Base
'users' => Agenda.voters}
end
- before_save do |a|
- return true if a.new_record?
- return true unless a.meeting_time_changed?
- a.email_reminder_sent = false
+ before_save do |agenda|
+ return true if agenda.new_record?
+ return true unless agenda.meeting_time_changed?
+ agenda.email_reminder_sent = false
true
end
- after_save do |a|
- if a.new_record? or a.meeting_time_changed?
- Agenda.delay(:run_at => a.time_for_reminders(:email)).send_current_agenda_reminders
+ after_save do |agenda|
+ if agenda.new_record? or agenda.meeting_time_changed?
+ Agenda.delay(:run_at => agenda.time_for_reminders(:email)).send_current_agenda_reminders
end
end
diff --git a/site/app/models/proxy.rb b/site/app/models/proxy.rb
index 7be0a0b..1fdb93f 100644
--- a/site/app/models/proxy.rb
+++ b/site/app/models/proxy.rb
@@ -40,9 +40,9 @@ class Proxy < ActiveRecord::Base
true
end
- before_create do |p|
- p.council_member_nick = p.council_member.irc_nick
- p.proxy_nick = p.proxy.irc_nick
+ before_create do |proxy|
+ proxy.council_member_nick = proxy.council_member.irc_nick
+ proxy.proxy_nick = proxy.proxy.irc_nick
end
protected
diff --git a/site/app/models/user.rb b/site/app/models/user.rb
index 087f0fe..0ca3e33 100644
--- a/site/app/models/user.rb
+++ b/site/app/models/user.rb
@@ -66,9 +66,9 @@ class User < ActiveRecord::Base
end
end
- a = ['Was on last meeting', 'Skipped last meeting',
+ text_statuses = ['Was on last meeting', 'Skipped last meeting',
'Slacker', 'No more a council']
- a[num_status]
+ text_statuses[num_status]
end
def can_appoint_a_proxy?(user)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-08-01 14:38 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-08-01 14:38 UTC (permalink / raw
To: gentoo-commits
commit: 42f0d698dbbe7bf18ec858afb294dedd07fc2d0a
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jul 26 15:30:54 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 15:30:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=42f0d698
A little cleanup in User class
---
site/app/models/user.rb | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/site/app/models/user.rb b/site/app/models/user.rb
index bba0a6e..28195f3 100644
--- a/site/app/models/user.rb
+++ b/site/app/models/user.rb
@@ -62,15 +62,14 @@ class User < ActiveRecord::Base
return 'There were no meetings in this term yet' if agendas.count.zero?
for agenda in agendas
- if Participation.participant_is(self).agenda_is(agenda).count == 0
+ if Participation.participant_is(self).agenda_is(agenda).count.zero?
num_status += 1 if num_status < 3
else
num_status = 0 if num_status == 1
end
end
- text_statuses = ['Was on last meeting', 'Skipped last meeting',
- 'Slacker', 'No more a council']
+ text_statuses = ['Was on last meeting', 'Skipped last meeting', 'Slacker', 'No more a council']
text_statuses[num_status]
end
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-08-01 14:38 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-08-01 14:38 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-08-01 14:38 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-08-01 14:38 UTC (permalink / raw
To: gentoo-commits
commit: 17a5bb7652293de6b1129df9cc7cbd752c676394
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jul 26 15:16:57 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 15:16:57 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=17a5bb76
Use hobo scopes where possible
Not Model.find :conditions => { ... }
---
site/app/models/agenda.rb | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb
index 29c57f5..4039d0c 100644
--- a/site/app/models/agenda.rb
+++ b/site/app/models/agenda.rb
@@ -77,7 +77,7 @@ class Agenda < ActiveRecord::Base
def self.update_voting_options(options)
agenda = Agenda.current
options.each do |item_info|
- item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_info.first }
+ item = AgendaItem.agenda_id_is(agenda).title_is(item_info.first).first
item.update_voting_options(item_info[1])
end
end
@@ -85,10 +85,10 @@ class Agenda < ActiveRecord::Base
def self.process_results(results)
agenda = Agenda.current
for item_title in results.keys
- item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_title }
+ item = AgendaItem.agenda_id_is(agenda.id).title_is(item_title).first
votes = results[item_title]
for voter in votes.keys
- option = VotingOption.first :conditions => { :agenda_item_id => item.id, :description => votes[voter] }
+ option = VotingOption.agenda_item_id_is(item.id).description_is(votes[voter]).first
user = ::User.find_by_irc_nick voter
Vote.vote_for_option(user, option, true)
end
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-08-01 14:38 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-08-01 14:38 UTC (permalink / raw
To: gentoo-commits
commit: 6c58eb40efb9f6eedc2f9d31b3ecf00780c25ad5
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jul 26 14:49:48 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 15:06:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=6c58eb40
Cleanup Agenda.update_voting_options
---
site/app/models/agenda.rb | 13 +------------
site/app/models/agenda_item.rb | 12 ++++++++++++
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb
index 75a9a23..29c57f5 100644
--- a/site/app/models/agenda.rb
+++ b/site/app/models/agenda.rb
@@ -78,18 +78,7 @@ class Agenda < ActiveRecord::Base
agenda = Agenda.current
options.each do |item_info|
item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_info.first }
- new_descriptions = item_info[1]
- old_descriptions = item.voting_options.*.description
-
- (old_descriptions - new_descriptions).each do |description|
- option = VotingOption.first :conditions => { :agenda_item_id => item.id,
- :description => description }
- option.destroy
- end
-
- (new_descriptions - old_descriptions ).each do |description|
- VotingOption.create! :agenda_item => item, :description => description
- end
+ item.update_voting_options(item_info[1])
end
end
diff --git a/site/app/models/agenda_item.rb b/site/app/models/agenda_item.rb
index 938e2e1..e8874ff 100644
--- a/site/app/models/agenda_item.rb
+++ b/site/app/models/agenda_item.rb
@@ -56,6 +56,18 @@ class AgendaItem < ActiveRecord::Base
return acting_user == user if [nil, :title, :discussion, :body].include?(field)
end
+ def update_voting_options(new_descriptions)
+ old_descriptions = voting_options.*.description
+
+ (old_descriptions - new_descriptions).each do |description|
+ option = VotingOption.agenda_item_id_is(id).description_is(description).first
+ option.destroy
+ end
+
+ (new_descriptions - old_descriptions ).each do |description|
+ VotingOption.create! :agenda_item => self, :description => description
+ end
+ end
protected
# Updated discussion time for a single agenda item
# protected because we want to call it only from
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
@ 2011-08-01 14:38 Petteri Räty
0 siblings, 0 replies; 6+ messages in thread
From: Petteri Räty @ 2011-08-01 14:38 UTC (permalink / raw
To: gentoo-commits
commit: 2a32f6bb142f57163ac3da2c90f3b13b21ce6ed2
Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jul 26 15:33:31 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Aug 1 10:19:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=2a32f6bb
Add line in site/app/models/proxy.rb for better readability
---
site/app/models/proxy.rb | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/site/app/models/proxy.rb b/site/app/models/proxy.rb
index 00630f8..cb6052d 100644
--- a/site/app/models/proxy.rb
+++ b/site/app/models/proxy.rb
@@ -50,6 +50,7 @@ class Proxy < ActiveRecord::Base
return if council_member.nil?
errors.add(:council_member, 'must be council member') unless council_member.council_member?
end
+
def proxy_must_not_be_council_member
return if proxy.nil?
errors.add(:proxy, 'must not be council member') if proxy.council_member?
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-01 14:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-01 14:38 [gentoo-commits] proj/council-webapp:master commit in: site/app/models/ Petteri Räty
-- strict thread matches above, loose matches on Subject: below --
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-08-01 14:38 Petteri Räty
2011-06-18 15:42 Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox