fine_print 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +74 -45
  3. data/Rakefile +9 -9
  4. data/app/assets/javascripts/application.js~ +16 -0
  5. data/app/assets/javascripts/fine_print/application.js +8 -2
  6. data/app/controllers/fine_print/application_controller.rb +9 -7
  7. data/app/controllers/fine_print/application_controller.rb~ +9 -7
  8. data/app/controllers/fine_print/contracts_controller.rb +79 -0
  9. data/app/controllers/fine_print/contracts_controller.rb~ +79 -0
  10. data/app/controllers/fine_print/home_controller.rb +1 -11
  11. data/app/controllers/fine_print/home_controller.rb~ +2 -11
  12. data/app/controllers/fine_print/signatures_controller.rb +14 -0
  13. data/app/controllers/fine_print/signatures_controller.rb~ +14 -0
  14. data/app/helpers/fine_print/application_helper.rb +7 -0
  15. data/app/helpers/fine_print/application_helper.rb~ +7 -0
  16. data/app/helpers/fine_print/contracts_helper.rb~ +7 -0
  17. data/app/models/fine_print/contract.rb +96 -0
  18. data/app/models/fine_print/contract.rb~ +100 -0
  19. data/app/models/fine_print/signature.rb +25 -0
  20. data/app/models/fine_print/signature.rb~ +25 -0
  21. data/app/views/fine_print/contracts/_form.html.erb +35 -0
  22. data/app/views/fine_print/contracts/_form.html.erb~ +35 -0
  23. data/app/views/fine_print/contracts/edit.html.erb +10 -0
  24. data/app/views/fine_print/contracts/index.html.erb +43 -0
  25. data/app/views/fine_print/contracts/index.html.erb~ +43 -0
  26. data/app/views/fine_print/contracts/new.html.erb +9 -0
  27. data/app/views/fine_print/contracts/new_version.html.erb +9 -0
  28. data/app/views/fine_print/contracts/show.html.erb +33 -0
  29. data/app/views/fine_print/contracts/show.html.erb~ +35 -0
  30. data/app/views/fine_print/home/index.html.erb +15 -6
  31. data/app/views/fine_print/home/index.html.erb~ +12 -4
  32. data/app/views/fine_print/signatures/index.html.erb +36 -0
  33. data/app/views/fine_print/signatures/index.html.erb~ +32 -0
  34. data/app/views/layouts/fine_print/application.html.erb +6 -0
  35. data/app/views/layouts/fine_print/application.html.erb~ +20 -0
  36. data/config/initializers/fine_print.rb +27 -44
  37. data/config/initializers/fine_print.rb~ +23 -40
  38. data/config/routes.rb +9 -3
  39. data/config/routes.rb~ +9 -4
  40. data/db/migrate/0_install_fine_print.rb +26 -0
  41. data/db/migrate/0_install_fine_print.rb~ +26 -0
  42. data/lib/fine_print/controller_additions.rb +69 -0
  43. data/lib/fine_print/controller_additions.rb~ +69 -0
  44. data/lib/fine_print/engine.rb +8 -0
  45. data/lib/fine_print/security_transgression.rb +1 -2
  46. data/lib/fine_print/utilities.rb~ +26 -0
  47. data/lib/fine_print/version.rb +1 -1
  48. data/lib/fine_print.rb +89 -42
  49. data/lib/fine_print.rb~ +89 -41
  50. data/lib/tasks/fine_print_tasks.rake +11 -8
  51. data/spec/controllers/contracts_controller_spec.rb +222 -0
  52. data/spec/controllers/contracts_controller_spec.rb~ +224 -0
  53. data/spec/controllers/home_controller_spec.rb +25 -0
  54. data/spec/controllers/home_controller_spec.rb~ +25 -0
  55. data/spec/controllers/signatures_controller_spec.rb +46 -0
  56. data/spec/controllers/signatures_controller_spec.rb~ +46 -0
  57. data/spec/dummy/README.md +1 -1
  58. data/spec/dummy/app/controllers/dummy_models_controller.rb +2 -0
  59. data/spec/dummy/app/controllers/dummy_models_controller.rb~ +29 -0
  60. data/spec/dummy/app/helpers/application_helper.rb +13 -0
  61. data/spec/dummy/app/models/dummy_user.rb +3 -0
  62. data/spec/dummy/app/models/dummy_user.rb~ +4 -0
  63. data/spec/dummy/app/models/user.rb~ +78 -0
  64. data/spec/dummy/config/application.rb +2 -2
  65. data/spec/dummy/config/application.rb~ +60 -0
  66. data/spec/dummy/config/initializers/fine_print.rb +36 -0
  67. data/spec/dummy/config/initializers/fine_print.rb~ +36 -0
  68. data/spec/dummy/config/initializers/session_store.rb +1 -1
  69. data/spec/dummy/config/initializers/session_store.rb~ +8 -0
  70. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  71. data/spec/dummy/config/initializers/wrap_parameters.rb~ +14 -0
  72. data/spec/dummy/config/routes.rb +1 -2
  73. data/spec/dummy/config/routes.rb~ +4 -0
  74. data/spec/dummy/db/development.sqlite3 +0 -0
  75. data/spec/dummy/db/migrate/1_create_dummy_users.rb +9 -0
  76. data/spec/dummy/db/migrate/1_create_dummy_users.rb~ +8 -0
  77. data/spec/dummy/db/schema.rb +20 -12
  78. data/spec/dummy/db/test.sqlite3 +0 -0
  79. data/spec/dummy/log/development.log +1635 -0
  80. data/spec/dummy/log/test.log +46188 -0
  81. data/spec/factories/contract.rb +25 -0
  82. data/spec/factories/contract.rb~ +26 -0
  83. data/spec/factories/dummy_user.rb +4 -0
  84. data/spec/factories/dummy_user.rb~ +6 -0
  85. data/spec/factories/signature.rb +6 -0
  86. data/spec/factories/signature.rb~ +8 -0
  87. data/spec/factories/user.rb~ +6 -0
  88. data/spec/fine_print_spec.rb~ +15 -4
  89. data/spec/lib/fine_print/controller_additions_spec.rb +20 -0
  90. data/spec/lib/fine_print/controller_additions_spec.rb~ +20 -0
  91. data/spec/lib/fine_print_spec.rb +47 -0
  92. data/spec/lib/fine_print_spec.rb~ +47 -0
  93. data/spec/models/contract_spec.rb +79 -0
  94. data/spec/models/contract_spec.rb~ +80 -0
  95. data/spec/models/signature_spec.rb +28 -0
  96. data/spec/models/signature_spec.rb~ +28 -0
  97. data/spec/spec_helper.rb +31 -0
  98. data/spec/spec_helper.rb~ +32 -0
  99. data/spec/test_helper.rb~ +15 -0
  100. metadata +153 -91
  101. data/app/assets/javascripts/fine_print/agreements.js +0 -19
  102. data/app/assets/javascripts/fine_print/agreements.js~ +0 -19
  103. data/app/assets/javascripts/fine_print/application.js~ +0 -5
  104. data/app/assets/javascripts/fine_print/dialog.js +0 -2
  105. data/app/assets/javascripts/fine_print/dialog.js~ +0 -2
  106. data/app/assets/javascripts/fine_print/user_agreements.js +0 -20
  107. data/app/assets/javascripts/fine_print/user_agreements.js~ +0 -20
  108. data/app/assets/stylesheets/fine_print/agreements.css +0 -11
  109. data/app/assets/stylesheets/fine_print/agreements.css~ +0 -11
  110. data/app/assets/stylesheets/fine_print/application.css~ +0 -60
  111. data/app/assets/stylesheets/fine_print/user_agreements.css~ +0 -3
  112. data/app/assets/stylesheets/scaffold.css~ +0 -56
  113. data/app/controllers/fine_print/agreements_controller.rb +0 -114
  114. data/app/controllers/fine_print/agreements_controller.rb~ +0 -113
  115. data/app/controllers/fine_print/user_agreements_controller.rb +0 -63
  116. data/app/controllers/fine_print/user_agreements_controller.rb~ +0 -63
  117. data/app/models/fine_print/agreement.rb +0 -50
  118. data/app/models/fine_print/agreement.rb~ +0 -50
  119. data/app/models/fine_print/user_agreement.rb +0 -19
  120. data/app/models/fine_print/user_agreement.rb~ +0 -21
  121. data/app/views/fine_print/agreements/_agreement.html.erb +0 -77
  122. data/app/views/fine_print/agreements/_agreement.html.erb~ +0 -77
  123. data/app/views/fine_print/agreements/_dialog.html.erb +0 -27
  124. data/app/views/fine_print/agreements/_dialog.html.erb~ +0 -27
  125. data/app/views/fine_print/agreements/_form.html.erb +0 -51
  126. data/app/views/fine_print/agreements/_form.html.erb~ +0 -51
  127. data/app/views/fine_print/agreements/edit.html.erb +0 -8
  128. data/app/views/fine_print/agreements/edit.html.erb~ +0 -8
  129. data/app/views/fine_print/agreements/index.html.erb +0 -32
  130. data/app/views/fine_print/agreements/index.html.erb~ +0 -32
  131. data/app/views/fine_print/agreements/new.html.erb +0 -7
  132. data/app/views/fine_print/agreements/new.html.erb~ +0 -7
  133. data/app/views/fine_print/agreements/new_version.html.erb +0 -7
  134. data/app/views/fine_print/agreements/new_version.html.erb~ +0 -7
  135. data/app/views/fine_print/agreements/show.html.erb +0 -15
  136. data/app/views/fine_print/agreements/show.html.erb~ +0 -14
  137. data/app/views/fine_print/user_agreements/cancel.js.erb +0 -1
  138. data/app/views/fine_print/user_agreements/cancel.js.erb~ +0 -2
  139. data/app/views/fine_print/user_agreements/create.js.erb +0 -2
  140. data/app/views/fine_print/user_agreements/create.js.erb~ +0 -2
  141. data/app/views/fine_print/user_agreements/index.html.erb +0 -25
  142. data/app/views/fine_print/user_agreements/index.html.erb~ +0 -25
  143. data/db/migrate/0_create_fine_print_agreements.rb~ +0 -22
  144. data/db/migrate/0_install.rb +0 -28
  145. data/db/migrate/0_install.rb~ +0 -28
  146. data/lib/fine_print/agreements_helper.rb +0 -13
  147. data/lib/fine_print/agreements_helper.rb~ +0 -11
  148. data/lib/fine_print/fine_print_agreement.rb +0 -26
  149. data/lib/fine_print/fine_print_agreement.rb~ +0 -26
  150. data/lib/fine_print/require_agreement.rb~ +0 -22
  151. data/lib/fine_print/security_transgression.rb~ +0 -3
  152. data/lib/fine_print/version.rb~ +0 -3
  153. data/lib/tasks/fine_print_tasks.rake~ +0 -42
  154. data/spec/dummy/README.md~ +0 -3
  155. data/spec/fine_print_spec.rb +0 -7
  156. 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 Contract</h1>
