12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- class AdminPanelController < ApplicationController
-
- layout 'admin'
-
- def maintenance_mode
- end
-
- def index
- redirect_to admin_dashboard_path
- end
-
- def dashboard
- @users = User.all
- @posts = BlogPost.all
- @files = Upload.all
- end
- def posts
- @posts = BlogPost.all
- end
- def contact_messages
- @contact_messages = ContactMessage.order('created_at DESC').all
- end
- def users
- @users = User.order('created_at DESC').all
- end
-
- def files
- @uploads = Upload.all
- end
-
- def site_config
- @config = Info.first
- end
-
- def site_config_update
- @config = Info.first
- respond_to do |format|
- if @config.update(info_params)
- format.html { redirect_to admin_config_path, notice: (t 'admin_panel.config_update_success') }
- format.json { head :no_content }
- else
- format.html { render action: 'site_config' }
- format.json { render json: @upload.errors, status: :unprocessable_entity }
- end
- end
- end
-
- def make_admin
- @user = User.find(params[:id])
- if @user.admin == true
- @user.admin = false
- status = "admin_panel.unmake_admin_success"
- else
- @user.admin = true
- status = "admin_panel.make_admin_success"
- end
- respond_to do |format|
- if @user.save
- format.html { redirect_to admin_users_path, notice: (t status) }
- format.json { head :no_content }
- else
- format.html { redirect_to admin_users_path, alert: (t 'admin_panel.make_admin_error') }
- format.json { head :no_content }
- end
- end
- end
-
- private
-
- def info_params
- params.require(:info).permit(:website_name, :tagline, :contact_email, :default_language, :maintenance_mode, :maintenance_title, :maintenance_message)
- end
-
- end
|