cybele 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +16 -2
- data/dump.rdb +1 -0
- data/lib/cybele/app_builder.rb +213 -220
- data/lib/cybele/generators/app_generator.rb +31 -20
- data/lib/cybele/version.rb +2 -2
- data/templates/.env.local.erb +11 -0
- data/templates/.env.production.erb +11 -0
- data/templates/.env.staging.erb +11 -0
- data/templates/README.md.erb +22 -0
- data/templates/app/assets/javascripts/application.js.coffee +63 -1
- data/templates/app/assets/javascripts/hq/application.js.coffee +93 -0
- data/templates/app/assets/stylesheets/application.css.sass +15 -4
- data/templates/app/assets/stylesheets/hq/application.css.sass +92 -0
- data/templates/app/controllers/application_controller.rb.erb +48 -0
- data/templates/app/controllers/concerns/basic_authentication.rb +18 -0
- data/templates/app/controllers/hq/admins_controller.rb +64 -0
- data/templates/app/controllers/hq/application_controller.rb +11 -0
- data/templates/app/controllers/hq/audits_controller.rb +16 -0
- data/templates/app/controllers/hq/cities_controller.rb +54 -0
- data/templates/app/controllers/hq/countries_controller.rb +54 -0
- data/templates/app/controllers/hq/dashboard_controller.rb +4 -1
- data/templates/app/controllers/hq/passwords_controller.rb +10 -0
- data/templates/app/controllers/hq/registrations_controller.rb +21 -0
- data/templates/app/controllers/hq/sessions_controller.rb +1 -1
- data/templates/app/controllers/hq/users_controller.rb +64 -0
- data/templates/app/controllers/user/dashboard_controller.rb +8 -0
- data/templates/app/controllers/user/passwords_controller.rb +10 -0
- data/templates/app/controllers/user/profiles_controller.rb +34 -0
- data/templates/app/controllers/user/registrations_controller.rb +20 -0
- data/templates/app/controllers/user/sessions_controller.rb +16 -0
- data/templates/app/controllers/user/user_application_controller.rb +20 -0
- data/templates/app/helpers/application_helper.rb.erb +27 -0
- data/templates/app/mailers/admin_mailer.rb +10 -0
- data/templates/app/mailers/base_mailer.rb +4 -0
- data/templates/app/mailers/user_mailer.rb +10 -0
- data/templates/app/models/admin.rb +51 -0
- data/templates/app/models/audit.rb +3 -0
- data/templates/app/models/city.rb +12 -0
- data/templates/app/models/country.rb +12 -0
- data/templates/app/models/user.rb +54 -0
- data/templates/app/views/admin_mailer/login_info.html.haml +13 -0
- data/templates/app/views/devise/confirmations/new.html.haml +6 -5
- data/templates/app/views/devise/mailer/confirmation_instructions.html.haml +5 -3
- data/templates/app/views/devise/mailer/reset_password_instructions.html.haml +2 -2
- data/templates/app/views/devise/passwords/edit.html.haml +3 -3
- data/templates/app/views/devise/passwords/new.html.haml +3 -3
- data/templates/app/views/devise/registrations/edit.html.haml +5 -11
- data/templates/app/views/devise/registrations/new.html.haml +18 -6
- data/templates/app/views/devise/sessions/new.html.haml +1 -1
- data/templates/app/views/devise/shared/_links.haml +3 -1
- data/templates/app/views/devise/unlocks/new.html.haml +4 -4
- data/templates/app/views/hq/admins/_admin.html.haml +21 -0
- data/templates/app/views/hq/admins/_blank.html.haml +9 -0
- data/templates/app/views/hq/admins/_filters.html.haml +20 -0
- data/templates/app/views/hq/admins/_form.html.haml +17 -0
- data/templates/app/views/hq/admins/_list.html.haml +15 -0
- data/templates/app/views/hq/admins/edit.html.haml +3 -0
- data/templates/app/views/hq/admins/index.html.haml +18 -0
- data/templates/app/views/hq/admins/new.html.haml +5 -0
- data/templates/app/views/hq/admins/show.html.haml +19 -0
- data/templates/app/views/hq/audits/_filters.html.haml +32 -0
- data/templates/app/views/hq/audits/_list.html.haml +37 -0
- data/templates/app/views/hq/audits/index.html.haml +5 -0
- data/templates/app/views/hq/audits/show.html.haml +5 -0
- data/templates/app/views/hq/cities/_blank.html.haml +9 -0
- data/templates/app/views/hq/cities/_city.html.haml +12 -0
- data/templates/app/views/hq/cities/_filters.html.haml +15 -0
- data/templates/app/views/hq/cities/_form.html.haml +15 -0
- data/templates/app/views/hq/cities/_list.html.haml +13 -0
- data/templates/app/views/hq/cities/edit.html.haml +3 -0
- data/templates/app/views/hq/cities/index.html.haml +18 -0
- data/templates/app/views/hq/cities/new.html.haml +3 -0
- data/templates/app/views/hq/cities/show.html.haml +13 -0
- data/templates/app/views/hq/countries/_blank.html.haml +9 -0
- data/templates/app/views/hq/countries/_country.html.haml +11 -0
- data/templates/app/views/hq/countries/_filters.html.haml +14 -0
- data/templates/app/views/hq/countries/_form.html.haml +14 -0
- data/templates/app/views/hq/countries/_list.html.haml +12 -0
- data/templates/app/views/hq/countries/edit.html.haml +3 -0
- data/templates/app/views/hq/countries/index.html.haml +18 -0
- data/templates/app/views/hq/countries/new.html.haml +3 -0
- data/templates/app/views/hq/countries/show.html.haml +14 -0
- data/templates/app/views/hq/dashboard/index.html.haml +8 -0
- data/templates/app/views/hq/passwords/edit.html.haml +12 -0
- data/templates/app/views/hq/passwords/new.html.haml +9 -0
- data/templates/app/views/hq/registrations/edit.html.haml +19 -0
- data/templates/app/views/hq/sessions/new.html.haml +7 -5
- data/templates/app/views/hq/users/_blank.html.haml +9 -0
- data/templates/app/views/hq/users/_filters.html.haml +20 -0
- data/templates/app/views/hq/users/_form.html.haml +18 -0
- data/templates/app/views/hq/users/_list.html.haml +15 -0
- data/templates/app/views/hq/users/_user.html.haml +20 -0
- data/templates/app/views/hq/users/edit.html.haml +3 -0
- data/templates/app/views/hq/users/index.html.haml +18 -0
- data/templates/app/views/hq/users/new.html.haml +5 -0
- data/templates/app/views/hq/users/show.html.haml +20 -0
- data/templates/app/views/layouts/application.html.haml.erb +16 -8
- data/templates/app/views/layouts/hq/application.html.haml.erb +55 -0
- data/templates/app/views/layouts/hq/login.html.haml.erb +35 -0
- data/templates/app/views/layouts/hq/partials/_dock.html.haml.erb +36 -0
- data/templates/app/views/layouts/hq/partials/_footer.html.haml.erb +0 -0
- data/templates/app/views/layouts/hq/partials/_navbar.html.haml.erb +22 -0
- data/templates/app/views/layouts/hq/partials/_trackers.html.haml.erb +0 -0
- data/templates/app/views/layouts/mailer.html.haml.erb +321 -0
- data/templates/app/views/layouts/mailer.text.haml +1 -0
- data/templates/app/views/layouts/partials/_footer.html.haml.erb +0 -0
- data/templates/app/views/layouts/partials/_trackers.html.haml.erb +0 -0
- data/templates/app/views/layouts/partials/_warnings.html.haml.erb +3 -0
- data/templates/app/views/user/dashboard/index.html.haml +8 -0
- data/templates/app/views/user/passwords/edit.html.haml +12 -0
- data/templates/app/views/user/passwords/new.html.haml +10 -0
- data/templates/app/views/{user_profiles → user/profiles}/_form.html.haml +4 -5
- data/templates/app/views/user/profiles/edit.html.haml +3 -0
- data/templates/app/views/user/profiles/show.html.haml +15 -0
- data/templates/app/views/user/registrations/edit.html.haml +19 -0
- data/templates/app/views/user/sessions/new.html.haml +11 -0
- data/templates/app/views/user_mailer/login_info.html.haml +13 -0
- data/templates/app/views/welcome/index.html.haml.erb +4 -4
- data/templates/config/initializers/devise_async.rb +6 -0
- data/templates/config/initializers/sidekiq.rb +13 -0
- data/templates/config/locales/email.tr.yml +28 -0
- data/templates/config/locales/models.tr.yml +72 -41
- data/templates/config/locales/responders.tr.yml +4 -1
- data/templates/config/locales/show_for.tr.yml +1 -3
- data/templates/config/locales/simple_form.tr.yml +8 -22
- data/templates/config/locales/tr.yml +33 -2
- data/templates/config/locales/view.tr.yml +64 -18
- data/templates/config/routes.erb +51 -0
- data/templates/config/schedule.yml +16 -0
- data/templates/config/settings/production.yml +0 -17
- data/templates/config/settings/staging.yml +0 -17
- data/templates/config/sidekiq.yml +13 -0
- data/templates/cybele_Gemfile +42 -5
- data/templates/cybele_gitignore +3 -1
- data/templates/cybele_version.txt +1 -0
- data/templates/env.sample.erb +11 -0
- data/templates/lib/data/cities.yml +163 -0
- data/templates/lib/tasks/dev.rake +29 -5
- data/templates/lib/tasks/sidekiq.rake +26 -0
- data/templates/lib/templates/rails/responders_controller/controller.rb +27 -22
- data/templates/public/images/favicon.png +0 -0
- data/templates/public/images/mail-logo.png +0 -0
- data/templates/public/images/missing_cover.png +0 -0
- data/templates/public/images/missing_cover@2x.png +0 -0
- data/templates/public/images/missing_logo.png +0 -0
- data/templates/public/images/missing_logo@2x.png +0 -0
- data/templates/public/images/sprite.png +0 -0
- data/templates/ruby-version +1 -1
- data/templates/vendor/assets/javascripts/jquery.datetimepicker.js +1871 -0
- data/templates/vendor/assets/javascripts/jquery.maskedinput.min.js +7 -0
- data/templates/vendor/assets/javascripts/nprogress.js +491 -0
- data/templates/vendor/assets/javascripts/trix.js +25 -0
- data/templates/vendor/assets/stylesheets/jquery.datetimepicker.css +418 -0
- data/templates/vendor/assets/stylesheets/nprogress.css +74 -0
- data/templates/vendor/assets/stylesheets/trix.css +209 -0
- metadata +125 -24
- data/templates/app/controllers/application_controller.rb +0 -19
- data/templates/app/controllers/hq/admin_profiles_controller.rb +0 -56
- data/templates/app/controllers/user_profiles_controller.rb +0 -56
- data/templates/app/views/hq/admin_profiles/_form.html.haml +0 -15
- data/templates/app/views/hq/admin_profiles/edit.html.haml +0 -3
- data/templates/app/views/hq/admin_profiles/new.html.haml +0 -3
- data/templates/app/views/hq/admin_profiles/show.html.haml +0 -13
- data/templates/app/views/hq/dashboard/index.html.haml.erb +0 -3
- data/templates/app/views/user_profiles/edit.html.haml +0 -3
- data/templates/app/views/user_profiles/new.html.haml +0 -3
- data/templates/app/views/user_profiles/show.html.haml +0 -13
- data/templates/config/locales/en.yml +0 -2
- data/templates/config/locales/models.en.yml +0 -54
- data/templates/config/locales/responders.en.yml +0 -10
- data/templates/config/locales/show_for.en.yml +0 -7
- data/templates/config/locales/simple_form.en.yml +0 -30
- data/templates/config/locales/view.en.yml +0 -51
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'application_responder'
|
2
|
+
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
include BasicAuthentication
|
5
|
+
|
6
|
+
rescue_from Exception, with: :server_error if Rails.env.production? or Rails.env.staging?
|
7
|
+
rescue_from ActiveRecord::RecordNotFound, with: :page_not_found if Rails.env.production? or Rails.env.staging?
|
8
|
+
rescue_from ActionController::RoutingError, with: :page_not_found if Rails.env.production? or Rails.env.staging?
|
9
|
+
|
10
|
+
self.responder = ApplicationResponder
|
11
|
+
respond_to :html, :json
|
12
|
+
|
13
|
+
# Prevent CSRF attacks by raising an exception.
|
14
|
+
# For APIs, you may want to use :null_session instead.
|
15
|
+
before_filter :set_audit_user
|
16
|
+
protect_from_forgery with: :exception
|
17
|
+
|
18
|
+
def server_error(exception)
|
19
|
+
Rollbar.error "ApplicationController#server_error --exception: #{exception}"
|
20
|
+
render template: 'errors/internal_server_error', status: 500
|
21
|
+
end
|
22
|
+
|
23
|
+
def page_not_found
|
24
|
+
render template: 'errors/not_found', status: 404
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def set_user_time_zone
|
30
|
+
Time.zone = current_user.time_zone if student_signed_in? && current_student.time_zone.present?
|
31
|
+
end
|
32
|
+
|
33
|
+
def devise_parameter_sanitizer
|
34
|
+
if resource_class == User
|
35
|
+
User::ParameterSanitizer.new(User, :user, params)
|
36
|
+
else
|
37
|
+
super # Use the default one
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def set_audit_user
|
44
|
+
# Set audit current user
|
45
|
+
Audited.current_user_method = :current_user
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BasicAuthentication
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
before_filter :authenticate
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def authenticate
|
11
|
+
if Rails.env.staging? and ENV['BASIC_AUTH_IS_ACTIVE'] == 'yes'
|
12
|
+
authenticate_or_request_with_http_basic do |username, password|
|
13
|
+
username == Settings.basic_auth.username && password == Settings.basic_auth.password
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Hq::AdminsController < Hq::ApplicationController
|
2
|
+
|
3
|
+
before_action :set_admin, only: [:show, :edit, :update, :destroy, :toggle_is_active]
|
4
|
+
add_breadcrumb I18n.t('activerecord.models.admins'), :hq_admins_path
|
5
|
+
|
6
|
+
def index
|
7
|
+
@search = Admin.order(id: :desc).search(params[:q])
|
8
|
+
@admins = @search.result(distinct: true).paginate(page: params[:page])
|
9
|
+
respond_with(@admins)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
add_breadcrumb @admin.name, hq_admin_path(@admin)
|
14
|
+
respond_with(@admin)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
add_breadcrumb t('tooltips.new'), new_hq_admin_path
|
19
|
+
@admin = Admin.new
|
20
|
+
respond_with(@admin)
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
add_breadcrumb @admin.name, hq_admin_path(@admin)
|
25
|
+
add_breadcrumb t('tooltips.edit'), edit_hq_admin_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@admin = Admin.new(admin_params)
|
30
|
+
@admin.save
|
31
|
+
respond_with(:hq, @admin)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@admin.update(admin_params)
|
36
|
+
respond_with(:hq, @admin)
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@admin.destroy
|
41
|
+
respond_with(:hq, @admin, location: request.referer)
|
42
|
+
end
|
43
|
+
|
44
|
+
def toggle_is_active
|
45
|
+
if @admin.update( is_active: !@admin.is_active )
|
46
|
+
@admin.is_active ?
|
47
|
+
flash[:info] = t('flash.actions.toggle_is_active.active', resource_name: Admin.model_name.human) :
|
48
|
+
flash[:info] = t('flash.actions.toggle_is_active.passive', resource_name: Admin.model_name.human)
|
49
|
+
else
|
50
|
+
flash[:danger] = t('flash.messages.error_occurred')
|
51
|
+
end
|
52
|
+
respond_with(:hq, @admin, location: request.referer)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def set_admin
|
58
|
+
@admin = Admin.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def admin_params
|
62
|
+
params.require(:admin).permit(:email, :name, :surname)
|
63
|
+
end
|
64
|
+
end
|
@@ -1,7 +1,18 @@
|
|
1
1
|
require 'application_responder'
|
2
2
|
|
3
3
|
class Hq::ApplicationController < ActionController::Base
|
4
|
+
|
5
|
+
before_filter :set_audit_user
|
4
6
|
before_action :authenticate_admin!
|
7
|
+
|
5
8
|
self.responder = ApplicationResponder
|
6
9
|
respond_to :html, :json
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_audit_user
|
14
|
+
# Set audit current user
|
15
|
+
Audited.current_user_method = :current_admin
|
16
|
+
end
|
17
|
+
|
7
18
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Hq::AuditsController < Hq::ApplicationController
|
2
|
+
|
3
|
+
add_breadcrumb I18n.t('activerecord.models.audits'), :hq_audits_path
|
4
|
+
|
5
|
+
def index
|
6
|
+
@search = Audit.includes(:user).reorder('id DESC').search(params[:q])
|
7
|
+
@audits = @search.result(distinct: true).paginate(page: params[:page])
|
8
|
+
@auditable_types = Audited::Adapters::ActiveRecord::Audit.select('auditable_type').group('auditable_type').reorder('')
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@audit = Audit.find(params[:id])
|
13
|
+
add_breadcrumb @audit.id, hq_audit_path(id: @audit)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Hq::CitiesController < Hq::ApplicationController
|
2
|
+
|
3
|
+
before_action :set_city, only: [:show, :edit, :update, :destroy]
|
4
|
+
add_breadcrumb I18n.t('activerecord.models.cities'), :hq_cities_path
|
5
|
+
|
6
|
+
def index
|
7
|
+
@search = City.includes(:country).order(id: :desc).search(params[:q])
|
8
|
+
@cities = @search.result(distinct: true).paginate(page: params[:page])
|
9
|
+
respond_with(@cities)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
add_breadcrumb @city.name, hq_city_path(@city)
|
14
|
+
respond_with(@city)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
add_breadcrumb t('tooltips.new'), new_hq_city_path
|
19
|
+
@city = City.new
|
20
|
+
respond_with(@city)
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
add_breadcrumb @city.name, hq_city_path(@city)
|
25
|
+
add_breadcrumb t('tooltips.edit'), edit_hq_city_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@city = City.new(city_params)
|
30
|
+
@city.save
|
31
|
+
respond_with(:hq, @city)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@city.update(city_params)
|
36
|
+
respond_with(:hq, @city)
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@city.destroy
|
41
|
+
respond_with(:hq, @city, location: request.referer)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def city_params
|
47
|
+
params.require(:city).permit(:name, :country_id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_city
|
51
|
+
@city = City.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Hq::CountriesController < Hq::ApplicationController
|
2
|
+
|
3
|
+
before_action :set_country, only: [:show, :edit, :update, :destroy]
|
4
|
+
add_breadcrumb I18n.t('activerecord.models.countries'), :hq_countries_path
|
5
|
+
|
6
|
+
def index
|
7
|
+
@search = Country.order(id: :desc).search(params[:q])
|
8
|
+
@countries = @search.result(distinct: true).paginate(page: params[:page])
|
9
|
+
respond_with(@countries)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
add_breadcrumb @country.name, hq_country_path(@country)
|
14
|
+
respond_with(@country)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
add_breadcrumb t('tooltips.new'), new_hq_country_path
|
19
|
+
@country = Country.new
|
20
|
+
respond_with(@country)
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
add_breadcrumb @country.name, hq_country_path(@country)
|
25
|
+
add_breadcrumb t('tooltips.edit'), edit_hq_country_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@country = Country.new(country_params)
|
30
|
+
@country.save
|
31
|
+
respond_with(:hq, @country)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@country.update(country_params)
|
36
|
+
respond_with(:hq, @country)
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@country.destroy
|
41
|
+
respond_with(:hq, @country, location: request.referer)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def country_params
|
47
|
+
params.require(:country).permit(:name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_country
|
51
|
+
@country = Country.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Hq::RegistrationsController < Devise::RegistrationsController
|
2
|
+
layout 'hq/application'
|
3
|
+
before_action :authenticate_admin!
|
4
|
+
before_action :redirect_admin, only: [:new, :create, :destroy]
|
5
|
+
add_breadcrumb I18n.t('dock.dashboard'), :hq_dashboard_index_path
|
6
|
+
|
7
|
+
def edit
|
8
|
+
add_breadcrumb I18n.t('tt.edit', resource_name: Admin.model_name.human)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def redirect_admin
|
14
|
+
redirect_to hq_root_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def after_update_path_for(resource)
|
18
|
+
hq_root_path
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Hq::UsersController < Hq::ApplicationController
|
2
|
+
|
3
|
+
before_action :set_user, only: [:show, :edit, :update, :destroy, :toggle_is_active]
|
4
|
+
add_breadcrumb I18n.t('activerecord.models.users'), :hq_users_path
|
5
|
+
|
6
|
+
def index
|
7
|
+
@search = User.order(id: :desc).search(params[:q])
|
8
|
+
@users = @search.result(distinct: true).paginate(page: params[:page])
|
9
|
+
respond_with(@users)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
add_breadcrumb @user.name, hq_user_path(@user)
|
14
|
+
respond_with(@user)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
add_breadcrumb t('tooltips.new'), new_hq_user_path
|
19
|
+
@user = User.new
|
20
|
+
respond_with(@user)
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
add_breadcrumb @user.name, hq_user_path(@user)
|
25
|
+
add_breadcrumb t('tooltips.edit'), edit_hq_user_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@user = User.new(user_params)
|
30
|
+
@user.save
|
31
|
+
respond_with(:hq, @user)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@user.update(user_params)
|
36
|
+
respond_with(:hq, @user)
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@user.destroy
|
41
|
+
respond_with(:hq, @user, location: request.referer)
|
42
|
+
end
|
43
|
+
|
44
|
+
def toggle_is_active
|
45
|
+
if @user.update( is_active: !@user.is_active )
|
46
|
+
@user.is_active ?
|
47
|
+
flash[:info] = t('flash.actions.toggle_is_active.active', resource_name: User.model_name.human) :
|
48
|
+
flash[:info] = t('flash.actions.toggle_is_active.passive', resource_name: User.model_name.human)
|
49
|
+
else
|
50
|
+
flash[:danger] = t('flash.messages.error_occurred')
|
51
|
+
end
|
52
|
+
respond_with(:hq, @user, location: request.referer)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def set_user
|
58
|
+
@user = User.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def user_params
|
62
|
+
params.require(:user).permit(:email, :name, :surname, :time_zone)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class User::ProfilesController < User::UserApplicationController
|
2
|
+
|
3
|
+
before_action :set_profile, only: [:show, :edit, :update]
|
4
|
+
add_breadcrumb I18n.t('dock.profile'), :user_profile_path
|
5
|
+
|
6
|
+
def show
|
7
|
+
add_breadcrumb @profile.full_name, user_profile_path
|
8
|
+
respond_with([:user, @profile])
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit
|
12
|
+
add_breadcrumb t('tooltips.edit'), edit_user_profile_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
@profile.update(profile_params)
|
17
|
+
respond_with([:user, @profile], location: user_profile_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def set_profile
|
23
|
+
@profile = current_user
|
24
|
+
end
|
25
|
+
|
26
|
+
def profile_params
|
27
|
+
params.require(:user)
|
28
|
+
.permit(
|
29
|
+
:name,
|
30
|
+
:surname,
|
31
|
+
:time_zone
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|