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
@@ -1,114 +0,0 @@
|
|
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
|
-
@cancel_path = session.delete(:fine_print_cancel_path)
|
25
|
-
@url = session.delete(:fine_print_request_url)
|
26
|
-
@ref = session.delete(:fine_print_request_ref)
|
27
|
-
|
28
|
-
respond_to do |format|
|
29
|
-
format.html # show.html.erb
|
30
|
-
format.json { render json: @agreement }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# GET /agreements/new
|
35
|
-
# GET /agreements/new.json
|
36
|
-
def new
|
37
|
-
@agreement = Agreement.new
|
38
|
-
raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
|
39
|
-
|
40
|
-
respond_to do |format|
|
41
|
-
format.html # new.html.erb
|
42
|
-
format.json { render json: @agreement }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# GET /agreements/1/edit
|
47
|
-
def edit
|
48
|
-
@agreement = Agreement.find(params[:id])
|
49
|
-
raise SecurityTransgression unless @agreement.can_be_edited_by?(@user)
|
50
|
-
end
|
51
|
-
|
52
|
-
# GET /agreements/1/new_version
|
53
|
-
def new_version
|
54
|
-
@agreement = Agreement.find(params[:agreement_id]).dup
|
55
|
-
raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
|
56
|
-
|
57
|
-
respond_to do |format|
|
58
|
-
format.html # new_version.html.erb
|
59
|
-
format.json { render json: @agreement }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# POST /agreements
|
64
|
-
# POST /agreements.json
|
65
|
-
def create
|
66
|
-
@agreement = Agreement.new(params[:agreement])
|
67
|
-
raise SecurityTransgression unless @agreement.can_be_created_by?(@user)
|
68
|
-
@agreement.version = Agreement.next_version(@agreement.name)
|
69
|
-
|
70
|
-
respond_to do |format|
|
71
|
-
if @agreement.save
|
72
|
-
format.html { redirect_to @agreement, notice: 'Agreement was successfully created.' }
|
73
|
-
format.json { render json: @agreement, status: :created, location: @agreement }
|
74
|
-
else
|
75
|
-
format.html { render action: "new" }
|
76
|
-
format.json { render json: @agreement.errors, status: :unprocessable_entity }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# PUT /agreements/1
|
82
|
-
# PUT /agreements/1.json
|
83
|
-
def update
|
84
|
-
@agreement = Agreement.find(params[:id])
|
85
|
-
raise SecurityTransgression unless @agreement.can_be_edited_by?(@user)
|
86
|
-
if params[:agreement][:name].try(:downcase) != @agreement.name.downcase
|
87
|
-
params[:agreement][:version] = Agreement.next_version(params[:agreement][:name])
|
88
|
-
end
|
89
|
-
|
90
|
-
respond_to do |format|
|
91
|
-
if @agreement.update_attributes(params[:agreement])
|
92
|
-
format.html { redirect_to @agreement, notice: 'Agreement was successfully updated.' }
|
93
|
-
format.json { head :no_content }
|
94
|
-
else
|
95
|
-
format.html { render action: "edit" }
|
96
|
-
format.json { render json: @agreement.errors, status: :unprocessable_entity }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# DELETE /agreements/1
|
102
|
-
# DELETE /agreements/1.json
|
103
|
-
def destroy
|
104
|
-
@agreement = Agreement.find(params[:id])
|
105
|
-
raise SecurityTransgression unless @agreement.can_be_destroyed_by?(@user)
|
106
|
-
@agreement.destroy
|
107
|
-
|
108
|
-
respond_to do |format|
|
109
|
-
format.html { redirect_to agreements_url }
|
110
|
-
format.json { head :no_content }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,113 +0,0 @@
|
|
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
|
@@ -1,63 +0,0 @@
|
|
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
|
@@ -1,63 +0,0 @@
|
|
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
|
@@ -1,50 +0,0 @@
|
|
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
|
@@ -1,50 +0,0 @@
|
|
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
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,77 +0,0 @@
|
|
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
|
-
|
@@ -1,77 +0,0 @@
|
|
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
|
-
|
@@ -1,27 +0,0 @@
|
|
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
|
-
|