mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Add experiments_controller
This commit is contained in:
parent
1ad265835b
commit
ebda92ef05
2 changed files with 10 additions and 7 deletions
|
@ -2,6 +2,7 @@ class ExperimentsController < ApplicationController
|
|||
include PermissionHelper
|
||||
before_action :set_experiment, except: [:new, :create]
|
||||
before_action :set_project, only: [:new, :create]
|
||||
before_action :check_view_permissions, only: [:canvas]
|
||||
|
||||
# except parameter could be used but it is not working.
|
||||
layout :choose_layout
|
||||
|
@ -9,7 +10,7 @@ class ExperimentsController < ApplicationController
|
|||
def new
|
||||
@experiment = Experiment.new
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
format.json {
|
||||
render json:{
|
||||
html: render_to_string( {
|
||||
partial: "new_modal.html.erb"
|
||||
|
@ -69,16 +70,22 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
def set_experiment
|
||||
@experiment = Experiment.find_by_id(params[:id])
|
||||
render_404 unless @experiment
|
||||
end
|
||||
|
||||
def set_project
|
||||
@project = Project.find_by_id(params[:project_id])
|
||||
render_404 unless @project
|
||||
end
|
||||
|
||||
def experiment_params
|
||||
params.require(:experiment).permit(:name, :description)
|
||||
end
|
||||
|
||||
def check_view_permissions
|
||||
render_403 unless can_view_experiment(@experiment)
|
||||
end
|
||||
|
||||
def choose_layout
|
||||
action_name.in?(['index', 'archive']) ? 'main' : 'fluid'
|
||||
end
|
||||
|
|
|
@ -2,11 +2,11 @@ class ProjectsController < ApplicationController
|
|||
include SampleActions
|
||||
include RenamingUtil
|
||||
|
||||
before_action :load_vars, only: [:show, :edit, :update, :canvas,
|
||||
before_action :load_vars, only: [:show, :edit, :update,
|
||||
:notifications, :reports,
|
||||
:samples, :module_archive,
|
||||
:delete_samples, :samples_index]
|
||||
before_action :check_view_permissions, only: [:show, :canvas, :reports,
|
||||
before_action :check_view_permissions, only: [:show, :reports,
|
||||
:samples, :module_archive,
|
||||
:samples_index]
|
||||
before_action :check_view_notifications_permissions, only: [ :notifications ]
|
||||
|
@ -238,10 +238,6 @@ class ProjectsController < ApplicationController
|
|||
# This is the "info" view
|
||||
end
|
||||
|
||||
def canvas
|
||||
# This is the "structure/overview/canvas" view
|
||||
end
|
||||
|
||||
def notifications
|
||||
@modules = @project
|
||||
.assigned_modules(current_user)
|
||||
|
|
Loading…
Reference in a new issue