mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 04:34:06 +08:00
Fix projects query for experiments
Remove unneeded word in view
This commit is contained in:
parent
d7341d0383
commit
c387439fb2
2 changed files with 10 additions and 8 deletions
|
@ -93,7 +93,7 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
# GET: clone_modal_experiment_path(id)
|
||||
def clone_modal
|
||||
@projects = projects_with_role_above_user
|
||||
@projects = projects_with_role_above_user(true)
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
|
@ -111,7 +111,7 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
# Try to clone the experiment
|
||||
success = true
|
||||
if projects_with_role_above_user.include?(project)
|
||||
if projects_with_role_above_user(true).include?(project)
|
||||
cloned_experiment = @experiment.deep_clone_to_project(current_user,
|
||||
project)
|
||||
success = cloned_experiment.valid?
|
||||
|
@ -144,7 +144,7 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
# GET: move_modal_experiment_path(id)
|
||||
def move_modal
|
||||
@projects = projects_with_role_above_user
|
||||
@projects = projects_with_role_above_user(false)
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
|
@ -232,12 +232,15 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
# Get projects where user is either owner or user in the same organization
|
||||
# as this experiment
|
||||
def projects_with_role_above_user
|
||||
# - include_this_project: whether to include project from @experiment
|
||||
def projects_with_role_above_user(include_this_project)
|
||||
organization = @experiment.project.organization
|
||||
projects = organization.projects.where(archived: false)
|
||||
projects = projects
|
||||
.where.not(id: @experiment.project.id) unless include_this_project
|
||||
|
||||
current_user.user_projects
|
||||
.where(project:
|
||||
Project.where(organization: organization)
|
||||
.where(archived: false))
|
||||
.where(project: projects)
|
||||
.where('role < 2')
|
||||
.map(&:project)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<h4 class="modal-title" id="move-experiment-modal-label"><%= t("experiments.move.modal_title", experiment: @experiment.name ) %></h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
asdasd
|
||||
<%= f.select :project_id, options_for_select(@projects.collect { |p| [ p.name, p.id ] },
|
||||
@project.id ),
|
||||
{}, {class: "form-control selectpicker", "data-role" => "clear"} %>
|
||||
|
|
Loading…
Reference in a new issue