diff --git a/app/assets/javascripts/admin/dashboard.coffee b/app/assets/javascripts/admin/dashboard.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/admin/dashboard.coffee
@@ -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/
diff --git a/app/assets/javascripts/admin/translations.coffee b/app/assets/javascripts/admin/translations.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/admin/translations.coffee
@@ -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/
diff --git a/app/assets/stylesheets/admin/dashboard.scss b/app/assets/stylesheets/admin/dashboard.scss
new file mode 100644
index 0000000..e84d552
--- /dev/null
+++ b/app/assets/stylesheets/admin/dashboard.scss
@@ -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/
diff --git a/app/assets/stylesheets/admin/translations.scss b/app/assets/stylesheets/admin/translations.scss
new file mode 100644
index 0000000..2eb5ca0
--- /dev/null
+++ b/app/assets/stylesheets/admin/translations.scss
@@ -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/
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
new file mode 100644
index 0000000..11fcc7b
--- /dev/null
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -0,0 +1,4 @@
+class Admin::DashboardController < AdminController
+ def index
+ end
+end
diff --git a/app/controllers/admin/translations_controller.rb b/app/controllers/admin/translations_controller.rb
new file mode 100644
index 0000000..db013f0
--- /dev/null
+++ b/app/controllers/admin/translations_controller.rb
@@ -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
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
new file mode 100644
index 0000000..f76d697
--- /dev/null
+++ b/app/controllers/admin_controller.rb
@@ -0,0 +1,3 @@
+class AdminController < ApplicationController
+ before_action :authenticate_admin!
+end
\ No newline at end of file
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 407aa10..d83690e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb
index 20a60d7..668e83b 100644
--- a/app/controllers/problems_controller.rb
+++ b/app/controllers/problems_controller.rb
@@ -1,5 +1,4 @@
class ProblemsController < ApplicationController
- skip_before_action :authenticate_admin!, only: [:index, :show]
before_action :set_problem, only: [:show]
def index
diff --git a/app/controllers/translations_controller.rb b/app/controllers/translations_controller.rb
index 9ea85f7..f3b0e70 100644
--- a/app/controllers/translations_controller.rb
+++ b/app/controllers/translations_controller.rb
@@ -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)
diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb
new file mode 100644
index 0000000..4052b7c
--- /dev/null
+++ b/app/helpers/admin/dashboard_helper.rb
@@ -0,0 +1,2 @@
+module Admin::DashboardHelper
+end
diff --git a/app/helpers/admin/translations_helper.rb b/app/helpers/admin/translations_helper.rb
new file mode 100644
index 0000000..737f375
--- /dev/null
+++ b/app/helpers/admin/translations_helper.rb
@@ -0,0 +1,2 @@
+module Admin::TranslationsHelper
+end
diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb
new file mode 100644
index 0000000..b1ae911
--- /dev/null
+++ b/app/views/admin/dashboard/index.html.erb
@@ -0,0 +1,2 @@
+
<%= t('.administration') %>
+<%= link_to t('.view_translations'), admin_translations_path %>
\ No newline at end of file
diff --git a/app/views/translations/_translation_pagination.html.erb b/app/views/admin/translations/_translation_pagination.html.erb
similarity index 100%
rename from app/views/translations/_translation_pagination.html.erb
rename to app/views/admin/translations/_translation_pagination.html.erb
diff --git a/app/views/translations/index.html.erb b/app/views/admin/translations/index.html.erb
similarity index 87%
rename from app/views/translations/index.html.erb
rename to app/views/admin/translations/index.html.erb
index b4d5237..1ba4325 100644
--- a/app/views/translations/index.html.erb
+++ b/app/views/admin/translations/index.html.erb
@@ -13,7 +13,7 @@
<% @translations.each do |translation| %>
| <%= translation.id %> |
- <%= link_to translation.title, translation %> |
+ <%= link_to translation.title, [:admin, translation] %> |
<% end %>
diff --git a/app/views/translations/index.json.jbuilder b/app/views/admin/translations/index.json.jbuilder
similarity index 100%
rename from app/views/translations/index.json.jbuilder
rename to app/views/admin/translations/index.json.jbuilder
diff --git a/app/views/translations/show.html.erb b/app/views/admin/translations/show.html.erb
similarity index 100%
rename from app/views/translations/show.html.erb
rename to app/views/admin/translations/show.html.erb
diff --git a/app/views/translations/show.json.jbuilder b/app/views/admin/translations/show.json.jbuilder
similarity index 100%
rename from app/views/translations/show.json.jbuilder
rename to app/views/admin/translations/show.json.jbuilder
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 87f25b8..fe74e24 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -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 %>
diff --git a/config/locales/views/admin/de.yml b/config/locales/views/admin/de.yml
new file mode 100644
index 0000000..579521d
--- /dev/null
+++ b/config/locales/views/admin/de.yml
@@ -0,0 +1,6 @@
+de:
+ admin:
+ dashboard:
+ index:
+ administration: "Administration"
+ view_translations: "Übersetzungen anschauen"
\ No newline at end of file
diff --git a/config/locales/views/translations/de.yml b/config/locales/views/translations/de.yml
index 40befab..69ea5f2 100644
--- a/config/locales/views/translations/de.yml
+++ b/config/locales/views/translations/de.yml
@@ -7,7 +7,6 @@ de:
source_code: Quelltext
translation_source_explanation: Hier kommt der HTML-Quelltext der Übersetzung hin.
new:
- back: Zurück
new_translation: Neue Übersetzung für Problem %{id}
notice:
successfully_created: Übersetzung wurde erfolgreich erstellt.
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 0a9dfc7..357d745 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,7 +3,11 @@ Rails.application.routes.draw do
resources :problems, only: [:index, :show] do
resources :translations, only: [:new, :create]
end
- resources :translations, only: [:index, :show]
+
+ namespace :admin do
+ get '', to: 'dashboard#index', as: '/'
+ resources :translations, only: [:index, :show]
+ end
mathjax 'mathjax'
diff --git a/test/controllers/admin/dashboard_controller_test.rb b/test/controllers/admin/dashboard_controller_test.rb
new file mode 100644
index 0000000..30f29e0
--- /dev/null
+++ b/test/controllers/admin/dashboard_controller_test.rb
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+class Admin::DashboardControllerTest < ActionController::TestCase
+ include Devise::TestHelpers
+
+ setup do
+ login
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+end
diff --git a/test/controllers/admin/translations_controller_test.rb b/test/controllers/admin/translations_controller_test.rb
new file mode 100644
index 0000000..6b58950
--- /dev/null
+++ b/test/controllers/admin/translations_controller_test.rb
@@ -0,0 +1,21 @@
+require 'test_helper'
+
+class Admin::TranslationsControllerTest < ActionController::TestCase
+ include Devise::TestHelpers
+
+ setup do
+ login
+ @translation = translations(:translation_one)
+ end
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:translations)
+ end
+
+ test "should show translation" do
+ get :show, id: @translation
+ assert_response :success
+ end
+
+end
diff --git a/test/controllers/translations_controller_test.rb b/test/controllers/translations_controller_test.rb
index 749220e..dc91bdb 100644
--- a/test/controllers/translations_controller_test.rb
+++ b/test/controllers/translations_controller_test.rb
@@ -4,7 +4,6 @@ class TranslationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
- @translation = translations(:translation_one)
@update = {
title: 'New title',
content: 'This is the new content',
@@ -13,14 +12,6 @@ class TranslationsControllerTest < ActionController::TestCase
title: '',
content: ''
}
- @admin = admins(:admin)
- end
-
- test "should get index" do
- sign_in @admin
- get :index
- assert_response :success
- assert_not_nil assigns(:translations)
end
test "should get new for translated problem" do
@@ -46,10 +37,4 @@ class TranslationsControllerTest < ActionController::TestCase
post :create, problem_id: 1, translation: @incorrect
end
end
-
- test "should show translation" do
- sign_in @admin
- get :show, id: @translation
- assert_response :success
- end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3c1612f..9037e51 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -10,4 +10,8 @@ class ActiveSupport::TestCase
fixtures :all
# Add more helper methods to be used by all tests here...
+ def login
+ admin = admins(:admin)
+ sign_in admin
+ end
end