2
+
3
+ <div class='fine_print new_contract'>
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,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="fine_print heading">FinePrint</h1>
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="fine_print heading">FinePrint</h1>
1
+ <h1 class='fine_print heading'>FinePrint</h1>
2
2
 
3
- <ul>
4
- <li><%= link_to 'Manage agreements', agreements_path, :class => "fine_print link" %></li>
5
- <li><%= link_to 'Accepted agreements', user_agreements_path, :class => "fine_print link" %></li>
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' %>
@@ -8,6 +8,12 @@
8
8
  </head>
9
9
  <body>
10
10
 
11
+ <% if flash[:alert] %>
12
+ <div class="alert"><%= flash[:alert] %></div>
13
+ <% elsif flash[:notice] %>
14
+ <div class="notice"><%= flash[:notice] %></div>
15
+ <% end %>
16
+
11
17
  <%= yield %>
12
18
 
13
19
  </body>
@@ -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
- # Engine Options (initializer only)
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
- # Name of the ApplicationController helper method that returns the current user
8
- # Default: "current_user"
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
- # Path to redirect users to when an error occurs (e.g. permission denied on admin pages)
17
- # Default: "/"
18
- config.redirect_path = "/"
19
-
20
- # Path to link users to if they need to sign in
21
- # Set to nil to disable the link
22
- # Default: "/"
23
- config.sign_in_path = "/"
24
-
25
-
26
-
27
- # Agreement Options (initializer or inline)
28
-
29
- # Message to be displayed to the user explaining that they need to accept an agreement
30
- # Set to nil to disable
31
- # Default: "You must accept the following agreement to proceed."
32
- config.agreement_notice = "You must accept the following agreement to proceed."
33
-
34
- # Path to redirect users to when an agreement is accepted and referer information is unavailable
35
- # Default: "/"
36
- config.accept_path = "/"
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