refinerycms-ballots 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- class BallotsController < ApplicationController
1
+ class BallotsController < ApplicationController
2
2
 
3
3
  before_filter :find_all_ballots
4
4
  before_filter :find_page
@@ -37,7 +37,7 @@ protected
37
37
  if !@member
38
38
  flash[:error] = 'Please double check your number and try again. If it is correct, you may need to contact an admin.'
39
39
  redirect_to login_ballot_votes_path(@ballot)
40
- elsif @member.has_voted_on?(@ballot)
40
+ elsif @ballot.voted_on_by?(@member)
41
41
  flash[:error] = "You have already voted on this ballot, revoting isn't allowed"
42
42
  redirect_to login_ballot_votes_path(@ballot)
43
43
  else
@@ -1,5 +1,9 @@
1
1
  module Admin
2
2
  module BallotsHelper
3
+ def unique_identifier_name
4
+ Member.unique_identifier_name
5
+ end
6
+
3
7
  def link_to_remove_fields name, f
4
8
  link_to_function(name, "remove_fields(this)") + f.hidden_field(:_destroy)
5
9
  end
data/app/models/ballot.rb CHANGED
@@ -48,11 +48,11 @@ class Ballot < ActiveRecord::Base
48
48
  end
49
49
 
50
50
  def voting_members
51
- Member.all.select { |member| member.has_voted_on? self }
51
+ Member.all.select { |member| voted_on_by? member }
52
52
  end
53
53
 
54
54
  def nonvoting_members
55
- Member.all.reject { |member| member.has_voted_on? self }
55
+ Member.all.reject { |member| voted_on_by? member }
56
56
  end
57
57
 
58
58
 
@@ -60,6 +60,11 @@ class Ballot < ActiveRecord::Base
60
60
  return if start_date < end_date
61
61
  errors[:start_date] << 'must be after end date'
62
62
  end
63
+
64
+ def voted_on_by?(member)
65
+ ballot_votes.where(:member_id => member.id, :ballot_id => id).any?
66
+ end
67
+
63
68
  private
64
69
  def today
65
70
  Time.now
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
 
15
15
  <div class="field">
16
- <%= label_tag :unique_identifier %>
16
+ <%= label_tag :unique_identifier, unique_identifier_name %>
17
17
    <%= text_field_tag :unique_identifier %><br />
18
18
  </div>
19
19
 
@@ -1,5 +1,4 @@
1
1
  require 'refinerycms-base'
2
- require 'member_extensions'
3
2
 
4
3
  module Refinery
5
4
  module Ballots
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-ballots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-13 00:00:00.000000000 Z
12
+ date: 2011-09-13 00:00:00.000000000 -05:00
13
+ default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: refinerycms-simple_members
16
- requirement: &70326298798500 !ruby/object:Gem::Requirement
17
+ requirement: &70235273747320 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ~>
@@ -21,10 +22,10 @@ dependencies:
21
22
  version: 0.1.0
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *70326298798500
25
+ version_requirements: *70235273747320
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: factory_girl
27
- requirement: &70326298812240 !ruby/object:Gem::Requirement
28
+ requirement: &70235273746620 !ruby/object:Gem::Requirement
28
29
  none: false
29
30
  requirements:
30
31
  - - ~>
@@ -32,7 +33,7 @@ dependencies:
32
33
  version: 2.1.0
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70326298812240
36
+ version_requirements: *70235273746620
36
37
  description: Ruby on Rails Ballots engine for Refinery CMS
37
38
  email:
38
39
  executables: []
@@ -40,7 +41,6 @@ extensions: []
40
41
  extra_rdoc_files: []
41
42
  files:
42
43
  - lib/generators/refinerycms_ballots_generator.rb
43
- - lib/member_extensions.rb
44
44
  - lib/refinerycms-ballots.rb
45
45
  - lib/tasks/ballots.rake
46
46
  - config/locales/en.yml
@@ -78,6 +78,7 @@ files:
78
78
  - app/views/votes/create.html.erb
79
79
  - app/views/votes/login.html.erb
80
80
  - app/views/votes/new.html.erb
81
+ has_rdoc: true
81
82
  homepage:
82
83
  licenses: []
83
84
  post_install_message:
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  requirements: []
100
101
  rubyforge_project:
101
- rubygems_version: 1.8.10
102
+ rubygems_version: 1.6.2
102
103
  signing_key:
103
104
  specification_version: 3
104
105
  summary: Ballots engine for Refinery CMS
@@ -1,12 +0,0 @@
1
- class Member < ActiveRecord::Base
2
- has_many :ballot_votes
3
-
4
- def number_of_times_voted
5
- ballot_votes.count
6
- end
7
-
8
- def has_voted_on?(ballot)
9
- ballot_votes.where(:ballot_id => ballot.id).any?
10
- end
11
- end
12
-