itsf_backend 1.1.7 → 1.1.8
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 +4 -4
- data/app/controllers/concerns/controller/pundit_authorization_failure_handling_concern.rb +21 -0
- data/app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb +7 -1
- data/app/controllers/itsf/backend/dashboard_controller.rb +1 -0
- data/app/controllers/itsf/backend/home_controller.rb +1 -0
- data/app/controllers/itsf/backend/resource/base_controller.rb +1 -0
- data/app/controllers/itsf/backend/service/base_controller.rb +1 -0
- data/app/views/itsf/backend/resource/base/_form_buttons.haml +3 -0
- data/app/views/itsf/backend/resource/base/_table_actions.html.haml +15 -9
- data/app/views/itsf/backend/resource/base/edit.html.haml +1 -3
- data/app/views/itsf/backend/resource/base/new.html.haml +1 -3
- data/lib/generators/itsf/backend/install/templates/initializer.rb +7 -1
- data/lib/itsf/backend/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b421756702587ef74370ab1010ab5535623d270
|
4
|
+
data.tar.gz: 94d3ee99c2857d4abf02c76d9a1d116100aaf498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a0af1ca63b6d8ca0885b5f72a1f3010764042468a3e0a6063a7fe15f245a4597e2e917781e60ce0cb956beeffe31e8ae03808a7db408fcd5b4dd2cd22ee3f8d
|
7
|
+
data.tar.gz: 537f2e9615e687a3f5160263d49cd9f03ad3b765a988d989e98e5d0422e2da259a1e4140f412f6c376df99202cc61eb83eaac980c609becb6319779c7899b8d5
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Controller
|
2
|
+
module PunditAuthorizationFailureHandlingConcern
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
rescue_from Pundit::NotAuthorizedError, with: :not_authorized
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def not_authorized(exception)
|
12
|
+
resource_name = exception.record.respond_to?(:model_name) ? exception.record.model_name.human : exception.record
|
13
|
+
collection_name = exception.record.respond_to?(:model_name) ? exception.record.model_name.human(count: :other) : exception.record
|
14
|
+
flash[:error] = I18n.t("pundit.not_authorized.#{action_name}", collection_name: collection_name,resource_name: resource_name)
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { redirect_to main_app.root_path }
|
17
|
+
format.json { render json: { error: 'not authorized' }, status: 403 }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -7,6 +7,7 @@ module Controller
|
|
7
7
|
responders :flash
|
8
8
|
end
|
9
9
|
|
10
|
+
|
10
11
|
def index
|
11
12
|
if Itsf::Backend.features?(:ransack)
|
12
13
|
@q = collection_scope_with_search_scopes(collection_scope).ransack(params[:q])
|
@@ -19,7 +20,7 @@ module Controller
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def new
|
22
|
-
@resource =
|
23
|
+
@resource = initialize_resource
|
23
24
|
authorize_action
|
24
25
|
respond_with @resource
|
25
26
|
end
|
@@ -57,6 +58,7 @@ module Controller
|
|
57
58
|
respond_with @resource, location: after_destroy_location
|
58
59
|
end
|
59
60
|
|
61
|
+
|
60
62
|
private
|
61
63
|
|
62
64
|
def after_create_location
|
@@ -93,6 +95,10 @@ module Controller
|
|
93
95
|
resource_class
|
94
96
|
end
|
95
97
|
|
98
|
+
def initialize_resource
|
99
|
+
resource_class.new
|
100
|
+
end
|
101
|
+
|
96
102
|
def load_resource
|
97
103
|
resource_class.find(params[:id])
|
98
104
|
end
|
@@ -8,6 +8,7 @@ module Itsf::Backend
|
|
8
8
|
if Itsf::Backend.features?(:pundit)
|
9
9
|
include Pundit
|
10
10
|
prepend Controller::PunditNamespacedAuthorizeConcern
|
11
|
+
include Controller::PunditAuthorizationFailureHandlingConcern
|
11
12
|
helper_method :engine_policy
|
12
13
|
|
13
14
|
after_action :verify_authorized
|
@@ -7,6 +7,7 @@ module Itsf::Backend
|
|
7
7
|
include Controller::RestActionsConcernWithPundit
|
8
8
|
include Pundit
|
9
9
|
prepend Controller::PunditNamespacedAuthorizeConcern
|
10
|
+
include Controller::PunditAuthorizationFailureHandlingConcern
|
10
11
|
helper_method :engine_policy
|
11
12
|
else
|
12
13
|
include Controller::RestActionsConcern
|
@@ -2,14 +2,20 @@
|
|
2
2
|
- id_base = "link-to-#{controller.class.name.underscore.gsub('_controller', '').gsub(/[\/_]/, '-')}-#{resource.to_param}"
|
3
3
|
.btn-group
|
4
4
|
- if !Itsf::Backend.features?(:pundit) || policy(resource).show?
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
- begin
|
6
|
+
= link_to(resource_path(resource), id: "#{id_base}-show", class: 'btn btn-xs btn-responsive btn-default') do
|
7
|
+
%span.glyphicon.glyphicon-eye-open
|
8
|
+
%span.btn-text= t('.show')
|
9
|
+
- rescue ActionController::UrlGenerationError
|
8
10
|
- if !Itsf::Backend.features?(:pundit) || policy(resource).edit?
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
- begin
|
12
|
+
= link_to(edit_resource_path(resource), id: "#{id_base}-edit", class: 'btn btn-xs btn-responsive btn-default') do
|
13
|
+
%span.glyphicon.glyphicon-pencil
|
14
|
+
%span.btn-text= t('.edit')
|
15
|
+
- rescue ActionController::UrlGenerationError
|
12
16
|
- if !Itsf::Backend.features?(:pundit) || policy(resource).destroy?
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
- begin
|
18
|
+
= link_to(resource_path(resource), id: "#{id_base}-destroy", class: 'btn btn-xs btn-responsive btn-danger', method: :delete, data: { confirm: I18n.t('.confirmations.delete') }) do
|
19
|
+
%span.glyphicon.glyphicon-fire
|
20
|
+
%span.btn-text= t('.destroy')
|
21
|
+
- rescue ActionController::UrlGenerationError
|
@@ -5,9 +5,7 @@
|
|
5
5
|
= simple_form_for(@resource, url: resource_path(@resource)) do |f|
|
6
6
|
= render partial: 'form_errors', locals: { resource: f.object }
|
7
7
|
= render 'form', form: f
|
8
|
-
=
|
9
|
-
= f.button :submit_and_continue_with_edit, class: 'btn btn-success'
|
10
|
-
= f.button :submit_and_continue_with_new, class: 'btn btn-success'
|
8
|
+
= render 'form_buttons', form: f
|
11
9
|
|
12
10
|
.well.well-sm
|
13
11
|
= link_to resource_path(@resource), class: 'btn btn-primary btn-responsive' do
|
@@ -5,9 +5,7 @@
|
|
5
5
|
= simple_form_for(@resource, url: collection_path) do |f|
|
6
6
|
= render partial: 'form_errors', locals: { resource: f.object }
|
7
7
|
= render 'form', form: f
|
8
|
-
=
|
9
|
-
= f.button :submit_and_continue_with_edit, class: 'btn btn-success'
|
10
|
-
= f.button :submit_and_continue_with_new, class: 'btn btn-success'
|
8
|
+
= render 'form_buttons', form: f
|
11
9
|
%div.panel-footer
|
12
10
|
|
13
11
|
.well.well-sm
|
@@ -17,12 +17,18 @@ Itsf::Backend.configure do |config|
|
|
17
17
|
#
|
18
18
|
config.home_base_controller = 'BackendController'
|
19
19
|
|
20
|
-
# Set the base controller for
|
20
|
+
# Set the base controller for resource controllers
|
21
21
|
#
|
22
22
|
# Default: config.resource_base_controller = 'BackendController'
|
23
23
|
#
|
24
24
|
config.resource_base_controller = 'BackendController'
|
25
25
|
|
26
|
+
# Set the base controller for service controllers
|
27
|
+
#
|
28
|
+
# Default: config.service_base_controller = 'BackendController'
|
29
|
+
#
|
30
|
+
config.service_base_controller = 'BackendController'
|
31
|
+
|
26
32
|
# Register backend engines here. They will be added to the backend menu
|
27
33
|
#
|
28
34
|
# Example: config.backend_engines = %w( MyEngine::Engine ).map(&:constantize)
|
data/lib/itsf/backend/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itsf_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -498,6 +498,7 @@ files:
|
|
498
498
|
- app/controllers/concerns/controller/acts_as_list_concern.rb
|
499
499
|
- app/controllers/concerns/controller/acts_as_published_concern.rb
|
500
500
|
- app/controllers/concerns/controller/pagination_concern.rb
|
501
|
+
- app/controllers/concerns/controller/pundit_authorization_failure_handling_concern.rb
|
501
502
|
- app/controllers/concerns/controller/pundit_namespaced_authorize_concern.rb
|
502
503
|
- app/controllers/concerns/controller/ransack_concern.rb
|
503
504
|
- app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb
|
@@ -539,6 +540,7 @@ files:
|
|
539
540
|
- app/views/itsf/backend/home/index.html.haml
|
540
541
|
- app/views/itsf/backend/i18n/_navigation.html.haml
|
541
542
|
- app/views/itsf/backend/resource/base/_form.html.haml
|
543
|
+
- app/views/itsf/backend/resource/base/_form_buttons.haml
|
542
544
|
- app/views/itsf/backend/resource/base/_form_errors.html.haml
|
543
545
|
- app/views/itsf/backend/resource/base/_head_extras.html.haml
|
544
546
|
- app/views/itsf/backend/resource/base/_index_extras.html.haml
|