mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 02:45:53 +08:00
Prevent user being added to project/task multiple times [SCI-2869]
This commit is contained in:
parent
a6bc02a2cb
commit
5deaf25fd9
5 changed files with 20 additions and 25 deletions
|
@ -64,12 +64,11 @@ class UserMyModulesController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
render :json => {
|
render json: {
|
||||||
:errors => [
|
errors: @um.errors
|
||||||
flash_error]
|
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -102,13 +101,11 @@ class UserMyModulesController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
render :json => {
|
render json: {
|
||||||
:errors => [
|
errors: @um.errors
|
||||||
flash_error
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,14 +111,12 @@ class UserProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
render :json => {
|
render json: {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
:errors => [
|
errors: @up.errors
|
||||||
flash_error
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -148,13 +146,11 @@ class UserProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json {
|
format.json do
|
||||||
render :json => {
|
render json: {
|
||||||
:errors => [
|
errors: @up.errors
|
||||||
flash_error
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class UserMyModule < ApplicationRecord
|
class UserMyModule < ApplicationRecord
|
||||||
validates :user, :my_module, presence: true
|
validates :user, presence: true, uniqueness: { scope: :my_module }
|
||||||
|
validates :my_module, presence: true
|
||||||
|
|
||||||
belongs_to :user, inverse_of: :user_my_modules, touch: true, optional: true
|
belongs_to :user, inverse_of: :user_my_modules, touch: true, optional: true
|
||||||
belongs_to :assigned_by,
|
belongs_to :assigned_by,
|
||||||
|
|
|
@ -2,7 +2,7 @@ class UserProject < ApplicationRecord
|
||||||
enum role: { owner: 0, normal_user: 1, technician: 2, viewer: 3 }
|
enum role: { owner: 0, normal_user: 1, technician: 2, viewer: 3 }
|
||||||
|
|
||||||
validates :role, presence: true
|
validates :role, presence: true
|
||||||
validates :user, presence: true
|
validates :user, presence: true, uniqueness: { scope: :project }
|
||||||
validates :project, presence: true
|
validates :project, presence: true
|
||||||
|
|
||||||
belongs_to :user, inverse_of: :user_projects, touch: true, optional: true
|
belongs_to :user, inverse_of: :user_projects, touch: true, optional: true
|
||||||
|
|
|
@ -543,6 +543,7 @@ en:
|
||||||
create:
|
create:
|
||||||
select_user_role: "Please select a user role."
|
select_user_role: "Please select a user role."
|
||||||
add_user_generic_error: "An error occured. "
|
add_user_generic_error: "An error occured. "
|
||||||
|
can_add_user_to_project: "Can not add user to the project."
|
||||||
|
|
||||||
my_modules:
|
my_modules:
|
||||||
buttons:
|
buttons:
|
||||||
|
|
Loading…
Add table
Reference in a new issue