fine_print 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +124 -0
  3. data/Rakefile +23 -0
  4. data/app/assets/javascripts/fine_print/agreements.js +19 -0
  5. data/app/assets/javascripts/fine_print/agreements.js~ +19 -0
  6. data/app/assets/javascripts/fine_print/application.js +4 -0
  7. data/app/assets/javascripts/fine_print/application.js~ +5 -0
  8. data/app/assets/javascripts/fine_print/dialog.js +2 -0
  9. data/app/assets/javascripts/fine_print/dialog.js~ +2 -0
  10. data/app/assets/javascripts/fine_print/user_agreements.js +20 -0
  11. data/app/assets/javascripts/fine_print/user_agreements.js~ +20 -0
  12. data/app/assets/stylesheets/fine_print/agreements.css +11 -0
  13. data/app/assets/stylesheets/fine_print/agreements.css~ +11 -0
  14. data/app/assets/stylesheets/fine_print/application.css +5 -0
  15. data/app/assets/stylesheets/fine_print/application.css~ +60 -0
  16. data/app/assets/stylesheets/fine_print/scaffold.css +56 -0
  17. data/app/assets/stylesheets/fine_print/user_agreements.css~ +3 -0
  18. data/app/assets/stylesheets/scaffold.css~ +56 -0
  19. data/app/controllers/fine_print/agreements_controller.rb +114 -0
  20. data/app/controllers/fine_print/agreements_controller.rb~ +113 -0
  21. data/app/controllers/fine_print/application_controller.rb +13 -0
  22. data/app/controllers/fine_print/application_controller.rb~ +13 -0
  23. data/app/controllers/fine_print/home_controller.rb +14 -0
  24. data/app/controllers/fine_print/home_controller.rb~ +15 -0
  25. data/app/controllers/fine_print/user_agreements_controller.rb +63 -0
  26. data/app/controllers/fine_print/user_agreements_controller.rb~ +63 -0
  27. data/app/models/fine_print/agreement.rb +50 -0
  28. data/app/models/fine_print/agreement.rb~ +50 -0
  29. data/app/models/fine_print/user_agreement.rb +19 -0
  30. data/app/models/fine_print/user_agreement.rb~ +21 -0
  31. data/app/views/fine_print/agreements/_agreement.html.erb +77 -0
  32. data/app/views/fine_print/agreements/_agreement.html.erb~ +77 -0
  33. data/app/views/fine_print/agreements/_dialog.html.erb +27 -0
  34. data/app/views/fine_print/agreements/_dialog.html.erb~ +27 -0
  35. data/app/views/fine_print/agreements/_form.html.erb +51 -0
  36. data/app/views/fine_print/agreements/_form.html.erb~ +51 -0
  37. data/app/views/fine_print/agreements/edit.html.erb +8 -0
  38. data/app/views/fine_print/agreements/edit.html.erb~ +8 -0
  39. data/app/views/fine_print/agreements/index.html.erb +32 -0
  40. data/app/views/fine_print/agreements/index.html.erb~ +32 -0
  41. data/app/views/fine_print/agreements/new.html.erb +7 -0
  42. data/app/views/fine_print/agreements/new.html.erb~ +7 -0
  43. data/app/views/fine_print/agreements/new_version.html.erb +7 -0
  44. data/app/views/fine_print/agreements/new_version.html.erb~ +7 -0
  45. data/app/views/fine_print/agreements/show.html.erb +15 -0
  46. data/app/views/fine_print/agreements/show.html.erb~ +14 -0
  47. data/app/views/fine_print/home/index.html.erb +7 -0
  48. data/app/views/fine_print/home/index.html.erb~ +7 -0
  49. data/app/views/fine_print/user_agreements/cancel.js.erb +1 -0
  50. data/app/views/fine_print/user_agreements/cancel.js.erb~ +2 -0
  51. data/app/views/fine_print/user_agreements/create.js.erb +2 -0
  52. data/app/views/fine_print/user_agreements/create.js.erb~ +2 -0
  53. data/app/views/fine_print/user_agreements/index.html.erb +25 -0
  54. data/app/views/fine_print/user_agreements/index.html.erb~ +25 -0
  55. data/app/views/layouts/fine_print/application.html.erb +14 -0
  56. data/config/initializers/fine_print.rb +53 -0
  57. data/config/initializers/fine_print.rb~ +53 -0
  58. data/config/routes.rb +7 -0
  59. data/config/routes.rb~ +7 -0
  60. data/db/migrate/0_create_fine_print_agreements.rb~ +22 -0
  61. data/db/migrate/0_install.rb +28 -0
  62. data/db/migrate/0_install.rb~ +28 -0
  63. data/lib/fine_print/agreements_helper.rb +13 -0
  64. data/lib/fine_print/agreements_helper.rb~ +11 -0
  65. data/lib/fine_print/engine.rb +5 -0
  66. data/lib/fine_print/fine_print_agreement.rb +26 -0
  67. data/lib/fine_print/fine_print_agreement.rb~ +26 -0
  68. data/lib/fine_print/require_agreement.rb~ +22 -0
  69. data/lib/fine_print/security_transgression.rb +4 -0
  70. data/lib/fine_print/security_transgression.rb~ +3 -0
  71. data/lib/fine_print/version.rb +3 -0
  72. data/lib/fine_print/version.rb~ +3 -0
  73. data/lib/fine_print.rb +69 -0
  74. data/lib/fine_print.rb~ +68 -0
  75. data/lib/tasks/fine_print_tasks.rake +42 -0
  76. data/lib/tasks/fine_print_tasks.rake~ +85 -0
  77. data/spec/dummy/README.md +3 -0
  78. data/spec/dummy/README.md~ +3 -0
  79. data/spec/dummy/Rakefile +7 -0
  80. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  81. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  82. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  83. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  84. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  85. data/spec/dummy/config/application.rb +59 -0
  86. data/spec/dummy/config/boot.rb +10 -0
  87. data/spec/dummy/config/database.yml +25 -0
  88. data/spec/dummy/config/environment.rb +5 -0
  89. data/spec/dummy/config/environments/development.rb +37 -0
  90. data/spec/dummy/config/environments/production.rb +67 -0
  91. data/spec/dummy/config/environments/test.rb +37 -0
  92. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  93. data/spec/dummy/config/initializers/inflections.rb +15 -0
  94. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  95. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  96. data/spec/dummy/config/initializers/session_store.rb +8 -0
  97. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy/config/locales/en.yml +5 -0
  99. data/spec/dummy/config/routes.rb +4 -0
  100. data/spec/dummy/config.ru +4 -0
  101. data/spec/dummy/db/development.sqlite3 +0 -0
  102. data/spec/dummy/db/schema.rb +36 -0
  103. data/spec/dummy/db/test.sqlite3 +0 -0
  104. data/spec/dummy/log/development.log +41 -0
  105. data/spec/dummy/log/test.log +3 -0
  106. data/spec/dummy/public/404.html +26 -0
  107. data/spec/dummy/public/422.html +26 -0
  108. data/spec/dummy/public/500.html +25 -0
  109. data/spec/dummy/public/favicon.ico +0 -0
  110. data/spec/dummy/script/rails +6 -0
  111. data/spec/fine_print_spec.rb +7 -0
  112. data/spec/fine_print_spec.rb~ +7 -0
  113. data/spec/minitest_helper.rb +12 -0
  114. metadata +277 -0
