request_refinery 0.0.1
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/request_refinery/application.js +13 -0
- data/app/assets/javascripts/request_refinery/controller_filters.js +2 -0
- data/app/assets/javascripts/request_refinery/customers.js +2 -0
- data/app/assets/javascripts/request_refinery/permissions.js +2 -0
- data/app/assets/javascripts/request_refinery/roles.js +2 -0
- data/app/assets/stylesheets/request_refinery/application.css +15 -0
- data/app/assets/stylesheets/request_refinery/controller_filters.css +4 -0
- data/app/assets/stylesheets/request_refinery/customers.css +4 -0
- data/app/assets/stylesheets/request_refinery/permissions.css +4 -0
- data/app/assets/stylesheets/request_refinery/roles.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/request_refinery/application_controller.rb +11 -0
- data/app/controllers/request_refinery/controller_filters_controller.rb +62 -0
- data/app/controllers/request_refinery/customers_controller.rb +62 -0
- data/app/controllers/request_refinery/permissions_controller.rb +62 -0
- data/app/controllers/request_refinery/roles_controller.rb +62 -0
- data/app/helpers/request_refinery/application_helper.rb +4 -0
- data/app/helpers/request_refinery/controller_filters_helper.rb +4 -0
- data/app/helpers/request_refinery/customers_helper.rb +4 -0
- data/app/helpers/request_refinery/permissions_helper.rb +4 -0
- data/app/helpers/request_refinery/roles_helper.rb +4 -0
- data/app/models/request_refinery/controller_filter.rb +5 -0
- data/app/models/request_refinery/customer.rb +5 -0
- data/app/models/request_refinery/permission.rb +11 -0
- data/app/models/request_refinery/role.rb +9 -0
- data/app/models/request_refinery/user.rb +51 -0
- data/app/views/layouts/request_refinery/application.html.erb +15 -0
- data/app/views/request_refinery/controller_filters/_form.html.erb +29 -0
- data/app/views/request_refinery/controller_filters/edit.html.erb +6 -0
- data/app/views/request_refinery/controller_filters/index.html.erb +29 -0
- data/app/views/request_refinery/controller_filters/new.html.erb +5 -0
- data/app/views/request_refinery/controller_filters/show.html.erb +19 -0
- data/app/views/request_refinery/customers/_form.html.erb +33 -0
- data/app/views/request_refinery/customers/edit.html.erb +6 -0
- data/app/views/request_refinery/customers/index.html.erb +31 -0
- data/app/views/request_refinery/customers/new.html.erb +5 -0
- data/app/views/request_refinery/customers/show.html.erb +24 -0
- data/app/views/request_refinery/permissions/_form.html.erb +21 -0
- data/app/views/request_refinery/permissions/edit.html.erb +6 -0
- data/app/views/request_refinery/permissions/index.html.erb +28 -0
- data/app/views/request_refinery/permissions/new.html.erb +5 -0
- data/app/views/request_refinery/permissions/show.html.erb +9 -0
- data/app/views/request_refinery/roles/_form.html.erb +29 -0
- data/app/views/request_refinery/roles/edit.html.erb +6 -0
- data/app/views/request_refinery/roles/index.html.erb +29 -0
- data/app/views/request_refinery/roles/new.html.erb +5 -0
- data/app/views/request_refinery/roles/show.html.erb +19 -0
- data/config/initializers/application_controller.rb +9 -0
- data/config/initializers/devise.rb +261 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20141003181010_devise_create_request_refinery_users.rb +76 -0
- data/db/migrate/20141003190734_create_request_refinery_controller_filters.rb +18 -0
- data/db/migrate/20141003190741_create_request_refinery_permissions.rb +31 -0
- data/db/migrate/20141003194717_create_request_refinery_customers.rb +12 -0
- data/db/seeds.rb +0 -0
- data/lib/generators/request_refinery/install_generator.rb +79 -0
- data/lib/request_refinery/engine.rb +15 -0
- data/lib/request_refinery/version.rb +3 -0
- data/lib/request_refinery.rb +70 -0
- data/lib/tasks/request_refinery_tasks.rake +4 -0
- metadata +172 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2c599438145bf3824bb157df27028e2d98bddd69
|
|
4
|
+
data.tar.gz: fc383596b104aaf01cac990f8e0c352000fadefb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2fe4b3668b2d4389df0ed04419bbdc3a0f38c52b1b534acab11ebc05f59085015e39a4f260763ee0019aaa5cf103b76f78a86d2c0af92198e94c2c1c83576529
|
|
7
|
+
data.tar.gz: 513e0c8e2b24eff809cebe56e489c36e017ee73536a56b822dcd0e69f573352a2a206672f03328210e3b448d9524e2f4a146e00a40427ae7284e893356b8f622
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2014 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'RequestRefinery'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'lib'
|
|
28
|
+
t.libs << 'test'
|
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
|
30
|
+
t.verbose = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task default: :test
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
div.field, div.actions {
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#notice {
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.field_with_errors {
|
|
28
|
+
padding: 2px;
|
|
29
|
+
background-color: red;
|
|
30
|
+
display: table;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#error_explanation {
|
|
34
|
+
width: 450px;
|
|
35
|
+
border: 2px solid red;
|
|
36
|
+
padding: 7px;
|
|
37
|
+
padding-bottom: 0;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
background-color: #f0f0f0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#error_explanation h2 {
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
padding: 5px 5px 5px 15px;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
margin: -7px;
|
|
48
|
+
margin-bottom: 0px;
|
|
49
|
+
background-color: #c00;
|
|
50
|
+
color: #fff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#error_explanation ul li {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
list-style: square;
|
|
56
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module RequestRefinery
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
before_action :authenticate_user!
|
|
4
|
+
before_action :enforce_request_permissions, except: [:unauthorized_request, :users]
|
|
5
|
+
|
|
6
|
+
helper_method :authorized_to?
|
|
7
|
+
|
|
8
|
+
include RequestRefinery::ControllerMethods
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_dependency "request_refinery/application_controller"
|
|
2
|
+
|
|
3
|
+
module RequestRefinery
|
|
4
|
+
class ControllerFiltersController < ApplicationController
|
|
5
|
+
before_action :set_controller_filter, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
# GET /controller_filters
|
|
8
|
+
def index
|
|
9
|
+
@controller_filters = ControllerFilter.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /controller_filters/1
|
|
13
|
+
def show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /controller_filters/new
|
|
17
|
+
def new
|
|
18
|
+
@controller_filter = ControllerFilter.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /controller_filters/1/edit
|
|
22
|
+
def edit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# POST /controller_filters
|
|
26
|
+
def create
|
|
27
|
+
@controller_filter = ControllerFilter.new(controller_filter_params)
|
|
28
|
+
|
|
29
|
+
if @controller_filter.save
|
|
30
|
+
redirect_to @controller_filter, notice: 'Controller filter was successfully created.'
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# PATCH/PUT /controller_filters/1
|
|
37
|
+
def update
|
|
38
|
+
if @controller_filter.update(controller_filter_params)
|
|
39
|
+
redirect_to @controller_filter, notice: 'Controller filter was successfully updated.'
|
|
40
|
+
else
|
|
41
|
+
render :edit
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# DELETE /controller_filters/1
|
|
46
|
+
def destroy
|
|
47
|
+
@controller_filter.destroy
|
|
48
|
+
redirect_to controller_filters_url, notice: 'Controller filter was successfully destroyed.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
53
|
+
def set_controller_filter
|
|
54
|
+
@controller_filter = ControllerFilter.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
|
58
|
+
def controller_filter_params
|
|
59
|
+
params.require(:controller_filter).permit(:http_method, :controller, :action_name)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_dependency "request_refinery/application_controller"
|
|
2
|
+
|
|
3
|
+
module RequestRefinery
|
|
4
|
+
class CustomersController < ApplicationController
|
|
5
|
+
before_action :set_customer, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
# GET /customers
|
|
8
|
+
def index
|
|
9
|
+
@customers = Customer.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /customers/1
|
|
13
|
+
def show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /customers/new
|
|
17
|
+
def new
|
|
18
|
+
@customer = Customer.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /customers/1/edit
|
|
22
|
+
def edit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# POST /customers
|
|
26
|
+
def create
|
|
27
|
+
@customer = Customer.new(customer_params)
|
|
28
|
+
|
|
29
|
+
if @customer.save
|
|
30
|
+
redirect_to @customer, notice: 'Customer was successfully created.'
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# PATCH/PUT /customers/1
|
|
37
|
+
def update
|
|
38
|
+
if @customer.update(customer_params)
|
|
39
|
+
redirect_to @customer, notice: 'Customer was successfully updated.'
|
|
40
|
+
else
|
|
41
|
+
render :edit
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# DELETE /customers/1
|
|
46
|
+
def destroy
|
|
47
|
+
@customer.destroy
|
|
48
|
+
redirect_to customers_url, notice: 'Customer was successfully destroyed.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
53
|
+
def set_customer
|
|
54
|
+
@customer = Customer.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
|
58
|
+
def customer_params
|
|
59
|
+
params.require(:customer).permit(:cust_id, :prefix, :folder_name, :error_email_recipients)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_dependency "request_refinery/application_controller"
|
|
2
|
+
|
|
3
|
+
module RequestRefinery
|
|
4
|
+
class PermissionsController < ApplicationController
|
|
5
|
+
before_action :set_permission, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
# GET /permissions
|
|
8
|
+
def index
|
|
9
|
+
@permissions = Permission.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /permissions/1
|
|
13
|
+
def show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /permissions/new
|
|
17
|
+
def new
|
|
18
|
+
@permission = Permission.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /permissions/1/edit
|
|
22
|
+
def edit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# POST /permissions
|
|
26
|
+
def create
|
|
27
|
+
@permission = Permission.new(permission_params)
|
|
28
|
+
|
|
29
|
+
if @permission.save
|
|
30
|
+
redirect_to @permission, notice: 'Permission was successfully created.'
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# PATCH/PUT /permissions/1
|
|
37
|
+
def update
|
|
38
|
+
if @permission.update(permission_params)
|
|
39
|
+
redirect_to @permission, notice: 'Permission was successfully updated.'
|
|
40
|
+
else
|
|
41
|
+
render :edit
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# DELETE /permissions/1
|
|
46
|
+
def destroy
|
|
47
|
+
@permission.destroy
|
|
48
|
+
redirect_to permissions_url, notice: 'Permission was successfully destroyed.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
53
|
+
def set_permission
|
|
54
|
+
@permission = Permission.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
|
58
|
+
def permission_params
|
|
59
|
+
params.require(:permission).permit(:name)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_dependency "request_refinery/application_controller"
|
|
2
|
+
|
|
3
|
+
module RequestRefinery
|
|
4
|
+
class RolesController < ApplicationController
|
|
5
|
+
before_action :set_role, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
# GET /roles
|
|
8
|
+
def index
|
|
9
|
+
@roles = Role.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /roles/1
|
|
13
|
+
def show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /roles/new
|
|
17
|
+
def new
|
|
18
|
+
@role = Role.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /roles/1/edit
|
|
22
|
+
def edit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# POST /roles
|
|
26
|
+
def create
|
|
27
|
+
@role = Role.new(role_params)
|
|
28
|
+
|
|
29
|
+
if @role.save
|
|
30
|
+
redirect_to @role, notice: 'Role was successfully created.'
|
|
31
|
+
else
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# PATCH/PUT /roles/1
|
|
37
|
+
def update
|
|
38
|
+
if @role.update(role_params)
|
|
39
|
+
redirect_to @role, notice: 'Role was successfully updated.'
|
|
40
|
+
else
|
|
41
|
+
render :edit
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# DELETE /roles/1
|
|
46
|
+
def destroy
|
|
47
|
+
@role.destroy
|
|
48
|
+
redirect_to roles_url, notice: 'Role was successfully destroyed.'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
53
|
+
def set_role
|
|
54
|
+
@role = Role.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Only allow a trusted parameter "white list" through.
|
|
58
|
+
def role_params
|
|
59
|
+
params.require(:role).permit(:role_group, :permissions, :restrictions)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module RequestRefinery
|
|
2
|
+
class Permission < ActiveRecord::Base
|
|
3
|
+
has_and_belongs_to_many :roles
|
|
4
|
+
has_and_belongs_to_many :users
|
|
5
|
+
has_and_belongs_to_many :inverse_roles, :class_name => "Role", :join_table => "request_refinery_restrictions_inverse_roles"
|
|
6
|
+
has_and_belongs_to_many :inverse_users, :class_name => "User", :join_table => "request_refinery_inverse_users_restrictions"
|
|
7
|
+
has_and_belongs_to_many :controller_filters
|
|
8
|
+
|
|
9
|
+
validates :name, presence: true, uniqueness: true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module RequestRefinery
|
|
2
|
+
class Role < ActiveRecord::Base
|
|
3
|
+
has_and_belongs_to_many :permissions
|
|
4
|
+
has_and_belongs_to_many :users
|
|
5
|
+
has_and_belongs_to_many :restrictions, :class_name => "Permission", :join_table => "request_refinery_restrictions_inverse_roles"
|
|
6
|
+
|
|
7
|
+
validates :group, presence: true, uniqueness: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module RequestRefinery
|
|
2
|
+
require 'devise'
|
|
3
|
+
require_relative "../../../config/initializers/devise.rb"
|
|
4
|
+
|
|
5
|
+
class User < ActiveRecord::Base
|
|
6
|
+
# Include default devise modules. Others available are:
|
|
7
|
+
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
8
|
+
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
|
|
9
|
+
|
|
10
|
+
before_create :initialize_username
|
|
11
|
+
before_save :initialize_username
|
|
12
|
+
|
|
13
|
+
has_and_belongs_to_many :permissions
|
|
14
|
+
has_and_belongs_to_many :restrictions, :class_name => "Permission", :join_table => "request_refinery_inverse_users_restrictions"
|
|
15
|
+
has_and_belongs_to_many :roles
|
|
16
|
+
has_and_belongs_to_many :customers
|
|
17
|
+
|
|
18
|
+
validates :email, presence: true, uniqueness: true
|
|
19
|
+
validates :password, presence: true
|
|
20
|
+
|
|
21
|
+
def initialize_username
|
|
22
|
+
self.username = self.email if self.username.blank? or User.where(username:self.username).count > 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def permissions
|
|
26
|
+
# get permissions from Permissions and Roles, account for the :all permission
|
|
27
|
+
p = super
|
|
28
|
+
self.roles.each{|x| p += x.permissions} # parse permissions from the user's roles
|
|
29
|
+
p_a = p.to_a
|
|
30
|
+
(p_a = Permission.all.to_a) if p.any? {|x| x.name == "all"} # if they have the all permissions, give them all permissions
|
|
31
|
+
|
|
32
|
+
# get restrictions
|
|
33
|
+
r = self.restrictions
|
|
34
|
+
r_a = r.to_a
|
|
35
|
+
|
|
36
|
+
# remove restrictions from the permissions
|
|
37
|
+
p_s = Set.new(p_a) - Set.new(r_a)
|
|
38
|
+
|
|
39
|
+
return p_s.to_a
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def permission_syms
|
|
43
|
+
self.permissions.collect{|x| x.name.to_sym}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def permission_strings
|
|
47
|
+
self.permissions.collect{|x| x.name}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>RequestRefinery</title>
|
|
5
|
+
<%= stylesheet_link_tag "request_refinery/application", media: "all" %>
|
|
6
|
+
<%= javascript_include_tag "request_refinery/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<p class="notice"><%= notice %></p>
|
|
11
|
+
<p class="alert"><%= alert %></p>
|
|
12
|
+
<%= yield %>
|
|
13
|
+
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= form_for(@controller_filter) do |f| %>
|
|
2
|
+
<% if @controller_filter.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@controller_filter.errors.count, "error") %> prohibited this controller_filter from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @controller_filter.errors.full_messages.each do |message| %>
|
|
8
|
+
<li><%= message %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :http_method %><br>
|
|
16
|
+
<%= f.text_field :http_method %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :controller %><br>
|
|
20
|
+
<%= f.text_field :controller %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="field">
|
|
23
|
+
<%= f.label :action_name %><br>
|
|
24
|
+
<%= f.text_field :action_name %>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="actions">
|
|
27
|
+
<%= f.submit %>
|
|
28
|
+
</div>
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<h1>Listing controller_filters</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<thead>
|
|
5
|
+
<tr>
|
|
6
|
+
<th>Http method</th>
|
|
7
|
+
<th>Controller</th>
|
|
8
|
+
<th>Action name</th>
|
|
9
|
+
<th colspan="3"></th>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
|
|
13
|
+
<tbody>
|
|
14
|
+
<% @controller_filters.each do |controller_filter| %>
|
|
15
|
+
<tr>
|
|
16
|
+
<td><%= controller_filter.http_method %></td>
|
|
17
|
+
<td><%= controller_filter.controller %></td>
|
|
18
|
+
<td><%= controller_filter.action_name %></td>
|
|
19
|
+
<td><%= link_to 'Show', controller_filter %></td>
|
|
20
|
+
<td><%= link_to 'Edit', edit_controller_filter_path(controller_filter) %></td>
|
|
21
|
+
<td><%= link_to 'Destroy', controller_filter, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
22
|
+
</tr>
|
|
23
|
+
<% end %>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
<br>
|
|
28
|
+
|
|
29
|
+
<%= link_to 'New Controller filter', new_controller_filter_path %>
|