Routes, empty views and controller changes for statistics concerning external_users, exercises and external_users having exercises
This commit is contained in:
@ -7,6 +7,7 @@ class ExercisesController < ApplicationController
|
|||||||
before_action :handle_file_uploads, only: [:create, :update]
|
before_action :handle_file_uploads, only: [:create, :update]
|
||||||
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
||||||
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
|
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :run, :statistics, :submit, :reload]
|
||||||
|
before_action :set_external_user, only: [:statistics]
|
||||||
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
||||||
before_action :set_teams, only: [:create, :edit, :new, :update]
|
before_action :set_teams, only: [:create, :edit, :new, :update]
|
||||||
|
|
||||||
@ -125,6 +126,14 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
private :set_exercise
|
private :set_exercise
|
||||||
|
|
||||||
|
def set_external_user
|
||||||
|
if params[:external_user_id]
|
||||||
|
@external_user = ExternalUser.find(params[:external_user_id])
|
||||||
|
authorize!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
private :set_exercise
|
||||||
|
|
||||||
def set_file_types
|
def set_file_types
|
||||||
@file_types = FileType.all.order(:name)
|
@file_types = FileType.all.order(:name)
|
||||||
end
|
end
|
||||||
@ -143,6 +152,11 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def statistics
|
def statistics
|
||||||
|
if(@external_user)
|
||||||
|
render 'exercises/external_users/statistics'
|
||||||
|
else
|
||||||
|
render 'exercises/statistics'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def submit
|
def submit
|
||||||
|
@ -13,4 +13,10 @@ class ExternalUsersController < ApplicationController
|
|||||||
@user = ExternalUser.find(params[:id])
|
@user = ExternalUser.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statistics
|
||||||
|
@user = ExternalUser.find(params[:id])
|
||||||
|
authorize!
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
class ExternalUserPolicy < AdminOnlyPolicy
|
class ExternalUserPolicy < AdminOnlyPolicy
|
||||||
|
def statistics?
|
||||||
|
admin?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
1
app/views/exercises/external_users/statistics.html.slim
Normal file
1
app/views/exercises/external_users/statistics.html.slim
Normal file
@ -0,0 +1 @@
|
|||||||
|
h1 = "#{@exercise} for external user #{@external_user}"
|
2
app/views/external_users/statistics.html.slim
Normal file
2
app/views/external_users/statistics.html.slim
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
h1 = @user
|
||||||
|
H2 = 'Hallo'
|
@ -20,6 +20,13 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
get '/help', to: 'application#help'
|
get '/help', to: 'application#help'
|
||||||
|
|
||||||
|
concern :statistics do
|
||||||
|
member do
|
||||||
|
get :statistics
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
resources :consumers
|
resources :consumers
|
||||||
|
|
||||||
resources :execution_environments do
|
resources :execution_environments do
|
||||||
@ -47,7 +54,9 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :external_users, only: [:index, :show]
|
resources :external_users, only: [:index, :show], concerns: :statistics do
|
||||||
|
resources :exercises, concerns: :statistics
|
||||||
|
end
|
||||||
|
|
||||||
namespace :code_ocean do
|
namespace :code_ocean do
|
||||||
resources :files, only: [:create, :destroy]
|
resources :files, only: [:create, :destroy]
|
||||||
|
Reference in New Issue
Block a user