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:
@@ -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
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
<h1><%= t('.administration') %></h1>
|
||||
<%= link_to t('.view_translations'), admin_translations_path %>
|
||||
<%= link_to t('.view_translations'), admin_translations_path, class: 'btn btn-default' %>
|
||||
|
||||
<h1><%= t('.update_problem_count') %></h1>
|
||||
<%= form_tag '/admin/update_problem_count', method: :post, class: 'form-inline' do %>
|
||||
<%= number_field_tag 'problem_count', @current_problem_count, min: @current_problem_count, class: 'form-control' %>
|
||||
<%= submit_tag t('.update'), class: 'btn btn-warning' %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user