Class: CamaleonCms::Admin::UsersController
- Inherits:
-
CamaleonCms::AdminController
- Object
- CamaleonCms::AdminController
- CamaleonCms::Admin::UsersController
- Defined in:
- app/controllers/camaleon_cms/admin/users_controller.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #profile ⇒ Object
- #profile_edit ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
-
#updated_ajax ⇒ Object
update som ajax requests from profile or user form.
Instance Method Details
#create ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 73 def create user_data = params[:user] @user = current_site.users.new(user_data) if @user.save @user.(params[:meta]) if params[:meta].present? @user.set_field_values(params[:field_options]) r={user: @user}; hooks_run('user_created', r) flash[:notice] = t('camaleon_cms.admin.users.message.created') redirect_to action: :index else new end end |
#destroy ⇒ Object
87 88 89 90 91 92 93 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 87 def destroy if @user.destroy flash[:notice] = t('camaleon_cms.admin.users.message.deleted') r={user: @user}; hooks_run('user_destroyed', r) end redirect_to action: :index end |
#edit ⇒ Object
58 59 60 61 62 63 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 58 def edit I18n.t("camaleon_cms.admin.button.edit") r = {user: @user, render: 'form' } hooks_run('user_edit', r) render r[:render] end |
#index ⇒ Object
14 15 16 17 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 14 def index I18n.t("camaleon_cms.admin.users.list_users") @users = current_site.users.paginate(:page => params[:page], :per_page => current_site.admin_per_page) end |
#new ⇒ Object
65 66 67 68 69 70 71 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 65 def new @user ||= current_site.users.new I18n.t("camaleon_cms.admin.button.new") r = {user: @user, render: 'form' } hooks_run('user_new', r) render r[:render] end |
#profile ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 19 def profile I18n.t("camaleon_cms.admin.users.profile") @user = params[:user_id].present? ? current_site.the_user(params[:user_id].to_i).object : cama_current_user.object return edit end |
#profile_edit ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 25 def profile_edit I18n.t("camaleon_cms.admin.users.profile") @user = cama_current_user.object return edit end |
#show ⇒ Object
31 32 33 34 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 31 def show I18n.t("camaleon_cms.admin.users.profile") render 'profile' end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 36 def update if @user.update(params[:user]) @user.(params[:meta]) if params[:meta].present? @user.set_field_values(params[:field_options]) r = {user: @user, message: t('camaleon_cms.admin.users.message.updated'), params: params}; hooks_run('user_after_edited', r) flash[:notice] = r[:message] if cama_current_user.id == @user.id redirect_to action: :profile_edit else redirect_to action: :index end else render 'form' end end |
#updated_ajax ⇒ Object
update som ajax requests from profile or user form
53 54 55 56 |
# File 'app/controllers/camaleon_cms/admin/users_controller.rb', line 53 def updated_ajax @user = current_site.users.find(params[:user_id]) render inline: @user.update(params[:password]) ? "" : @user.errors..join(', ') end |