1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-27 02:28:50 +01:00

Add problem count changing to the admin dashboard

This commit is contained in:
2015-09-09 17:40:15 +02:00
parent ae9315a623
commit 95b84f003c
5 changed files with 33 additions and 2 deletions

View File

@@ -1,4 +1,16 @@
class Admin::DashboardController < AdminController
def index
@current_problem_count = Problem.count
end
def update_problem_count
begin
new_problem_count = params[:problem_count].to_i
raise t('no_problem_count') unless new_problem_count
Problem.update_count(new_problem_count)
redirect_to({:controller => 'admin/dashboard', :action => :index}, notice: t('.success_message'))
rescue => e
redirect_to({:controller => 'admin/dashboard', :action => :index}, alert: t('.failure_message', error: e.message))
end
end
end