mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 02:28:50 +01:00
Move translation viewing to admin namespace
This commit is contained in:
3
app/assets/javascripts/admin/dashboard.coffee
Normal file
3
app/assets/javascripts/admin/dashboard.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/javascripts/admin/translations.coffee
Normal file
3
app/assets/javascripts/admin/translations.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/admin/dashboard.scss
Normal file
3
app/assets/stylesheets/admin/dashboard.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the admin/dashboard controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/admin/translations.scss
Normal file
3
app/assets/stylesheets/admin/translations.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the admin/translations controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
4
app/controllers/admin/dashboard_controller.rb
Normal file
4
app/controllers/admin/dashboard_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Admin::DashboardController < AdminController
|
||||
def index
|
||||
end
|
||||
end
|
||||
18
app/controllers/admin/translations_controller.rb
Normal file
18
app/controllers/admin/translations_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Admin::TranslationsController < AdminController
|
||||
before_action :set_translation, only: :show
|
||||
|
||||
# GET /translations
|
||||
# GET /translations.json
|
||||
def index
|
||||
@translations = Translation.paginate(page: params[:page])
|
||||
end
|
||||
|
||||
# GET /translations/1
|
||||
# GET /translations/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
def set_translation
|
||||
@translation = Translation.find(params[:id])
|
||||
end
|
||||
end
|
||||
3
app/controllers/admin_controller.rb
Normal file
3
app/controllers/admin_controller.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class AdminController < ApplicationController
|
||||
before_action :authenticate_admin!
|
||||
end
|
||||
@@ -2,5 +2,4 @@ class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
before_action :authenticate_admin!
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class ProblemsController < ApplicationController
|
||||
skip_before_action :authenticate_admin!, only: [:index, :show]
|
||||
before_action :set_problem, only: [:show]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
class TranslationsController < ApplicationController
|
||||
skip_before_action :authenticate_admin!, only: [:new, :create]
|
||||
before_action :set_translation, only: :show
|
||||
before_action :set_problem, only: [:new, :create]
|
||||
|
||||
# GET /translations
|
||||
# GET /translations.json
|
||||
def index
|
||||
@translations = Translation.paginate(page: params[:page])
|
||||
end
|
||||
|
||||
# GET /translations/1
|
||||
# GET /translations/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /translations/new
|
||||
def new
|
||||
@translation = @problem.translations.build
|
||||
@@ -40,11 +27,6 @@ class TranslationsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_translation
|
||||
@translation = Translation.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def translation_params
|
||||
params.require(:translation).permit(:title, :content)
|
||||
|
||||
2
app/helpers/admin/dashboard_helper.rb
Normal file
2
app/helpers/admin/dashboard_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Admin::DashboardHelper
|
||||
end
|
||||
2
app/helpers/admin/translations_helper.rb
Normal file
2
app/helpers/admin/translations_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Admin::TranslationsHelper
|
||||
end
|
||||
2
app/views/admin/dashboard/index.html.erb
Normal file
2
app/views/admin/dashboard/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1><%= t('.administration') %></h1>
|
||||
<%= link_to t('.view_translations'), admin_translations_path %>
|
||||
@@ -13,7 +13,7 @@
|
||||
<% @translations.each do |translation| %>
|
||||
<tr>
|
||||
<td><%= translation.id %></td>
|
||||
<td><%= link_to translation.title, translation %></td>
|
||||
<td><%= link_to translation.title, [:admin, translation] %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
@@ -27,7 +27,7 @@
|
||||
<%= nav class: 'navbar-left' do %>
|
||||
<%= link_to Problem.model_name.human(count: 2), problems_path %>
|
||||
<% if admin_signed_in? %>
|
||||
<%= link_to Translation.model_name.human(count: 2), translations_path %>
|
||||
<%= link_to t('admin.dashboard.index.administration'), :admin %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= nav class: 'navbar-right' do %>
|
||||
|
||||
Reference in New Issue
Block a user