refinerycms-ballots 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/db/migrate/create_ballots.rb +50 -0
- data/db/migrate/create_vote_tables.rb +35 -0
- data/db/seeds/ballots.rb +22 -0
- data/public/javascripts/refinerycms-ballots.js +11 -0
- data/public/stylesheets/ballots.css +52 -0
- metadata +13 -10
@@ -0,0 +1,50 @@
|
|
1
|
+
class CreateBallots < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :ballots do |t|
|
5
|
+
t.string :title
|
6
|
+
t.integer :position
|
7
|
+
t.datetime :start_date
|
8
|
+
t.datetime :end_date
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
create_table :offices do |t|
|
13
|
+
t.string :title
|
14
|
+
t.integer :number_of_positions, :default => 1
|
15
|
+
t.references :ballot
|
16
|
+
t.integer :position
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table :candidates do |t|
|
21
|
+
t.string :name
|
22
|
+
t.references :office
|
23
|
+
t.integer :position
|
24
|
+
t.timestamps
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
add_index :ballots , :id
|
29
|
+
add_index :offices , :id
|
30
|
+
add_index :candidates , :id
|
31
|
+
|
32
|
+
load(Rails.root.join('db', 'seeds', 'ballots.rb'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.down
|
36
|
+
[:ballots, :offices, :candidates].each do |table_name|
|
37
|
+
if defined?(UserPlugin)
|
38
|
+
UserPlugin.destroy_all :name => table_name.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
if defined?(Page)
|
42
|
+
Page.delete_all :link_url => "/#{table_name}"
|
43
|
+
end
|
44
|
+
|
45
|
+
drop_table table_name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class CreateVoteTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :ballot_votes do |t|
|
4
|
+
t.references :member
|
5
|
+
t.references :ballot
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :office_votes do |t|
|
10
|
+
t.references :ballot_vote
|
11
|
+
t.references :office
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table :candidate_votes do |t|
|
15
|
+
t.references :office_vote
|
16
|
+
t.references :candidate
|
17
|
+
t.boolean :voted, :default => false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.down
|
22
|
+
[:ballot_votes, :office_votes, :candidate_votes].each do |table_name|
|
23
|
+
if defined?(UserPlugin)
|
24
|
+
UserPlugin.destroy_all :name => table_name.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
if defined?(Page)
|
28
|
+
Page.delete_all :link_url => "/#{table_name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
drop_table table_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/db/seeds/ballots.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
if defined?(User)
|
2
|
+
User.all.each do |user|
|
3
|
+
if user.plugins.where(:name => 'ballots').blank?
|
4
|
+
user.plugins.create(:name => 'ballots',
|
5
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(Page)
|
11
|
+
page = Page.create(
|
12
|
+
:title => 'Ballots',
|
13
|
+
:link_url => '/ballots',
|
14
|
+
:deletable => false,
|
15
|
+
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
|
16
|
+
:menu_match => '^/ballots(\/|\/.+?|)$',
|
17
|
+
:show_in_menu => false,
|
18
|
+
)
|
19
|
+
Page.default_parts.each do |default_page_part|
|
20
|
+
page.parts.create(:title => default_page_part, :body => nil)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
function remove_fields(link) {
|
2
|
+
$(link).prev("input[type=hidden]").val("1");
|
3
|
+
$(link).closest(".fields").hide();
|
4
|
+
}
|
5
|
+
|
6
|
+
function add_fields(link, association, content) {
|
7
|
+
var new_id = new Date().getTime();
|
8
|
+
var regexp = new RegExp("new_" + association, "g");
|
9
|
+
$(link).parent().before(content.replace(regexp, new_id));
|
10
|
+
}
|
11
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
.ballot ol li, .ballot_vote ol li {
|
2
|
+
list-style: none;
|
3
|
+
}
|
4
|
+
|
5
|
+
#body_content .left-column {
|
6
|
+
float: left;
|
7
|
+
padding-left: 50px;
|
8
|
+
margin: 0px;
|
9
|
+
width: 45%;
|
10
|
+
}
|
11
|
+
|
12
|
+
#body_content .right-column {
|
13
|
+
float: right;
|
14
|
+
margin: 0px;
|
15
|
+
width: 45%;
|
16
|
+
}
|
17
|
+
|
18
|
+
form div.office.fields {
|
19
|
+
background-color: #DDD;
|
20
|
+
padding: 20px;
|
21
|
+
margin: 30px 200px 0px 10px; /* 200px RHS is kind of a hack, just to push the next element to the next line */
|
22
|
+
display: inline-block; /* inline-block is so the background shrink-wraps the contents of the element */
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
#content form .office.fields > .field {
|
27
|
+
display: inline-block;
|
28
|
+
width: inherit;
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
form .office.fields > label {
|
33
|
+
margin-top: 0px;
|
34
|
+
margin-left: 0px;
|
35
|
+
width: 50%;
|
36
|
+
}
|
37
|
+
|
38
|
+
/* apparently this selector won't work on ie8, but not important enough to care */
|
39
|
+
form .office.fields > .field:last-of-type {
|
40
|
+
margin-left: 15px;
|
41
|
+
}
|
42
|
+
|
43
|
+
#content form .start_date {
|
44
|
+
display: inline-block;
|
45
|
+
width: inherit;
|
46
|
+
}
|
47
|
+
|
48
|
+
#content form .end_date {
|
49
|
+
display: inline-block;
|
50
|
+
width: inherit;
|
51
|
+
margin-left: 50px;
|
52
|
+
}
|
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.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,23 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-13 00:00:00.000000000
|
13
|
-
default_executable:
|
12
|
+
date: 2011-09-13 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: refinerycms-simple_members
|
17
|
-
requirement: &
|
16
|
+
requirement: &70356347656420 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.1.
|
21
|
+
version: 0.1.7
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *70356347656420
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: factory_girl
|
28
|
-
requirement: &
|
27
|
+
requirement: &70356347655700 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ~>
|
@@ -33,7 +32,7 @@ dependencies:
|
|
33
32
|
version: 2.1.0
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *70356347655700
|
37
36
|
description: Ruby on Rails Ballots engine for Refinery CMS
|
38
37
|
email:
|
39
38
|
executables: []
|
@@ -78,7 +77,11 @@ files:
|
|
78
77
|
- app/views/votes/create.html.erb
|
79
78
|
- app/views/votes/login.html.erb
|
80
79
|
- app/views/votes/new.html.erb
|
81
|
-
|
80
|
+
- db/migrate/create_ballots.rb
|
81
|
+
- db/migrate/create_vote_tables.rb
|
82
|
+
- db/seeds/ballots.rb
|
83
|
+
- public/javascripts/refinerycms-ballots.js
|
84
|
+
- public/stylesheets/ballots.css
|
82
85
|
homepage:
|
83
86
|
licenses: []
|
84
87
|
post_install_message:
|
@@ -99,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
102
|
version: '0'
|
100
103
|
requirements: []
|
101
104
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.8.10
|
103
106
|
signing_key:
|
104
107
|
specification_version: 3
|
105
108
|
summary: Ballots engine for Refinery CMS
|