keppler 2.0.2 → 2.0.3
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 +5 -5
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -22
- data/Rakefile +6 -0
- data/bin/keppler +6 -2
- data/bin/setup +2 -1
- data/exe/keppler +6 -0
- data/installer/core/.gitignore +87 -0
- data/installer/core/.ruby-version +1 -0
- data/installer/core/Gemfile +6 -4
- data/installer/core/README.md +86 -50
- data/installer/core/app/assets/images/.keep +0 -0
- data/installer/core/app/assets/images/admin/astronauta_keppler.svg +123 -0
- data/installer/core/app/assets/images/admin/avatar_keppler.svg +100 -0
- data/installer/core/app/assets/images/admin/image_default.png +0 -0
- data/installer/core/app/assets/images/app/fondo.svg +19 -0
- data/installer/core/app/assets/javascripts/admin/file_upload.coffee +11 -0
- data/installer/core/app/assets/javascripts/admin/main.coffee +23 -12
- data/installer/core/app/assets/javascripts/admin/preview_template.js +2 -2
- data/installer/core/app/assets/javascripts/admin/sidebar.js +8 -7
- data/installer/core/app/assets/javascripts/admin/swal.js +37 -0
- data/installer/core/app/assets/javascripts/admin/switch.js +6 -0
- data/installer/core/app/assets/javascripts/admin/tooltips.coffee +3 -0
- data/installer/core/app/assets/javascripts/errors/application.js.coffee +1 -0
- data/installer/core/app/assets/javascripts/errors/errors.js +113 -0
- data/installer/core/app/assets/javascripts/keppler_ga_dashboard/view-selector2.js +1 -1
- data/installer/core/app/assets/javascripts/vue_admin/index.js +34 -9
- data/installer/core/app/assets/stylesheets/admin/application.scss +4 -14
- data/installer/core/app/assets/stylesheets/admin/components/navigation/_navbar.scss +4 -5
- data/installer/core/app/assets/stylesheets/admin/components/navigation/_sidebar.scss +26 -17
- data/installer/core/app/assets/stylesheets/admin/pages/_appearance.scss +5 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_customize.scss +21 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_datepicker.scss +1088 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_files.scss +26 -9
- data/installer/core/app/assets/stylesheets/admin/pages/_form.scss +19 -6
- data/installer/core/app/assets/stylesheets/admin/pages/_index.scss +4 -8
- data/installer/core/app/assets/stylesheets/admin/pages/_listing.scss +5 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_navbar.scss +9 -2
- data/installer/core/app/assets/stylesheets/admin/pages/_roles.scss +6 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_search.scss +24 -28
- data/installer/core/app/assets/stylesheets/admin/pages/_sidebar.scss +1 -1
- data/installer/core/app/assets/stylesheets/admin/pages/_switchs.scss +135 -39
- data/installer/core/app/assets/stylesheets/admin/pages/_timepicker.scss +16 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_user.scss +6 -0
- data/installer/core/app/assets/stylesheets/admin/utils/_base.scss +6 -1
- data/installer/core/app/assets/stylesheets/admin/utils/_theme.scss +24 -11
- data/installer/core/app/assets/stylesheets/admin/utils/_variables.scss +1 -1
- data/installer/core/app/assets/stylesheets/app/pages/_front.sass +70 -56
- data/installer/core/app/assets/stylesheets/errors/errors.scss +161 -120
- data/installer/core/app/assets/stylesheets/vendor/admin-lte/_skin-blue.scss +1 -1
- data/installer/core/app/controllers/admin/admin_controller.rb +1 -1
- data/installer/core/app/controllers/admin/customizes_controller.rb +6 -8
- data/installer/core/app/controllers/admin/meta_tags_controller.rb +14 -18
- data/installer/core/app/controllers/admin/roles_controller.rb +176 -0
- data/installer/core/app/controllers/admin/scripts_controller.rb +14 -33
- data/installer/core/app/controllers/admin/settings_controller.rb +26 -27
- data/installer/core/app/controllers/admin/users_controller.rb +35 -29
- data/installer/core/app/controllers/app/app_controller.rb +27 -4
- data/installer/core/app/controllers/application_controller.rb +39 -1
- data/installer/core/app/controllers/concerns/.keep +0 -0
- data/installer/core/app/helpers/admin_helper.rb +5 -0
- data/installer/core/app/helpers/application_helper.rb +9 -0
- data/installer/core/app/helpers/roles_helper.rb +2 -0
- data/installer/core/app/inputs/file_material_input.rb +4 -2
- data/installer/core/app/inputs/keppler_boolean_input.rb +74 -0
- data/installer/core/app/inputs/keppler_file_input.rb +70 -0
- data/installer/core/app/mailers/.keep +0 -0
- data/installer/core/app/mailers/application_mailer.rb +13 -13
- data/installer/core/app/models/.keep +0 -0
- data/installer/core/app/models/appearance.rb +2 -0
- data/installer/core/app/models/application_record.rb +3 -0
- data/installer/core/app/models/concerns/.keep +0 -0
- data/installer/core/app/models/concerns/downloadable.rb +13 -0
- data/installer/core/app/models/concerns/sortable.rb +9 -0
- data/installer/core/app/models/concerns/uploadable.rb +10 -0
- data/installer/core/app/models/customize.rb +8 -6
- data/installer/core/app/models/front.rb +3 -0
- data/installer/core/app/models/google_analytics_setting.rb +2 -0
- data/installer/core/app/models/meta_tag.rb +27 -14
- data/installer/core/app/models/permission.rb +3 -0
- data/installer/core/app/models/role.rb +62 -5
- data/installer/core/app/models/script.rb +6 -15
- data/installer/core/app/models/setting.rb +2 -0
- data/installer/core/app/models/smtp_setting.rb +2 -0
- data/installer/core/app/models/social_account.rb +2 -0
- data/installer/core/app/models/user.rb +17 -1
- data/installer/core/app/policies/application_policy.rb +4 -4
- data/installer/core/app/policies/controller_policy.rb +15 -11
- data/installer/core/app/policies/role_policy.rb +25 -0
- data/installer/core/app/policies/user_policy.rb +1 -1
- data/installer/core/app/uploaders/attachment_uploader.rb +18 -1
- data/installer/core/app/views/admin/customizes/_description.html.haml +4 -4
- data/installer/core/app/views/admin/customizes/_form.html.haml +4 -4
- data/installer/core/app/views/admin/customizes/_listing.html.haml +1 -1
- data/installer/core/app/views/admin/customizes/_switch_default_template.html.haml +8 -13
- data/installer/core/app/views/admin/customizes/_switch_template.html.haml +8 -11
- data/installer/core/app/views/admin/customizes/index.html.haml +9 -9
- data/installer/core/app/views/admin/layouts/_head.html.haml +3 -3
- data/installer/core/app/views/admin/layouts/_keppler_boolean_script.haml +12 -0
- data/installer/core/app/views/admin/layouts/_navigation.html.haml +17 -16
- data/installer/core/app/views/admin/layouts/_sidebar.html.haml +27 -36
- data/installer/core/app/views/admin/layouts/application.html.haml +1 -0
- data/installer/core/app/views/admin/layouts/index/remote_messages.js.haml +6 -6
- data/installer/core/app/views/admin/meta_tags/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/meta_tags/_listing.html.haml +6 -6
- data/installer/core/app/views/admin/meta_tags/index.html.haml +15 -29
- data/installer/core/app/views/admin/meta_tags/show.html.haml +7 -8
- data/installer/core/app/views/admin/roles/_description.html.haml +13 -0
- data/installer/core/app/views/admin/roles/_form.html.haml +27 -0
- data/installer/core/app/views/admin/roles/_index_show.html.haml +24 -0
- data/installer/core/app/views/admin/roles/_listing.html.haml +46 -0
- data/installer/core/app/views/admin/roles/_switch.html.haml +20 -0
- data/installer/core/app/views/admin/roles/add_permissions.html.haml +60 -0
- data/installer/core/app/views/admin/roles/create_permissions.html.haml +0 -0
- data/installer/core/app/views/admin/roles/create_permissions.js.erb +1 -0
- data/installer/core/app/views/admin/roles/edit.html.haml +1 -0
- data/installer/core/app/views/admin/roles/index.html.haml +80 -0
- data/installer/core/app/views/admin/roles/new.html.haml +1 -0
- data/installer/core/app/views/admin/roles/reload.js.haml +5 -0
- data/installer/core/app/views/admin/roles/show.html.haml +32 -0
- data/installer/core/app/views/admin/roles/show.js.haml +4 -0
- data/installer/core/app/views/admin/roles/show_description.js.erb +2 -0
- data/installer/core/app/views/admin/scripts/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/scripts/_listing.html.haml +13 -13
- data/installer/core/app/views/admin/scripts/index.html.haml +12 -26
- data/installer/core/app/views/admin/scripts/show.html.haml +4 -4
- data/installer/core/app/views/admin/settings/components/_preview.html.haml +1 -1
- data/installer/core/app/views/admin/settings/fields/_appearance.html.haml +25 -17
- data/installer/core/app/views/admin/settings/fields/_basic_information.html.haml +13 -7
- data/installer/core/app/views/admin/settings/fields/_email_setting.html.haml +16 -16
- data/installer/core/app/views/admin/settings/fields/_google_analytics_setting.html.haml +1 -1
- data/installer/core/app/views/admin/settings/fields/_social_accounts.html.haml +39 -39
- data/installer/core/app/views/admin/users/_form.html.haml +18 -25
- data/installer/core/app/views/admin/users/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/users/_listing.html.haml +6 -6
- data/installer/core/app/views/admin/users/delete_avatar.js.haml +3 -0
- data/installer/core/app/views/admin/users/filter_by_role.js.erb +9 -0
- data/installer/core/app/views/admin/users/index.html.haml +22 -22
- data/installer/core/app/views/admin/users/show.html.haml +10 -12
- data/installer/core/app/views/app/front/index.html.haml +137 -87
- data/installer/core/app/views/app/layouts/_footer.html.haml +2 -2
- data/installer/core/app/views/app/layouts/_head.html.haml +4 -12
- data/installer/core/app/views/app/layouts/_meta_tags.html.haml +38 -6
- data/installer/core/app/views/app/layouts/application.html.haml +8 -8
- data/installer/core/app/views/devise/sessions/new.html.haml +32 -28
- data/installer/core/app/views/errors/internal_server_error.html.haml +50 -7
- data/installer/core/app/views/errors/not_authorized.html.haml +75 -6
- data/installer/core/app/views/errors/not_found.html.haml +101 -7
- data/installer/core/app/views/errors/unprocessable.html.haml +50 -7
- data/installer/core/bin/update +31 -0
- data/installer/core/bin/yarn +11 -0
- data/installer/core/config/application.rb +1 -1
- data/installer/core/config/environments/production.rb +1 -1
- data/installer/core/config/initializers/carrierwave.rb +12 -0
- data/installer/core/config/initializers/mime_types.rb +2 -2
- data/installer/core/config/initializers/simple_form_bootstrap.rb +20 -1
- data/installer/core/config/initializers/simple_form_components.rb +61 -0
- data/installer/core/config/locales/en.yml +29 -6
- data/installer/core/config/locales/es.yml +32 -5
- data/installer/core/config/locales/simple_form.en.yml +1 -0
- data/installer/core/config/locales/simple_form.es.yml +3 -2
- data/installer/core/config/menu.yml +34 -8
- data/installer/core/config/permissions.yml +21 -0
- data/installer/core/config/routes.rb +56 -14
- data/installer/core/db/migrate/20140812210925_rolify_create_roles.rb +2 -0
- data/installer/core/db/migrate/20160128131802_create_scripts.rb +1 -0
- data/installer/core/db/migrate/20180503174351_create_permissions.rb +11 -0
- data/installer/core/db/seeds.rb +12 -6
- data/installer/core/lib/generators/keppler_front/templates/views/template.html.haml +222 -177
- data/installer/core/lib/generators/keppler_relation/keppler_relation_generator.rb +1 -1
- data/installer/core/lib/generators/keppler_scaffold/keppler_scaffold_generator.rb +57 -40
- data/installer/core/lib/generators/keppler_scaffold/templates/controllers/controller.rb +29 -30
- data/installer/core/lib/generators/keppler_scaffold/templates/models/model.rb +14 -20
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_form.html.haml +24 -35
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_index_show.html.haml +12 -11
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_listing.html.haml +7 -7
- data/installer/core/lib/generators/keppler_scaffold/templates/views/index.html.haml +17 -33
- data/installer/core/lib/generators/keppler_scaffold/templates/views/show.html.haml +23 -24
- data/installer/core/plugins/keppler_ga_dashboard/app/assets/images/keppler_ga_dashboard/.keep +0 -0
- data/installer/core/plugins/keppler_ga_dashboard/config/permissions.yml +4 -0
- data/installer/core/plugins/keppler_ga_dashboard/keppler_ga_dashboard.gemspec +1 -1
- data/installer/core/test/controllers/.keep +0 -0
- data/installer/core/test/controllers/roles_controller_test.rb +48 -0
- data/installer/core/test/fixtures/.keep +0 -0
- data/installer/core/test/fixtures/permissions.yml +9 -0
- data/installer/core/test/helpers/.keep +0 -0
- data/installer/core/test/integration/.keep +0 -0
- data/installer/core/test/mailers/.keep +0 -0
- data/installer/core/test/models/.keep +0 -0
- data/installer/core/test/models/permission_test.rb +7 -0
- data/installer/core/test/system/roles_test.rb +43 -0
- data/installer/core/vendor/assets/javascripts/.keep +0 -0
- data/installer/core/vendor/assets/stylesheets/.keep +0 -0
- data/installer/plugins/concerns/commons.rb +47 -0
- data/installer/plugins/concerns/destroy_multiple.rb +33 -0
- data/installer/plugins/concerns/history.rb +24 -0
- data/installer/plugins/config/locales/en.yml +104 -0
- data/installer/plugins/config/locales/es.yml +139 -0
- data/installer/plugins/config/menu.yml +12 -0
- data/installer/plugins/config/permissions.yml +1 -0
- data/installer/plugins/generators/keppler_scaffold/keppler_scaffold_generator.rb +203 -0
- data/installer/plugins/generators/keppler_scaffold/templates/controllers/controller.rb +171 -0
- data/installer/plugins/generators/keppler_scaffold/templates/models/model.rb +41 -0
- data/installer/plugins/generators/keppler_scaffold/templates/policies/policy.rb +11 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_description.html.haml +13 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_form.html.haml +49 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_index_show.html.haml +26 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_listing.html.haml +65 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/edit.html.haml +1 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/index.html.haml +97 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/new.html.haml +1 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/reload.js.haml +5 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/show.html.haml +66 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/show.js.haml +4 -0
- data/installer/plugins/install.rb +156 -0
- data/installer/plugins/layouts/_navigation.html.haml +47 -0
- data/installer/plugins/layouts/application.html.haml +24 -0
- data/keppler.gemspec +35 -0
- data/lib/keppler.rb +0 -1
- data/lib/keppler/add.rb +13 -0
- data/lib/keppler/cli.rb +134 -5
- data/lib/keppler/delete.rb +13 -0
- data/lib/keppler/version.rb +1 -1
- metadata +117 -23
- data/installer/core/app/assets/images/admin/space.png +0 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_header.scss +0 -34
- data/installer/core/app/assets/stylesheets/admin/pages/_pageslide.scss +0 -125
- data/installer/core/db/schema.rb +0 -172
- data/installer/lib/conf.rb +0 -31
- data/installer/lib/scaffold.rb +0 -10
- data/installer/run.sh +0 -17
- data/installer/scripts/bin.sh +0 -61
- data/lib/keppler/cli/generate.rb +0 -19
@@ -1,8 +1,8 @@
|
|
1
1
|
module Admin
|
2
2
|
# SettingsController
|
3
3
|
class SettingsController < AdminController
|
4
|
-
before_action :set_setting, only: [
|
5
|
-
before_action :authorization,
|
4
|
+
before_action :set_setting, only: %i[edit update appearance_default]
|
5
|
+
before_action :authorization, except: %i[reload appearance_default]
|
6
6
|
|
7
7
|
def edit
|
8
8
|
@social_medias = social_account_permit_attributes
|
@@ -11,9 +11,7 @@ module Admin
|
|
11
11
|
|
12
12
|
def update
|
13
13
|
if @setting.update(setting_params)
|
14
|
-
if
|
15
|
-
get_apparience_colors([params[:color], params[:darken], params[:accent]])
|
16
|
-
end
|
14
|
+
get_apparience_colors([params[:color], params[:darken], params[:accent]]) if theme?
|
17
15
|
redirect_to(
|
18
16
|
admin_settings_path(@render), notice: actions_messages(@setting)
|
19
17
|
)
|
@@ -24,8 +22,9 @@ module Admin
|
|
24
22
|
|
25
23
|
def appearance_default
|
26
24
|
appearance = Appearance.last
|
27
|
-
appearance.
|
28
|
-
|
25
|
+
appearance.remove_image_background!
|
26
|
+
appearance.save
|
27
|
+
get_apparience_colors(['#f44336'])
|
29
28
|
redirect_to(
|
30
29
|
admin_settings_path(@render), notice: actions_messages(@setting)
|
31
30
|
)
|
@@ -33,9 +32,9 @@ module Admin
|
|
33
32
|
|
34
33
|
private
|
35
34
|
|
36
|
-
def
|
35
|
+
def theme?
|
37
36
|
colors = [params[:color]]
|
38
|
-
!colors.include?('')
|
37
|
+
!colors.include?('') && !colors.include?(nil)
|
39
38
|
end
|
40
39
|
|
41
40
|
def get_apparience_colors(values)
|
@@ -45,7 +44,7 @@ module Admin
|
|
45
44
|
variables_file.map { |line| indx = variables_file.find_index(line) if line.include?("$keppler-#{attribute}") }
|
46
45
|
variables_file[indx] = "$keppler-#{attribute}:#{values[i]};\n"
|
47
46
|
end
|
48
|
-
variables_file = variables_file.join(
|
47
|
+
variables_file = variables_file.join('')
|
49
48
|
File.write(style_file, variables_file)
|
50
49
|
end
|
51
50
|
|
@@ -56,9 +55,9 @@ module Admin
|
|
56
55
|
end
|
57
56
|
|
58
57
|
def authorization
|
59
|
-
authorize
|
58
|
+
authorize Setting
|
60
59
|
end
|
61
|
-
|
60
|
+
|
62
61
|
def style_file
|
63
62
|
"#{Rails.root}/app/assets/stylesheets/admin/utils/_variables.scss"
|
64
63
|
end
|
@@ -76,35 +75,35 @@ module Admin
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def smpt_setting_permit_attributes
|
79
|
-
[
|
78
|
+
%i[id address port domain_name email password]
|
80
79
|
end
|
81
80
|
|
82
81
|
def ga_setting_permit_attributes
|
83
|
-
[
|
82
|
+
%i[ga_account_id ga_tracking_id ga_status]
|
84
83
|
end
|
85
84
|
|
86
85
|
def social_account_permit_attributes
|
87
|
-
[
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
86
|
+
%i[
|
87
|
+
facebook twitter instagram google_plus
|
88
|
+
tripadvisor pinterest flickr behance
|
89
|
+
dribbble tumblr github linkedin
|
90
|
+
soundcloud youtube skype vimeo
|
92
91
|
]
|
93
92
|
end
|
94
93
|
|
95
94
|
def social_account_colors
|
96
|
-
[
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
%w[
|
96
|
+
#3b5998 #1da1f2 #e1306c #dd4b39
|
97
|
+
#00af87 #bd081c #ff0084 #1769ff
|
98
|
+
#ff8833 #35465c #333333 #0077b5
|
99
|
+
#ff8800 #ff0000 #00aff0 #162221
|
101
100
|
]
|
102
101
|
end
|
103
102
|
|
104
103
|
def apparence_permit_attributes
|
105
|
-
[
|
106
|
-
|
107
|
-
|
104
|
+
%i[
|
105
|
+
id theme_name image_background
|
106
|
+
image_background_cache remove_image_background
|
108
107
|
]
|
109
108
|
end
|
110
109
|
end
|
@@ -1,42 +1,41 @@
|
|
1
1
|
module Admin
|
2
2
|
# UsersController
|
3
3
|
class UsersController < AdminController
|
4
|
-
before_action :set_user, only: [
|
5
|
-
before_action :set_roles, only: [
|
6
|
-
before_action :show_history, only: [
|
4
|
+
before_action :set_user, only: %i[show edit update destroy]
|
5
|
+
before_action :set_roles, only: %i[index new edit create update]
|
6
|
+
before_action :show_history, only: %i[index]
|
7
|
+
before_action :authorization, except: %i[reload filter_by_role]
|
8
|
+
before_action :set_objects, only: %i[index filter_by_role reload]
|
7
9
|
|
8
10
|
def index
|
9
|
-
@
|
10
|
-
users = @q.result(distinct: true).where('id != ?', User.first.id).order(created_at: :desc)
|
11
|
-
@objects = users.page(@current_page)
|
12
|
-
@total = users.size
|
13
|
-
@users = User.all.reverse
|
11
|
+
@users = User.all.drop(1)
|
14
12
|
|
15
13
|
if !@objects.first_page? && @objects.size.zero?
|
16
14
|
redirect_to users_path(page: @current_page.to_i.pred, search: @query)
|
17
15
|
end
|
16
|
+
|
18
17
|
respond_to do |format|
|
19
18
|
format.html
|
20
19
|
format.json { render :json => @objects }
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def filter_by_role
|
24
|
+
if params[:role].eql?('all')
|
25
|
+
@users = User.all.drop(1)
|
26
|
+
else
|
27
|
+
@users = User.filter_by_role(@objects, params[:role])
|
29
28
|
end
|
30
|
-
|
31
|
-
authorize @user
|
32
29
|
end
|
33
30
|
|
34
|
-
def
|
31
|
+
def new
|
32
|
+
@user = User.new
|
33
|
+
respond_to_formats(@user)
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
38
|
-
|
39
|
-
end
|
36
|
+
def show; end
|
37
|
+
|
38
|
+
def edit; end
|
40
39
|
|
41
40
|
def update
|
42
41
|
update_attributes = user_params.delete_if do |_, value|
|
@@ -48,7 +47,6 @@ module Admin
|
|
48
47
|
else
|
49
48
|
render action: 'edit'
|
50
49
|
end
|
51
|
-
authorize @user
|
52
50
|
end
|
53
51
|
|
54
52
|
def create
|
@@ -64,29 +62,33 @@ module Admin
|
|
64
62
|
def destroy
|
65
63
|
@user.destroy
|
66
64
|
redirect_to admin_users_path, notice: actions_messages(@user)
|
67
|
-
authorize @user
|
68
65
|
end
|
69
66
|
|
70
67
|
def destroy_multiple
|
71
|
-
# byebug
|
72
68
|
User.destroy redefine_ids(params[:multiple_ids])
|
73
69
|
redirect_to(
|
74
70
|
admin_users_path(page: @current_page, search: @query),
|
75
71
|
notice: actions_messages(User.new)
|
76
72
|
)
|
77
|
-
authorize @user
|
78
73
|
end
|
79
74
|
|
80
|
-
def reload
|
81
|
-
@q = User.ransack(params[:q])
|
82
|
-
users = @q.result(distinct: true).where('id != ?', User.first.id).order(created_at: :desc)
|
83
|
-
@objects = users.page(@current_page)
|
84
|
-
end
|
75
|
+
def reload; end
|
85
76
|
|
86
77
|
private
|
87
78
|
|
88
79
|
def set_user
|
89
|
-
|
80
|
+
if params[:id].eql?('clients') || params[:id].eql?('admins')
|
81
|
+
redirect_to action: :index, role: params[:id]
|
82
|
+
else
|
83
|
+
@user = User.find(params[:id])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def set_objects
|
88
|
+
@q = User.ransack(params[:q])
|
89
|
+
users = @q.result(distinct: true).where('id != ?', User.first.id).order(created_at: :desc)
|
90
|
+
@objects = users.page(@current_page)
|
91
|
+
@total = users.size
|
90
92
|
end
|
91
93
|
|
92
94
|
def set_roles
|
@@ -94,6 +96,10 @@ module Admin
|
|
94
96
|
@roles = all_roles.drop(1)
|
95
97
|
end
|
96
98
|
|
99
|
+
def authorization
|
100
|
+
authorize User
|
101
|
+
end
|
102
|
+
|
97
103
|
def user_params
|
98
104
|
params.require(:user).permit(
|
99
105
|
:name, :email, :password, :password_confirmation,
|
@@ -2,22 +2,45 @@ module App
|
|
2
2
|
# AppController -> Controller out the back-office
|
3
3
|
class AppController < ::ApplicationController
|
4
4
|
layout 'app/layouts/application'
|
5
|
+
skip_before_action :verify_authenticity_token
|
6
|
+
before_action :set_locale
|
5
7
|
before_action :set_metas
|
6
8
|
before_action :set_analytics
|
7
9
|
|
8
10
|
def set_metas
|
11
|
+
@theme_color = nil
|
12
|
+
# Descomentar el modelo que exista depende del proyecto
|
13
|
+
# @post = KepplerBlog::Post.find(params[:id])
|
14
|
+
# @product = Product.find(params[:id])
|
9
15
|
@setting = Setting.first
|
10
|
-
@title = @setting.name
|
11
|
-
@description = @setting.description
|
12
|
-
@favicon = @setting.favicon
|
13
16
|
@meta = MetaTag.get_by_url(request.url)
|
14
17
|
@social = SocialAccount.last
|
18
|
+
@meta_title = MetaTag.title(@post, @product, @setting)
|
19
|
+
@meta_description = MetaTag.description(@post, @product, @setting)
|
20
|
+
@meta_image = MetaTag.image(request, @post, @product, @setting)
|
21
|
+
@meta_locale = @locale.eql?('es') ? 'es_VE' : 'en_US'
|
22
|
+
@meta_locale_alternate = @locale.eql?('es') ? 'en_US' : 'es_VE'
|
23
|
+
@country_code = @locale.eql?('es') ? 'VE' : 'US'
|
15
24
|
end
|
16
25
|
|
17
26
|
private
|
18
27
|
|
28
|
+
def set_locale
|
29
|
+
if params[:locale]
|
30
|
+
@locale = I18n.locale = params[:locale]
|
31
|
+
elsif request.env['HTTP_ACCEPT_LANGUAGE']
|
32
|
+
request_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/)[0]
|
33
|
+
@locale = I18n.locale = request_lang.eql?('es') ? 'es' : 'en'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_url_options(options = {})
|
38
|
+
logger.debug "default_url_options is passed options: #{options.inspect}\n"
|
39
|
+
{ locale: I18n.locale }
|
40
|
+
end
|
41
|
+
|
19
42
|
def set_analytics
|
20
|
-
@scripts = Script.
|
43
|
+
@scripts = Script.select { |x| x.url == request.env['PATH_INFO'] }
|
21
44
|
end
|
22
45
|
end
|
23
46
|
end
|
@@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base
|
|
7
7
|
before_action :appearance
|
8
8
|
before_action :set_apparience_colors
|
9
9
|
before_action :set_sidebar
|
10
|
+
before_action :set_modules
|
10
11
|
skip_around_action :set_locale_from_url
|
11
12
|
include Pundit
|
12
13
|
include PublicActivity::StoreController
|
@@ -19,8 +20,29 @@ class ApplicationController < ActionController::Base
|
|
19
20
|
|
20
21
|
private
|
21
22
|
|
23
|
+
def class_exists?(klass)
|
24
|
+
defined?(klass) && klass.is_a?(Class)
|
25
|
+
end
|
26
|
+
|
27
|
+
def redirect_to_index(_objects_path)
|
28
|
+
redirect_to objects_path(page: @current_page.to_i.pred, search: @query)
|
29
|
+
end
|
30
|
+
|
31
|
+
def nothing_in_first_page?(objects)
|
32
|
+
!objects.first_page? && objects.size.zero?
|
33
|
+
end
|
34
|
+
|
35
|
+
def respond_to_formats(objects)
|
36
|
+
respond_to do |format|
|
37
|
+
format.html
|
38
|
+
format.csv { send_data objects.to_csv }
|
39
|
+
format.xls { send_data objects.to_xls }
|
40
|
+
format.json { render json: objects }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
22
44
|
def user_not_authorized
|
23
|
-
flash[:alert] =
|
45
|
+
flash[:alert] = t('keppler.messages.not_authorized_action')
|
24
46
|
redirect_to(request.referrer || root_path)
|
25
47
|
end
|
26
48
|
# block access dashboard
|
@@ -46,6 +68,22 @@ class ApplicationController < ActionController::Base
|
|
46
68
|
end
|
47
69
|
end
|
48
70
|
|
71
|
+
def set_modules
|
72
|
+
@modules = YAML.load_file(
|
73
|
+
"#{Rails.root}/config/permissions.yml"
|
74
|
+
).values.each(&:symbolize_keys!)
|
75
|
+
modules = Dir[File.join("#{Rails.root}/plugins", '*')]
|
76
|
+
modules.each do |m|
|
77
|
+
module_name = YAML.load_file(
|
78
|
+
"#{m}/config/permissions.yml"
|
79
|
+
).values
|
80
|
+
if !module_name.first.nil?
|
81
|
+
module_name.each(&:symbolize_keys!)
|
82
|
+
@modules[0] = @modules[0].merge(module_name[0])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
49
87
|
def appearance
|
50
88
|
@appearance = Setting.first.appearance
|
51
89
|
end
|
File without changes
|
@@ -15,7 +15,16 @@ module ApplicationHelper
|
|
15
15
|
current_user
|
16
16
|
end
|
17
17
|
|
18
|
+
def can?(model)
|
19
|
+
Pundit.policy(current_user, model)
|
20
|
+
end
|
21
|
+
|
18
22
|
def landing?
|
19
23
|
controller_name.eql?('front') && action_name.eql?('index')
|
20
24
|
end
|
25
|
+
|
26
|
+
def can?(model)
|
27
|
+
Pundit.policy(current_user, model)
|
28
|
+
end
|
29
|
+
|
21
30
|
end
|
@@ -13,8 +13,10 @@ class FileMaterialInput < SimpleForm::Inputs::Base
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def file_input
|
16
|
-
template.content_tag(
|
17
|
-
|
16
|
+
template.content_tag(
|
17
|
+
:span,
|
18
|
+
t("activerecord.attributes.#{attribute_name}").humanize
|
19
|
+
) + @builder.file_field(attribute_name)
|
18
20
|
end
|
19
21
|
|
20
22
|
def file_path
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Creates a much prettier version of the file input field
|
4
|
+
class KepplerBooleanInput < SimpleForm::Inputs::Base
|
5
|
+
def input(_wrapper_options)
|
6
|
+
initializers
|
7
|
+
template.content_tag(:label, '', class: 'keppler-switch') do
|
8
|
+
template.tag(
|
9
|
+
:input,
|
10
|
+
class: ('active' if try_boolean),
|
11
|
+
name: @input_name,
|
12
|
+
type: 'checkbox',
|
13
|
+
checked: true,
|
14
|
+
value: try_boolean.to_s
|
15
|
+
) +
|
16
|
+
template.content_tag(:span, '', class: 'slider round') +
|
17
|
+
template.content_tag(
|
18
|
+
:label,
|
19
|
+
try_boolean.to_s,
|
20
|
+
class: "inline-label #{'active' if try_boolean}"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def label_switch
|
26
|
+
template.content_tag(:label, '', class: 'keppler-switch')
|
27
|
+
end
|
28
|
+
|
29
|
+
def input_switch
|
30
|
+
template.tag(
|
31
|
+
:input,
|
32
|
+
class: ('active' if try_boolean),
|
33
|
+
id: "switch-#{object}-#{attribute_name}",
|
34
|
+
type: 'checkbox',
|
35
|
+
checked: try_boolean.to_s
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def span_slider_round
|
40
|
+
template.content_tag(:span, '', class: 'slider round')
|
41
|
+
end
|
42
|
+
|
43
|
+
# def script
|
44
|
+
# template.content_tag(
|
45
|
+
# :script,
|
46
|
+
# `$('.keppler-switch').click(function(event) {
|
47
|
+
# event.preventDefault()
|
48
|
+
# var input = $(this).find('input')
|
49
|
+
# var label = $(this).find('.inline-label')
|
50
|
+
# input
|
51
|
+
# .toggleClass('active')
|
52
|
+
# .val(input.hasClass('active'))
|
53
|
+
# label
|
54
|
+
# .toggleClass('active')
|
55
|
+
# .text(label.hasClass('active'))
|
56
|
+
# })`
|
57
|
+
# )
|
58
|
+
# end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def try_boolean
|
63
|
+
object.try(attribute_name) ? true : false
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
def initializers
|
69
|
+
@model = lookup_model_names.join('_')
|
70
|
+
@attribute = reflection_or_attribute_name
|
71
|
+
@input_id = "#{@model}_#{@attribute}"
|
72
|
+
@input_name = "#{@model}[#{@attribute}]"
|
73
|
+
end
|
74
|
+
end
|