A website template with lots of features, built with ruby on rails.

admin_panel_controller.rb 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. class AdminPanelController < ApplicationController
  2. layout 'admin'
  3. def maintenance_mode
  4. end
  5. def index
  6. redirect_to admin_dashboard_path
  7. end
  8. def dashboard
  9. @users = User.all
  10. @posts = BlogPost.all
  11. @files = Upload.all
  12. end
  13. def posts
  14. @posts = BlogPost.all
  15. end
  16. def contact_messages
  17. @contact_messages = ContactMessage.order('created_at DESC').all
  18. end
  19. def users
  20. @users = User.all
  21. end
  22. def files
  23. @uploads = Upload.all
  24. end
  25. def site_config
  26. @config = Info.first
  27. end
  28. def site_config_update
  29. @config = Info.first
  30. respond_to do |format|
  31. if @config.update(info_params)
  32. format.html { redirect_to admin_config_path, notice: (t 'admin_panel.config_update_success') }
  33. format.json { head :no_content }
  34. else
  35. format.html { render action: 'site_config' }
  36. format.json { render json: @upload.errors, status: :unprocessable_entity }
  37. end
  38. end
  39. end
  40. private
  41. # Never trust parameters from the scary internet, only allow the white list through.
  42. def info_params
  43. params.require(:info).permit(:website_name, :tagline, :contact_email, :default_language, :maintenance_mode, :maintenance_title, :maintenance_message)
  44. end
  45. end