fine_print 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +74 -45
- data/Rakefile +9 -9
- data/app/assets/javascripts/application.js~ +16 -0
- data/app/assets/javascripts/fine_print/application.js +8 -2
- data/app/controllers/fine_print/application_controller.rb +9 -7
- data/app/controllers/fine_print/application_controller.rb~ +9 -7
- data/app/controllers/fine_print/contracts_controller.rb +79 -0
- data/app/controllers/fine_print/contracts_controller.rb~ +79 -0
- data/app/controllers/fine_print/home_controller.rb +1 -11
- data/app/controllers/fine_print/home_controller.rb~ +2 -11
- data/app/controllers/fine_print/signatures_controller.rb +14 -0
- data/app/controllers/fine_print/signatures_controller.rb~ +14 -0
- data/app/helpers/fine_print/application_helper.rb +7 -0
- data/app/helpers/fine_print/application_helper.rb~ +7 -0
- data/app/helpers/fine_print/contracts_helper.rb~ +7 -0
- data/app/models/fine_print/contract.rb +96 -0
- data/app/models/fine_print/contract.rb~ +100 -0
- data/app/models/fine_print/signature.rb +25 -0
- data/app/models/fine_print/signature.rb~ +25 -0
- data/app/views/fine_print/contracts/_form.html.erb +35 -0
- data/app/views/fine_print/contracts/_form.html.erb~ +35 -0
- data/app/views/fine_print/contracts/edit.html.erb +10 -0
- data/app/views/fine_print/contracts/index.html.erb +43 -0
- data/app/views/fine_print/contracts/index.html.erb~ +43 -0
- data/app/views/fine_print/contracts/new.html.erb +9 -0
- data/app/views/fine_print/contracts/new_version.html.erb +9 -0
- data/app/views/fine_print/contracts/show.html.erb +33 -0
- data/app/views/fine_print/contracts/show.html.erb~ +35 -0
- data/app/views/fine_print/home/index.html.erb +15 -6
- data/app/views/fine_print/home/index.html.erb~ +12 -4
- data/app/views/fine_print/signatures/index.html.erb +36 -0
- data/app/views/fine_print/signatures/index.html.erb~ +32 -0
- data/app/views/layouts/fine_print/application.html.erb +6 -0
- data/app/views/layouts/fine_print/application.html.erb~ +20 -0
- data/config/initializers/fine_print.rb +27 -44
- data/config/initializers/fine_print.rb~ +23 -40
- data/config/routes.rb +9 -3
- data/config/routes.rb~ +9 -4
- data/db/migrate/0_install_fine_print.rb +26 -0
- data/db/migrate/0_install_fine_print.rb~ +26 -0
- data/lib/fine_print/controller_additions.rb +69 -0
- data/lib/fine_print/controller_additions.rb~ +69 -0
- data/lib/fine_print/engine.rb +8 -0
- data/lib/fine_print/security_transgression.rb +1 -2
- data/lib/fine_print/utilities.rb~ +26 -0
- data/lib/fine_print/version.rb +1 -1
- data/lib/fine_print.rb +89 -42
- data/lib/fine_print.rb~ +89 -41
- data/lib/tasks/fine_print_tasks.rake +11 -8
- data/spec/controllers/contracts_controller_spec.rb +222 -0
- data/spec/controllers/contracts_controller_spec.rb~ +224 -0
- data/spec/controllers/home_controller_spec.rb +25 -0
- data/spec/controllers/home_controller_spec.rb~ +25 -0
- data/spec/controllers/signatures_controller_spec.rb +46 -0
- data/spec/controllers/signatures_controller_spec.rb~ +46 -0
- data/spec/dummy/README.md +1 -1
- data/spec/dummy/app/controllers/dummy_models_controller.rb +2 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb~ +29 -0
- data/spec/dummy/app/helpers/application_helper.rb +13 -0
- data/spec/dummy/app/models/dummy_user.rb +3 -0
- data/spec/dummy/app/models/dummy_user.rb~ +4 -0
- data/spec/dummy/app/models/user.rb~ +78 -0
- data/spec/dummy/config/application.rb +2 -2
- data/spec/dummy/config/application.rb~ +60 -0
- data/spec/dummy/config/initializers/fine_print.rb +36 -0
- data/spec/dummy/config/initializers/fine_print.rb~ +36 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb~ +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb~ +14 -0
- data/spec/dummy/config/routes.rb +1 -2
- data/spec/dummy/config/routes.rb~ +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb +9 -0
- data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +8 -0
- data/spec/dummy/db/schema.rb +20 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1635 -0
- data/spec/dummy/log/test.log +46188 -0
- data/spec/factories/contract.rb +25 -0
- data/spec/factories/contract.rb~ +26 -0
- data/spec/factories/dummy_user.rb +4 -0
- data/spec/factories/dummy_user.rb~ +6 -0
- data/spec/factories/signature.rb +6 -0
- data/spec/factories/signature.rb~ +8 -0
- data/spec/factories/user.rb~ +6 -0
- data/spec/fine_print_spec.rb~ +15 -4
- data/spec/lib/fine_print/controller_additions_spec.rb +20 -0
- data/spec/lib/fine_print/controller_additions_spec.rb~ +20 -0
- data/spec/lib/fine_print_spec.rb +47 -0
- data/spec/lib/fine_print_spec.rb~ +47 -0
- data/spec/models/contract_spec.rb +79 -0
- data/spec/models/contract_spec.rb~ +80 -0
- data/spec/models/signature_spec.rb +28 -0
- data/spec/models/signature_spec.rb~ +28 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/spec_helper.rb~ +32 -0
- data/spec/test_helper.rb~ +15 -0
- metadata +153 -91
- data/app/assets/javascripts/fine_print/agreements.js +0 -19
- data/app/assets/javascripts/fine_print/agreements.js~ +0 -19
- data/app/assets/javascripts/fine_print/application.js~ +0 -5
- data/app/assets/javascripts/fine_print/dialog.js +0 -2
- data/app/assets/javascripts/fine_print/dialog.js~ +0 -2
- data/app/assets/javascripts/fine_print/user_agreements.js +0 -20
- data/app/assets/javascripts/fine_print/user_agreements.js~ +0 -20
- data/app/assets/stylesheets/fine_print/agreements.css +0 -11
- data/app/assets/stylesheets/fine_print/agreements.css~ +0 -11
- data/app/assets/stylesheets/fine_print/application.css~ +0 -60
- data/app/assets/stylesheets/fine_print/user_agreements.css~ +0 -3
- data/app/assets/stylesheets/scaffold.css~ +0 -56
- data/app/controllers/fine_print/agreements_controller.rb +0 -114
- data/app/controllers/fine_print/agreements_controller.rb~ +0 -113
- data/app/controllers/fine_print/user_agreements_controller.rb +0 -63
- data/app/controllers/fine_print/user_agreements_controller.rb~ +0 -63
- data/app/models/fine_print/agreement.rb +0 -50
- data/app/models/fine_print/agreement.rb~ +0 -50
- data/app/models/fine_print/user_agreement.rb +0 -19
- data/app/models/fine_print/user_agreement.rb~ +0 -21
- data/app/views/fine_print/agreements/_agreement.html.erb +0 -77
- data/app/views/fine_print/agreements/_agreement.html.erb~ +0 -77
- data/app/views/fine_print/agreements/_dialog.html.erb +0 -27
- data/app/views/fine_print/agreements/_dialog.html.erb~ +0 -27
- data/app/views/fine_print/agreements/_form.html.erb +0 -51
- data/app/views/fine_print/agreements/_form.html.erb~ +0 -51
- data/app/views/fine_print/agreements/edit.html.erb +0 -8
- data/app/views/fine_print/agreements/edit.html.erb~ +0 -8
- data/app/views/fine_print/agreements/index.html.erb +0 -32
- data/app/views/fine_print/agreements/index.html.erb~ +0 -32
- data/app/views/fine_print/agreements/new.html.erb +0 -7
- data/app/views/fine_print/agreements/new.html.erb~ +0 -7
- data/app/views/fine_print/agreements/new_version.html.erb +0 -7
- data/app/views/fine_print/agreements/new_version.html.erb~ +0 -7
- data/app/views/fine_print/agreements/show.html.erb +0 -15
- data/app/views/fine_print/agreements/show.html.erb~ +0 -14
- data/app/views/fine_print/user_agreements/cancel.js.erb +0 -1
- data/app/views/fine_print/user_agreements/cancel.js.erb~ +0 -2
- data/app/views/fine_print/user_agreements/create.js.erb +0 -2
- data/app/views/fine_print/user_agreements/create.js.erb~ +0 -2
- data/app/views/fine_print/user_agreements/index.html.erb +0 -25
- data/app/views/fine_print/user_agreements/index.html.erb~ +0 -25
- data/db/migrate/0_create_fine_print_agreements.rb~ +0 -22
- data/db/migrate/0_install.rb +0 -28
- data/db/migrate/0_install.rb~ +0 -28
- data/lib/fine_print/agreements_helper.rb +0 -13
- data/lib/fine_print/agreements_helper.rb~ +0 -11
- data/lib/fine_print/fine_print_agreement.rb +0 -26
- data/lib/fine_print/fine_print_agreement.rb~ +0 -26
- data/lib/fine_print/require_agreement.rb~ +0 -22
- data/lib/fine_print/security_transgression.rb~ +0 -3
- data/lib/fine_print/version.rb~ +0 -3
- data/lib/tasks/fine_print_tasks.rake~ +0 -42
- data/spec/dummy/README.md~ +0 -3
- data/spec/fine_print_spec.rb +0 -7
- data/spec/minitest_helper.rb +0 -12
@@ -0,0 +1,100 @@
|
|
1
|
+
module FinePrint
|
2
|
+
class Contract < ActiveRecord::Base
|
3
|
+
has_many :signatures, :inverse_of => :contract
|
4
|
+
|
5
|
+
has_many :same_name, :class_name => 'Contract', :primary_key => :name, :foreign_key => :name
|
6
|
+
|
7
|
+
before_validation :downcase_name
|
8
|
+
before_update :no_signatures
|
9
|
+
before_destroy :no_signatures
|
10
|
+
|
11
|
+
validates_presence_of :name, :title, :content
|
12
|
+
validates_format_of :name, :with => /\A\w+\z/
|
13
|
+
validates_uniqueness_of :version, :scope => :name, :case_sensitive => false
|
14
|
+
|
15
|
+
default_scope order(:name, 'version DESC')
|
16
|
+
|
17
|
+
scope :published, where(arel_table[:version].not_eq(nil))
|
18
|
+
scope :latest, published
|
19
|
+
.joins(:same_name)
|
20
|
+
.group(:id)
|
21
|
+
.having(:version => arel_table.alias(:same_names_fine_print_contracts)[:version]
|
22
|
+
.maximum.tap{|mvq| mvq.alias = nil})
|
23
|
+
|
24
|
+
def is_published?
|
25
|
+
!version.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_latest?
|
29
|
+
is_published? && version == same_name.maximum(:version)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sign(user)
|
33
|
+
FinePrint.sign_contract(self, user)
|
34
|
+
end
|
35
|
+
|
36
|
+
def signed_by?(user)
|
37
|
+
FinePrint.signed_contract?(self, user)
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish
|
41
|
+
no_signatures
|
42
|
+
errors.add(:base, 'Contract is already published') if is_published?
|
43
|
+
return false unless errors.empty?
|
44
|
+
|
45
|
+
self.version = (same_name.published.first.try(:version) || 0) + 1
|
46
|
+
save
|
47
|
+
end
|
48
|
+
|
49
|
+
def unpublish
|
50
|
+
no_signatures
|
51
|
+
errors.add(:base, 'Contract is not the latest published version') unless is_latest?
|
52
|
+
return false unless errors.empty?
|
53
|
+
|
54
|
+
self.version = nil
|
55
|
+
save
|
56
|
+
end
|
57
|
+
|
58
|
+
def draft_copy
|
59
|
+
Contract.where(:name => name, :version => nil).first || dup.tap{|contract| contract.version = nil}
|
60
|
+
end
|
61
|
+
|
62
|
+
##################
|
63
|
+
# Access Control #
|
64
|
+
##################
|
65
|
+
|
66
|
+
def can_be_updated?
|
67
|
+
signatures.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
def can_be_published?
|
71
|
+
signatures.empty? && !is_published?
|
72
|
+
end
|
73
|
+
|
74
|
+
def can_be_unpublished?
|
75
|
+
signatures.empty? && is_latest?
|
76
|
+
end
|
77
|
+
|
78
|
+
def can_be_new_versioned?
|
79
|
+
is_published?
|
80
|
+
end
|
81
|
+
|
82
|
+
alias_method :can_be_destroyed?, :can_be_updated?
|
83
|
+
|
84
|
+
##############
|
85
|
+
# Validation #
|
86
|
+
##############
|
87
|
+
|
88
|
+
def no_signatures
|
89
|
+
return if signatures.empty?
|
90
|
+
errors.add(:base, 'Contract cannot be modified because users have signed it')
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
def downcase_name
|
97
|
+
self.name = name.downcase
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FinePrint
|
2
|
+
class Signature < ActiveRecord::Base
|
3
|
+
belongs_to :contract, :inverse_of => :signatures
|
4
|
+
belongs_to :user, :polymorphic => true
|
5
|
+
|
6
|
+
before_create :contract_published
|
7
|
+
|
8
|
+
validates_presence_of :contract, :user_type, :user_id
|
9
|
+
validates_uniqueness_of :contract_id, :scope => [:user_type, :user_id]
|
10
|
+
|
11
|
+
default_scope order(:contract_id, :user_type, :user_id)
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
##############
|
16
|
+
# Validation #
|
17
|
+
##############
|
18
|
+
|
19
|
+
def contract_published
|
20
|
+
return if contract.is_published?
|
21
|
+
errors.add(:contract, 'needs to be published before it can be signed')
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FinePrint
|
2
|
+
class Signature < ActiveRecord::Base
|
3
|
+
belongs_to :contract, :inverse_of => :signatures
|
4
|
+
belongs_to :user, :polymorphic => true
|
5
|
+
|
6
|
+
before_save :contract_published
|
7
|
+
|
8
|
+
validates_presence_of :contract, :user_type, :user_id
|
9
|
+
validates_uniqueness_of :contract_id, :scope => [:user_type, :user_id]
|
10
|
+
|
11
|
+
default_scope order(:contract_id, :user_type, :user_id)
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
##############
|
16
|
+
# Validation #
|
17
|
+
##############
|
18
|
+
|
19
|
+
def contract_published
|
20
|
+
return if contract.is_published?
|
21
|
+
errors.add(:contract, 'needs to be published before it can be signed')
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%= form_for(@contract, :html => {:class => 'fine_print'}) do |f| %>
|
2
|
+
<% if @contract.errors.any? %>
|
3
|
+
<div id='error_explanation' class='fine_print errors'>
|
4
|
+
<h2 class='fine_print heading'><%= pluralize(@contract.errors.count, 'error') %> prohibited this contract from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @contract.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class='field'>
|
15
|
+
<%= f.label :name, :class => 'fine_print' %>
|
16
|
+
<%= f.text_field :name, :size => 40, :class => 'fine_print text_field' %>
|
17
|
+
<div class='fine_print field_help'>
|
18
|
+
used internally by your code, only letters, numbers, underscores; changing this will start a new contract with new version counts
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class='field'>
|
22
|
+
<%= f.label :title, :class => 'fine_print' %>
|
23
|
+
<%= f.text_field :title, :size => 40, :class => 'fine_print text_field' %>
|
24
|
+
<div class='fine_print field_help'>
|
25
|
+
e.g., 'Terms of Use'
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class='field'>
|
29
|
+
<%= f.label :content, :class => 'fine_print' %>
|
30
|
+
<%= f.text_area :content, :cols => 56, :class => 'fine_print text_area' %>
|
31
|
+
</div>
|
32
|
+
<div class='actions'>
|
33
|
+
<%= f.submit nil, :class => 'fine_print submit' %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%= form_for(@contract, :html => {class: 'fine_print'}) do |f| %>
|
2
|
+
<% if @contract.errors.any? %>
|
3
|
+
<div id='error_explanation' class='fine_print errors'>
|
4
|
+
<h2 class='fine_print heading'><%= pluralize(@contract.errors.count, 'error') %> prohibited this contract from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @contract.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class='field'>
|
15
|
+
<%= f.label :name, :class => 'fine_print' %>
|
16
|
+
<%= f.text_field :name, :size => 40, :class => 'fine_print text_field' %>
|
17
|
+
<div class='fine_print field_help'>
|
18
|
+
used internally by your code, only letters, numbers, underscores; changing this will start a new contract with new version counts
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class='field'>
|
22
|
+
<%= f.label :title, :class => 'fine_print' %>
|
23
|
+
<%= f.text_field :title, :size => 40, :class => 'fine_print text_field' %>
|
24
|
+
<div class='fine_print field_help'>
|
25
|
+
e.g., 'Terms of Use'
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class='field'>
|
29
|
+
<%= f.label :content, :class => 'fine_print' %>
|
30
|
+
<%= f.text_area :content, :cols => 56, :class => 'fine_print text_area' %>
|
31
|
+
</div>
|
32
|
+
<div class='actions'>
|
33
|
+
<%= f.submit nil, :class => 'fine_print submit' %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1 class='fine_print heading'>Editing Contract</h1>
|
2
|
+
|
3
|
+
<div class='fine_print edit_contract'>
|
4
|
+
<%= render 'form' %>
|
5
|
+
|
6
|
+
<div class='fine_print links'>
|
7
|
+
<%= link_to 'Show', @contract, :class => 'fine_print link' %> |
|
8
|
+
<%= link_to 'List', contracts_path, :class => 'fine_print link' %>
|
9
|
+
</div>
|
10
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<h1 class='fine_print heading'>FinePrint Contracts</h1>
|
2
|
+
|
3
|
+
<div class='fine_print contract_index'>
|
4
|
+
|
5
|
+
<% @contracts.group_by(&:name).each do |name, contracts| %>
|
6
|
+
|
7
|
+
<%# Sort contracts by version number; unpublished contracts go at end by creation date %>
|
8
|
+
<% contracts = contracts.sort_by {|cc| cc.version || cc.created_at.to_i} %>
|
9
|
+
|
10
|
+
<ul class='fine_print'>
|
11
|
+
<li><%= name %></li>
|
12
|
+
|
13
|
+
<ul class='fine_print'>
|
14
|
+
<% contracts.each do |contract| %>
|
15
|
+
<li><%= link_to contract.title, contract %>
|
16
|
+
(<%= contract.version.nil? ? 'draft' : "v.#{contract.version.to_s}" %>)
|
17
|
+
<% if contract.can_be_updated? %>
|
18
|
+
[<%= link_to 'Edit', edit_contract_path(contract), :class => 'fine_print link' %>]
|
19
|
+
<% else %>
|
20
|
+
[<%= link_to 'New version', new_version_contract_path(contract), :class => 'fine_print link' %>]
|
21
|
+
<% end %>
|
22
|
+
<% if contract.can_be_published? %>
|
23
|
+
[<%= link_to 'Publish', publish_contract_path(contract), :method => :put, :data => {:confirm => 'Are you sure you want to publish this contract?'} %>]
|
24
|
+
<% elsif contract.can_be_unpublished? %>
|
25
|
+
[<%= link_to 'Unpublish', unpublish_contract_path(contract), :method => :put, :data => {:confirm => 'Are you sure you want to unpublish this contract?'} %>]
|
26
|
+
<% end %>
|
27
|
+
<% if contract.can_be_destroyed? %>
|
28
|
+
[<%= link_to 'Delete', contract, :method => :delete, :data => {:confirm => 'Are you sure you wish to delete this contract?'}, :class => 'fine_print link' %>]
|
29
|
+
<% end %>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
</ul>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<div class='fine_print links'>
|
39
|
+
<%= link_to 'New Contract', new_contract_path, :class => 'fine_print link' %> |
|
40
|
+
<%= link_to 'Overview', root_path, :class => 'fine_print link' %>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<h1 class='fine_print heading'>FinePrint Contracts</h1>
|
2
|
+
|
3
|
+
<div class='fine_print contract_index'>
|
4
|
+
|
5
|
+
<% @contracts.group_by(&:name).each do |name, contracts| %>
|
6
|
+
|
7
|
+
<%# Sort contracts by version number; unpublished contracts go at end by creation date %>
|
8
|
+
<% contracts = contracts.sort_by {|cc| cc.version || cc.created_at.to_i} %>
|
9
|
+
|
10
|
+
<ul class='fine_print'>
|
11
|
+
<li><%= name %></li>
|
12
|
+
|
13
|
+
<ul class='fine_print'>
|
14
|
+
<% contracts.each do |contract| %>
|
15
|
+
<li><%= link_to contract.title, contract %>
|
16
|
+
(<%= contract.version.nil? ? 'draft' : "v.#{contract.version.to_s}" %>)
|
17
|
+
<% if contract.can_be_updated? %>
|
18
|
+
[<%= link_to 'Edit', edit_contract_path(contract), :class => 'fine_print link' %>]
|
19
|
+
<% else %>
|
20
|
+
[<%= link_to 'New version', new_version_contract_path(contract), :class => 'fine_print link' %>]
|
21
|
+
<% end %>
|
22
|
+
<% if contract.can_be_published? %>
|
23
|
+
[<%= link_to 'Publish', publish_contract_path(contract), :method => :put, :data => {:confirm => 'Are you sure you want to publish this contract?'} %>]
|
24
|
+
<% elsif contract.can_be_unpublished? %>
|
25
|
+
[<%= link_to 'Unpublish', unpublish_contract_path(contract), :method => :put, :data => {:confirm => 'Are you sure you want to unpublish this contract?'} %>]
|
26
|
+
<% end %>
|
27
|
+
<% if contract.can_be_destroyed? %>
|
28
|
+
[<%= link_to 'Delete', contract, :method => :delete, :data => {:confirm => 'Are you sure you wish to delete this contract?'}, :class => 'fine_print link' %>]
|
29
|
+
<% end %>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
</ul>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<div class='fine_print links'>
|
39
|
+
<%= link_to 'New Contract', new_contract_path, :class => 'fine_print link' %> |
|
40
|
+
<%= link_to 'Overview', root_path, :class => 'fine_print link' %>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1 class='fine_print heading'>New Version of <%= @contract.name %></h1>
|
2
|
+
|
3
|
+
<div class='fine_print new_contract_version'>
|
4
|
+
<%= render 'form' %>
|
5
|
+
|
6
|
+
<div class='fine_print links'>
|
7
|
+
<%= link_to 'List', contracts_path, :class => 'fine_print link' %>
|
8
|
+
</div>
|
9
|
+
</div>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<h1 class='fine_print heading'>Contract Details</h1>
|
2
|
+
|
3
|
+
<div class='fine_print show_contract'>
|
4
|
+
<table class='fine_print left_heading'>
|
5
|
+
<tr>
|
6
|
+
<th>Name</th>
|
7
|
+
<td><%= @contract.name %></td>
|
8
|
+
</tr>
|
9
|
+
<tr>
|
10
|
+
<th>Title</th>
|
11
|
+
<td><%= @contract.title %></td>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<th>Version</th>
|
15
|
+
<td><%= @contract.version.nil? ? 'Draft' : @contract.version %></td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<th>Updated at</th>
|
19
|
+
<td><%= @contract.updated_at %></td>
|
20
|
+
</tr>
|
21
|
+
<tr>
|
22
|
+
<th>Content</th>
|
23
|
+
<td><%= @contract.content.html_safe %></td>
|
24
|
+
</tr>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<div class='fine_print links'>
|
28
|
+
<% if @contract.can_be_updated? %>
|
29
|
+
<%= link_to 'Edit', edit_contract_path(@contract), :class => 'fine_print link' %> |
|
30
|
+
<% end %>
|
31
|
+
<%= link_to 'List', contracts_path, :class => 'fine_print link' %>
|
32
|
+
</div>
|
33
|
+
</div>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<h1 class='fine_print heading'>Contract Details</h1>
|
2
|
+
|
3
|
+
<div class='fine_print show_contract'>
|
4
|
+
|
5
|
+
<table class='fine_print left_heading'>
|
6
|
+
<tr>
|
7
|
+
<th>Name</th>
|
8
|
+
<td><%= @contract.name %></td>
|
9
|
+
</tr>
|
10
|
+
<tr>
|
11
|
+
<th>Title</th>
|
12
|
+
<td><%= @contract.title %></td>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<th>Version</th>
|
16
|
+
<td><%= @contract.version.nil? ? 'Draft' : @contract.version %></td>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<th>Updated at</th>
|
20
|
+
<td><%= @contract.updated_at %></td>
|
21
|
+
</tr>
|
22
|
+
<tr>
|
23
|
+
<th>Content</th>
|
24
|
+
<td><%= @contract.content.html_safe %></td>
|
25
|
+
</tr>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<div class='fine_print links'>
|
29
|
+
<% if @contract.can_be_updated? %>
|
30
|
+
<%= link_to 'Edit', edit_contract_path(@contract), :class => 'fine_print link' %> |
|
31
|
+
<% end %>
|
32
|
+
<%= link_to 'List', contracts_path, :class => 'fine_print link' %>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</div>
|
@@ -1,7 +1,16 @@
|
|
1
|
-
<h1 class=
|
2
|
-
|
3
|
-
<ul>
|
4
|
-
<li><%= link_to 'Manage agreements', agreements_path, :class => "fine_print link" %></li>
|
5
|
-
<li><%= link_to 'View accepted agreements', user_agreements_path, :class => "fine_print link" %></li>
|
6
|
-
</ul>
|
1
|
+
<h1 class='fine_print heading'>FinePrint</h1>
|
7
2
|
|
3
|
+
<div class='fine_print root'>
|
4
|
+
<ul class='fine_print'>
|
5
|
+
<li>
|
6
|
+
<%= link_to 'Manage contracts',
|
7
|
+
contracts_path,
|
8
|
+
:class => 'fine_print link' %>
|
9
|
+
</li>
|
10
|
+
<li>
|
11
|
+
<%= link_to 'View signatures',
|
12
|
+
signatures_path,
|
13
|
+
:class => 'fine_print link' %>
|
14
|
+
</li>
|
15
|
+
</ul>
|
16
|
+
</div>
|
@@ -1,7 +1,15 @@
|
|
1
|
-
<h1 class=
|
1
|
+
<h1 class='fine_print heading'>FinePrint</h1>
|
2
2
|
|
3
|
-
<ul>
|
4
|
-
<li
|
5
|
-
|
3
|
+
<ul class='fine_print'>
|
4
|
+
<li>
|
5
|
+
<%= link_to 'Manage contracts',
|
6
|
+
contracts_path,
|
7
|
+
:class => 'fine_print link' %>
|
8
|
+
</li>
|
9
|
+
<li>
|
10
|
+
<%= link_to 'View signatures',
|
11
|
+
signatures_path,
|
12
|
+
:class => 'fine_print link' %>
|
13
|
+
</li>
|
6
14
|
</ul>
|
7
15
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<h1 class='fine_print heading'>Contract Signatures</h1>
|
2
|
+
|
3
|
+
<div class='fine_print signature_index'>
|
4
|
+
|
5
|
+
<table class='fine_print top_heading index'>
|
6
|
+
<tr class='fine_print heading-row'>
|
7
|
+
<th>User ID</th>
|
8
|
+
<th>Contract name</th>
|
9
|
+
<th>Contract version</th>
|
10
|
+
<th>Date accepted</th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<% @signatures.each do |signature| %>
|
15
|
+
<tr class='fine_print data-row <%= cycle('even', 'odd') %>'>
|
16
|
+
<td><%= signature.user.id %></td>
|
17
|
+
<td><%= signature.contract.name %></td>
|
18
|
+
<td><%= signature.contract.version %></td>
|
19
|
+
<td><%= signature.created_at %></td>
|
20
|
+
<td><%= link_to 'Terminate',
|
21
|
+
signature,
|
22
|
+
:method => :delete,
|
23
|
+
:data => {
|
24
|
+
:confirm => 'User will be asked to accept the contract again. Are you sure?'
|
25
|
+
},
|
26
|
+
:class => 'fine_print link' %>
|
27
|
+
</td>
|
28
|
+
</tr>
|
29
|
+
<% end %>
|
30
|
+
</table>
|
31
|
+
|
32
|
+
<div class='fine_print links'>
|
33
|
+
<%= link_to 'Overview', root_path, :class => 'fine_print link' %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<h1 class='fine_print heading'>Contract Signatures</h1>
|
2
|
+
|
3
|
+
<table class='fine_print index'>
|
4
|
+
<tr class='fine_print heading-row'>
|
5
|
+
<th>User ID</th>
|
6
|
+
<th>Contract name</th>
|
7
|
+
<th>Contract version</th>
|
8
|
+
<th>Date accepted</th>
|
9
|
+
<th></th>
|
10
|
+
</tr>
|
11
|
+
|
12
|
+
<% @signatures.each do |signature| %>
|
13
|
+
<tr class='fine_print data-row <%= cycle('even', 'odd') %>'>
|
14
|
+
<td><%= signature.user.id %></td>
|
15
|
+
<td><%= signature.contract.name %></td>
|
16
|
+
<td><%= signature.contract.version %></td>
|
17
|
+
<td><%= signature.created_at %></td>
|
18
|
+
<td><%= link_to 'Terminate',
|
19
|
+
signature,
|
20
|
+
method: :delete,
|
21
|
+
data: {
|
22
|
+
confirm: 'User will be asked to accept the contract again. Are you sure?'
|
23
|
+
},
|
24
|
+
:class => 'fine_print link' %>
|
25
|
+
</td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
<br />
|
31
|
+
|
32
|
+
<%= link_to 'Overview', root_path, :class => 'fine_print link' %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>FinePrint</title>
|
5
|
+
<%= stylesheet_link_tag "fine_print/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "fine_print/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<% if flash[:notice] %>
|
12
|
+
<div class="notice"><%= flash[:notice] %></div>
|
13
|
+
<% elsif flash[:notice] %>
|
14
|
+
<div class="notice"><%= flash[:notice] %></div>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= yield %>
|
18
|
+
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -1,53 +1,36 @@
|
|
1
1
|
# Change the settings below to suit your needs
|
2
2
|
# All settings are initially set to their default values
|
3
3
|
FinePrint.configure do |config|
|
4
|
+
# Engine Configuration
|
4
5
|
|
5
|
-
#
|
6
|
+
# Name of the ApplicationController helper method that returns the current user.
|
7
|
+
# Default: 'current_user'
|
8
|
+
config.current_user_method = 'current_user'
|
6
9
|
|
7
|
-
#
|
8
|
-
#
|
9
|
-
config.current_user_method = "current_user"
|
10
|
-
|
11
|
-
# Proc called with user as argument that should return true if and only if the user is an admin
|
12
|
-
# Admins can create and edit agreements and terminate accepted agreements
|
10
|
+
# Proc called with user as argument that should return true if and only if the user is an admin.
|
11
|
+
# Admins can create and edit agreements and terminate accepted agreements.
|
13
12
|
# Default: lambda { |user| false } (no admins)
|
14
13
|
config.user_admin_proc = lambda { |user| false }
|
15
14
|
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
# Default:
|
36
|
-
config.
|
37
|
-
|
38
|
-
# Path to redirect users to when an agreement is not accepted and referer information is unavailable
|
39
|
-
# Default: "/"
|
40
|
-
config.cancel_path = "/"
|
41
|
-
|
42
|
-
# Whether to use referer information to redirect users after (not) accepting an agreement
|
43
|
-
# Default: true
|
44
|
-
config.use_referers = true
|
45
|
-
|
46
|
-
# If set to true, modal jQuery UI dialogs will be used instead of redirecting the user to the agreement page
|
47
|
-
# Note: users with javascript disabled will not even see the agreement and will be able to proceed without accepting it
|
48
|
-
# if users are not supposed to ever see or interact with a certain page without accepting the agreement,
|
49
|
-
# disable this option for that particular controller action
|
50
|
-
# Default: false
|
51
|
-
config.use_modal_dialogs = false
|
52
|
-
|
15
|
+
# Proc that returns true if and only if the provided user is logged in.
|
16
|
+
# In many systems, a non-logged-in user is represented by nil.
|
17
|
+
# However, some systems use something like an AnonymousUser class to represent this state.
|
18
|
+
# This proc is mostly used to help the developer realize that they should only be asking
|
19
|
+
# signed in users to sign contracts; without this, developers would get a cryptic SQL error.
|
20
|
+
# Default: lambda { |user| !user.nil? }
|
21
|
+
config.user_signed_in_proc = lambda { |user| !user.nil? }
|
22
|
+
|
23
|
+
# Path to redirect users to when an error occurs (e.g. permission denied on admin pages).
|
24
|
+
# Default: '/'
|
25
|
+
config.redirect_path = '/'
|
26
|
+
|
27
|
+
# Signature (fine_print_get_signatures) Configuration
|
28
|
+
|
29
|
+
# Path to redirect users to when they need to agree to contract(s).
|
30
|
+
# A list of contract names that must be agreed to will be available in the 'contracts' parameter.
|
31
|
+
# Your code doesn't have to deal with all of them at once, e.g. you can get
|
32
|
+
# the user to agree to the first one and then they'll just eventually be
|
33
|
+
# redirected back to this page with the remaining contract names.
|
34
|
+
# Default: '/'
|
35
|
+
config.pose_contracts_path = '/'
|
53
36
|
end
|