@@ -0,0 +1,113 @@
1
+ require_dependency "fine_print/application_controller"
2
+
3
+ module FinePrint
4
+ class AgreementsController < ApplicationController
5
+ # GET /agreements
6
+ # GET /agreements.json
7
+ def index
8
+ raise SecurityTransgression unless Agreement.can_be_listed_by?(@user)
9
+ @agreements = Agreement.all
10
+
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.json { render json: @agreements }
14
+ end
15
+ end
16
+
17
+ # GET /agreements/1
18
+ # GET /agreements/1.json
19
+ def show
20
+ @agreement = Agreement.find(params[:id])
21
+ raise SecurityTransgression unless @agreement.can_be_read_by?(@user)
22
+ @user_agreement = UserAgreement.new(:agreement => @agreement) if @agreement.can_be_accepted_by?(@user)
23
+ @accept_path = session.delete(:fine_print_accept_path)
24
+ @url = session.delete(:fine_print_request_url)
25
+ @ref = session.delete(:fine_print_request_ref)
26
+
27
+ respond_to do |format|
28
+ format.html # show.html.erb
29
+ format.json { render json: @agreement }
30
+ end
31
+ end
32
+
33
+ # GET /agreements/new
34
+ # GET /agreements/new.json
35
+ def new
36
+ @agreement = Agreement.new
37
+ raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
38
+
39
+ respond_to do |format|
40
+ format.html # new.html.erb
41
+ format.json { render json: @agreement }
42
+ end
43
+ end
44
+
45
+ # GET /agreements/1/edit
46
+ def edit
47
+ @agreement = Agreement.find(params[:id])
48
+ raise SecurityTransgression unless @agreement.can_be_edited_by?(@user)
49
+ end
50
+
51
+ # GET /agreements/1/new_version
52
+ def new_version
53
+ @agreement = Agreement.find(params[:agreement_id]).dup
54
+ raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
55
+
56
+ respond_to do |format|
57
+ format.html # new_version.html.erb
58
+ format.json { render json: @agreement }
59
+ end
60
+ end
61
+
62
+ # POST /agreements
63
+ # POST /agreements.json
64
+ def create
65
+ @agreement = Agreement.new(params[:agreement])
66
+ raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
67
+ @agreement.version = Agreement.next_version(@agreement.name)
68
+
69
+ respond_to do |format|
70
+ if @agreement.save
71
+ format.html { redirect_to @agreement, notice: 'Agreement was successfully created.' }
72
+ format.json { render json: @agreement, status: :created, location: @agreement }
73
+ else
74
+ format.html { render action: "new" }
75
+ format.json { render json: @agreement.errors, status: :unprocessable_entity }
76
+ end
77
+ end
78
+ end
79
+
80
+ # PUT /agreements/1
81
+ # PUT /agreements/1.json
82
+ def update
83
+ @agreement = Agreement.find(params[:id])
84
+ raise SecurityTransgression unless @agreement.can_be_edited_by?(@user)
85
+ if params[:agreement][:name].try(:downcase) != @agreement.name.downcase
86
+ params[:agreement][:version] = Agreement.next_version(params[:agreement][:name])
87
+ end
88
+
89
+ respond_to do |format|
90
+ if @agreement.update_attributes(params[:agreement])
91
+ format.html { redirect_to @agreement, notice: 'Agreement was successfully updated.' }
92
+ format.json { head :no_content }
93
+ else
94
+ format.html { render action: "edit" }
95
+ format.json { render json: @agreement.errors, status: :unprocessable_entity }
96
+ end
97
+ end
98
+ end
99
+
100
+ # DELETE /agreements/1
101
+ # DELETE /agreements/1.json
102
+ def destroy
103
+ @agreement = Agreement.find(params[:id])
104
+ raise SecurityTransgression unless @agreement.can_be_destroyed_by?(@user)
105
+ @agreement.destroy
106
+
107
+ respond_to do |format|
108
+ format.html { redirect_to agreements_url }
109
+ format.json { head :no_content }
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,13 @@
1
+ module FinePrint
2
+ class ApplicationController < ActionController::Base
3
+ before_filter :get_user
4
+
5
+ rescue_from SecurityTransgression, :with => lambda { redirect_to FinePrint.redirect_path }
6
+
7
+ protected
8
+
9
+ def get_user
10
+ @user = self.send FinePrint.current_user_method
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module FinePrint
2
+ class ApplicationController < ActionController::Base
3
+ before_filter :get_user
4
+ helper MyEngine::Engine.helpers
5
+ rescue_from SecurityTransgression, :with => lambda { redirect_to FinePrint.redirect_path }
6
+
7
+ protected
8
+
9
+ def get_user
10
+ @user = self.send FinePrint.current_user_method
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require_dependency "fine_print/application_controller"
2
+
3
+ module FinePrint
4
+ class HomeController < ApplicationController
5
+ # GET /fine_print
6
+ def index
7
+ raise SecurityTransgression unless Agreement.can_be_listed_by?(@user) && UserAgreement.can_be_listed_by?(@user)
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ require_dependency "fine_print/application_controller"
2
+
3
+ module FinePrint
4
+ class HomeController < ApplicationController
5
+ # GET /fine_print
6
+ def index
7
+ raise SecurityTransgression unless Agreement.can_be_listed_by?(@user) && UserAgreement.can_be_listed_by?(@user)
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ format.json { render json: @agreements }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,63 @@
1
+ require_dependency "fine_print/application_controller"
2
+
3
+ module FinePrint
4
+ class UserAgreementsController < ApplicationController
5
+ # GET /user_agreements
6
+ # GET /user_agreements.json
7
+ def index
8
+ raise SecurityTransgression unless UserAgreement.can_be_listed_by?(@user)
9
+ @user_agreements = UserAgreement.all
10
+
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.json { render json: @user_agreements }
14
+ end
15
+ end
16
+
17
+ # POST /user_agreements
18
+ # POST /user_agreements.json
19
+ def create
20
+ @agreement = Agreement.find(params[:agreement_id])
21
+ raise SecurityTransgression unless @agreement.can_be_accepted_by?(@user)
22
+
23
+ if params[:cancel] || (@agreement.display_confirmation && !params[:confirmation_checkbox])
24
+ respond_to do |format|
25
+ format.html { redirect_to params[:ref] || FinePrint.get_option(params, :cancel_path) }
26
+ format.js { render 'cancel' }
27
+ end
28
+ return
29
+ end
30
+
31
+ @index = params[:index].to_i
32
+ @user_agreement = UserAgreement.new
33
+ @user_agreement.agreement = @agreement
34
+ @user_agreement.user = @user
35
+ redirect_path = params[:url] || FinePrint.get_option(params, :accept_path)
36
+
37
+ respond_to do |format|
38
+ if @user_agreement.save
39
+ format.html { redirect_to redirect_path, notice: "#{@user_agreement.agreement.name} accepted." }
40
+ format.json { render json: @user_agreement, status: :created, location: @user_agreement }
41
+ format.js
42
+ else
43
+ format.html { redirect_to redirect_path, notice: "You have already accepted this agreement." }
44
+ format.json { render json: @user_agreement.errors, status: :unprocessable_entity }
45
+ format.js { redirect_to redirect_path, notice: "You have already accepted this agreement." }
46
+ end
47
+ end
48
+ end
49
+
50
+ # DELETE /user_agreements/1
51
+ # DELETE /user_agreements/1.json
52
+ def destroy
53
+ @user_agreement = UserAgreement.find(params[:id])
54
+ raise SecurityTransgression unless @user_agreement.can_be_destroyed_by?(@user)
55
+ @user_agreement.destroy
56
+
57
+ respond_to do |format|
58
+ format.html { redirect_to user_agreements_url }
59
+ format.json { head :no_content }
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,63 @@
1
+ require_dependency "fine_print/application_controller"
2
+
3
+ module FinePrint
4
+ class UserAgreementsController < ApplicationController
5
+ # GET /user_agreements
6
+ # GET /user_agreements.json
7
+ def index
8
+ raise SecurityTransgression unless UserAgreement.can_be_listed_by?(@user)
9
+ @user_agreements = UserAgreement.all
10
+
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.json { render json: @user_agreements }
14
+ end
15
+ end
16
+
17
+ # POST /user_agreements
18
+ # POST /user_agreements.json
19
+ def create
20
+ @agreement = Agreement.find(params[:agreement_id])
21
+ raise SecurityTransgression unless @agreement.can_be_accepted_by?(@user)
22
+
23
+ if params[:cancel] || (@agreement.display_confirmation && !params[:confirmation_checkbox])
24
+ respond_to do |format|
25
+ format.html { redirect_to params[:ref] || FinePrint.get_option(params, :cancel_path) }
26
+ format.js { render 'cancel' }
27
+ end
28
+ return
29
+ end
30
+
31
+ @index = params[:index].to_i
32
+ @user_agreement = UserAgreement.new
33
+ @user_agreement.agreement = @agreement
34
+ @user_agreement.user = @user
35
+ redirect_path = params[:url] || FinePrint.get_option(params, :redirect_path)
36
+
37
+ respond_to do |format|
38
+ if @user_agreement.save
39
+ format.html { redirect_to redirect_path, notice: "#{@user_agreement.agreement.name} accepted." }
40
+ format.json { render json: @user_agreement, status: :created, location: @user_agreement }
41
+ format.js
42
+ else
43
+ format.html { redirect_to redirect_path, notice: "You have already accepted this agreement." }
44
+ format.json { render json: @user_agreement.errors, status: :unprocessable_entity }
45
+ format.js { redirect_to redirect_path, notice: "You have already accepted this agreement." }
46
+ end
47
+ end
48
+ end
49
+
50
+ # DELETE /user_agreements/1
51
+ # DELETE /user_agreements/1.json
52
+ def destroy
53
+ @user_agreement = UserAgreement.find(params[:id])
54
+ raise SecurityTransgression unless @user_agreement.can_be_destroyed_by?(@user)
55
+ @user_agreement.destroy
56
+
57
+ respond_to do |format|
58
+ format.html { redirect_to user_agreements_url }
59
+ format.json { head :no_content }
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,50 @@
1
+ module FinePrint
2
+ class Agreement < ActiveRecord::Base
3
+ attr_accessible :name, :version, :content, :confirmation_text, :display_name, :display_version, :display_updated, :display_confirmation, :ready
4
+
5
+ has_many :user_agreements
6
+
7
+ validates_presence_of :name, :content, :version
8
+ validates_uniqueness_of :name, :scope => :version, :case_sensitive => false
9
+
10
+ default_scope order(:name, :version)
11
+
12
+ def self.latest(name)
13
+ find(:last, :conditions => ["LOWER(name) = ?", name.try(:downcase)])
14
+ end
15
+
16
+ def self.next_version(name)
17
+ (latest(name).try(:version) || 0) + 1
18
+ end
19
+
20
+ def self.latest_ready(name)
21
+ where(:ready => true).find(:last, :conditions => ["LOWER(name) = ?", name.try(:downcase)])
22
+ end
23
+
24
+ def accepted_by?(user)
25
+ !user.nil? && !user_agreements.where(:user_type => user.class.to_s, :user_id => user.id).empty?
26
+ end
27
+
28
+ def self.can_be_listed_by?(user)
29
+ FinePrint.is_admin?(user)
30
+ end
31
+
32
+ def can_be_read_by?(user)
33
+ ready || FinePrint.is_admin?(user)
34
+ end
35
+
36
+ def can_be_accepted_by?(user)
37
+ ready && !user.nil?
38
+ end
39
+
40
+ def can_be_created_by?(user)
41
+ FinePrint.is_admin?(user)
42
+ end
43
+
44
+ def can_be_edited_by?(user)
45
+ FinePrint.is_admin?(user) && user_agreements.empty?
46
+ end
47
+
48
+ alias_method :can_be_destroyed_by?, :can_be_edited_by?
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ module FinePrint
2
+ class Agreement < ActiveRecord::Base
3
+ attr_accessible :name, :version, :content, :display_name, :display_version, :display_updated, :display_confirmation, :ready
4
+
5
+ has_many :user_agreements
6
+
7
+ validates_presence_of :name, :content, :version
8
+ validates_uniqueness_of :name, :scope => :version, :case_sensitive => false
9
+
10
+ default_scope order(:name, :version)
11
+
12
+ def self.latest(name)
13
+ find(:last, :conditions => ["LOWER(name) = ?", name.try(:downcase)])
14
+ end
15
+
16
+ def self.next_version(name)
17
+ (latest(name).try(:version) || 0) + 1
18
+ end
19
+
20
+ def self.latest_ready(name)
21
+ where(:ready => true).find(:last, :conditions => ["LOWER(name) = ?", name.try(:downcase)])
22
+ end
23
+
24
+ def accepted_by?(user)
25
+ !user.nil? && !user_agreements.where(:user_type => user.class.to_s, :user_id => user.id).empty?
26
+ end
27
+
28
+ def self.can_be_listed_by?(user)
29
+ FinePrint.is_admin?(user)
30
+ end
31
+
32
+ def can_be_read_by?(user)
33
+ ready || FinePrint.is_admin?(user)
34
+ end
35
+
36
+ def can_be_accepted_by?(user)
37
+ ready && !user.nil?
38
+ end
39
+
40
+ def can_be_created_by?(user)
41
+ FinePrint.is_admin?(user)
42
+ end
43
+
44
+ def can_be_edited_by?(user)
45
+ FinePrint.is_admin?(user) && user_agreements.empty?
46
+ end
47
+
48
+ alias_method :can_be_destroyed_by?, :can_be_edited_by?
49
+ end
50
+ end
@@ -0,0 +1,19 @@
1
+ module FinePrint
2
+ class UserAgreement < ActiveRecord::Base
3
+ belongs_to :agreement
4
+ belongs_to :user, :polymorphic => true
5
+
6
+ validates_presence_of :agreement, :user
7
+ validates_uniqueness_of :user_id, :scope => [:agreement_id, :user_type]
8
+
9
+ default_scope order(:agreement_id, :user_type, :user_id)
10
+
11
+ def self.can_be_listed_by?(user)
12
+ FinePrint.is_admin?(user)
13
+ end
14
+
15
+ def can_be_destroyed_by?(user)
16
+ FinePrint.is_admin?(user)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module FinePrint
2
+ class UserAgreement < ActiveRecord::Base
3
+ attr_accessible :agreement
4
+
5
+ belongs_to :agreement
6
+ belongs_to :user, :polymorphic => true
7
+
8
+ validates_presence_of :agreement, :user
9
+ validates_uniqueness_of :user_id, :scope => [:agreement_id, :user_type]
10
+
11
+ default_scope order(:agreement_id, :user_type, :user_id)
12
+
13
+ def self.can_be_listed_by?(user)
14
+ FinePrint.is_admin?(user)
15
+ end
16
+
17
+ def can_be_destroyed_by?(user)
18
+ FinePrint.is_admin?(user)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,77 @@
1
+ <% # Clients of this partial must supply the following variable:
2
+ # agreement
3
+ # user
4
+ #
5
+ # Additionally, they can override the following variables:
6
+ index ||= 0
7
+ notice ||= nil
8
+ accept_path ||= nil
9
+ cancel_path ||= nil
10
+ url ||= nil
11
+ ref ||= nil
12
+ remote ||= false %>
13
+
14
+ <% unless notice.nil? %>
15
+ <p id="notice" class = "fine_print notice"><%= notice %></p>
16
+ <% end %>
17
+
18
+ <% if agreement.display_name %>
19
+ <h1 class="fine_print agreement name">
20
+ <%= agreement.name %>
21
+ </h1>
22
+ <% end %>
23
+
24
+ <% if agreement.display_version %>
25
+ <h3 class="fine_print agreement version">
26
+ Version: <%= agreement.version %>
27
+ </h3>
28
+ <% end %>
29
+
30
+ <% if agreement.display_updated %>
31
+ <h3 class="fine_print agreement updated">
32
+ Last updated: <%= agreement.updated_at %>
33
+ </h3>
34
+ <% end %>
35
+
36
+ <pre class="fine_print agreement content">
37
+ <%= agreement.content %>
38
+ </pre>
39
+
40
+ <% if agreement.can_be_accepted_by?(user) %>
41
+ <%= form_tag fine_print.user_agreements_path, :remote => remote do %>
42
+ <%= hidden_field_tag :agreement_id, agreement.id %>
43
+ <%= hidden_field_tag :index, index %>
44
+ <% unless accept_path.nil? %>
45
+ <%= hidden_field_tag :accept_path, accept_path %>
46
+ <% end %>
47
+ <% unless cancel_path.nil? %>
48
+ <%= hidden_field_tag :cancel_path, cancel_path %>
49
+ <% end %>
50
+ <% unless url.nil? %>
51
+ <%= hidden_field_tag :url, url %>
52
+ <% end %>
53
+ <% unless ref.nil? %>
54
+ <%= hidden_field_tag :ref, ref %>
55
+ <% end %>
56
+ <% if agreement.display_confirmation %>
57
+ <div class="field">
58
+ <%= label_tag :confirmation_checkbox, agreement.confirmation_text, :class => "fine_print label" %>
59
+ <%= check_box_tag :confirmation_checkbox, 1, false, :id => "fine_print_confirmation_checkbox_#{index}", :class => "fine_print checkbox" %><br/>
60
+ </div>
61
+ <% end %>
62
+ <div class="actions">
63
+ <%= submit_tag (agreement.display_confirmation ? 'OK' : agreement.confirmation_text), :id => "fine_print_submit_ok_#{index}", :class => "fine_print submit" %>
64
+ <%= submit_tag :Cancel, :name => 'cancel', :class => "fine_print submit" %>
65
+ </div>
66
+ <% end %>
67
+ <% if agreement.display_confirmation %>
68
+ <script>
69
+ fine_print_agreement_checkbox(<%= index %>);
70
+ </script>
71
+ <% end %>
72
+ <% elsif !agreement.ready %>
73
+ This agreement is not yet ready to be used.<br/>
74
+ <% else %>
75
+ Please <%= FinePrint.sign_in_path.nil? ? 'sign in' : link_to('sign in', FinePrint.sign_in_path) %> to accept this agreement.<br/>
76
+ <% end %>
77
+
@@ -0,0 +1,77 @@
1
+ <% # Clients of this partial must supply the following variable:
2
+ # agreement
3
+ # user
4
+ #
5
+ # Additionally, they can override the following variables:
6
+ index ||= 0
7
+ notice ||= nil
8
+ accept_path ||= nil
9
+ cancel_path ||= nil
10
+ url ||= nil
11
+ ref ||= nil
12
+ remote ||= false %>
13
+
14
+ <% if notice %>
15
+ <p id="notice" class = "fine_print notice"><%= notice %></p>
16
+ <% end %>
17
+
18
+ <% if agreement.display_name %>
19
+ <h1 class="fine_print agreement name">
20
+ <%= agreement.name %>
21
+ </h1>
22
+ <% end %>
23
+
24
+ <% if agreement.display_version %>
25
+ <h3 class="fine_print agreement version">
26
+ Version: <%= agreement.version %>
27
+ </h3>
28
+ <% end %>
29
+
30
+ <% if agreement.display_updated %>
31
+ <h3 class="fine_print agreement updated">
32
+ Last updated: <%= agreement.updated_at %>
33
+ </h3>
34
+ <% end %>
35
+
36
+ <pre class="fine_print agreement content">
37
+ <%= agreement.content %>
38
+ </pre>
39
+
40
+ <% if agreement.can_be_accepted_by?(user) %>
41
+ <%= form_tag fine_print.user_agreements_path, :remote => remote do %>
42
+ <%= hidden_field_tag :agreement_id, agreement.id %>
43
+ <%= hidden_field_tag :index, index %>
44
+ <% unless accept_path.nil? %>
45
+ <%= hidden_field_tag :accept_path, accept_path %>
46
+ <% end %>
47
+ <% unless cancel_path.nil? %>
48
+ <%= hidden_field_tag :cancel_path, cancel_path %>
49
+ <% end %>
50
+ <% unless url.nil? %>
51
+ <%= hidden_field_tag :url, url %>
52
+ <% end %>
53
+ <% unless ref.nil? %>
54
+ <%= hidden_field_tag :ref, ref %>
55
+ <% end %>
56
+ <% if agreement.display_confirmation %>
57
+ <div class="field">
58
+ <%= label_tag :confirmation_checkbox, agreement.confirmation_text, :class => "fine_print label" %>
59
+ <%= check_box_tag :confirmation_checkbox, 1, false, :id => "fine_print_confirmation_checkbox_#{index}", :class => "fine_print checkbox" %><br/>
60
+ </div>
61
+ <% end %>
62
+ <div class="actions">
63
+ <%= submit_tag (agreement.display_confirmation ? 'OK' : agreement.confirmation_text), :id => "fine_print_submit_ok_#{index}", :class => "fine_print submit" %>
64
+ <%= submit_tag :Cancel, :name => 'cancel', :class => "fine_print submit" %>
65
+ </div>
66
+ <% end %>
67
+ <% if agreement.display_confirmation %>
68
+ <script>
69
+ fine_print_agreement_checkbox(<%= index %>);
70
+ </script>
71
+ <% end %>
72
+ <% elsif !agreement.ready %>
73
+ This agreement is not yet ready to be used.<br/>
74
+ <% else %>
75
+ Please <%= FinePrint.sign_in_path.nil? ? 'sign in' : link_to('sign in', FinePrint.sign_in_path) %> to accept this agreement.<br/>
76
+ <% end %>
77
+
@@ -0,0 +1,27 @@
1
+ <% # Clients of this partial must supply the following variables:
2
+ # agreements
3
+ # user
4
+ # notice
5
+ #
6
+ # Additionally, they can override the following variables:
7
+ width ||= 640
8
+ height ||= 480 %>
9
+
10
+ <%= stylesheet_link_tag 'fine_print/application' %>
11
+ <%= javascript_include_tag 'fine_print/dialog' %>
12
+
13
+ <% agreements.each_with_index do |agreement, index| %>
14
+ <div id="<%= "fine_print_dialog_#{index}" %>" title="<%= agreement.name %>" class="fine_print agreement dialog">
15
+ <%= render :partial => 'fine_print/agreements/agreement', :locals => {
16
+ :agreement => agreement,
17
+ :index => index,
18
+ :user => user,
19
+ :notice => notice,
20
+ :remote => true } %>
21
+ </div>
22
+
23
+ <script>
24
+ fine_print_init_dialog(<%= index %>, <%= width %>, <%= height %>);
25
+ </script>
26
+ <% end %>
27
+
@@ -0,0 +1,27 @@
1
+ <% # Clients of this partial must supply the following variables:
2
+ # agreements
3
+ # user
4
+ # notice
5
+ #
6
+ # Additionally, they can override the following variables:
7
+ width ||= 640
8
+ height ||= 480 %>
9
+
10
+ <%= stylesheet_link_tag 'fine_print/application' %>
11
+ <%= javascript_include_tag 'fine_print/dialog' %>
12
+
13
+ <% agreements.each_with_index do |agreement, index| %>
14
+ <div id="<%= "fine_print_dialog_#{index}" %>" title="<%= agreement.name %>" class="fine_print agreement dialog">
15
+ <%= render :partial => 'fine_print/agreements/agreement', :locals => {
16
+ :agreement => agreement,
17
+ :index => index,
18
+ :user => user,
19
+ :notice => notice,
20
+ :remote => true } %>
21
+ </div>
22
+
23
+ <script>
24
+ fine_print_init_dialog(<%= index %>, width, height);
25
+ </script>
26
+ <% end %>
27
+