mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-02 18:04:29 +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
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
render :json => {
|
||||
:errors => [
|
||||
flash_error]
|
||||
format.json do
|
||||
render json: {
|
||||
errors: @um.errors
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -102,13 +101,11 @@ class UserMyModulesController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
render :json => {
|
||||
:errors => [
|
||||
flash_error
|
||||
]
|
||||
format.json do
|
||||
render json: {
|
||||
errors: @um.errors
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -111,14 +111,12 @@ class UserProjectsController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
render :json => {
|
||||
format.json do
|
||||
render json: {
|
||||
status: 'error',
|
||||
:errors => [
|
||||
flash_error
|
||||
]
|
||||
errors: @up.errors
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -148,13 +146,11 @@ class UserProjectsController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
render :json => {
|
||||
:errors => [
|
||||
flash_error
|
||||
]
|
||||
format.json do
|
||||
render json: {
|
||||
errors: @up.errors
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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 :assigned_by,
|
||||
|
|
|
@ -2,7 +2,7 @@ class UserProject < ApplicationRecord
|
|||
enum role: { owner: 0, normal_user: 1, technician: 2, viewer: 3 }
|
||||
|
||||
validates :role, presence: true
|
||||
validates :user, presence: true
|
||||
validates :user, presence: true, uniqueness: { scope: :project }
|
||||
validates :project, presence: true
|
||||
|
||||
belongs_to :user, inverse_of: :user_projects, touch: true, optional: true
|
||||
|
|
|
@ -543,6 +543,7 @@ en:
|
|||
create:
|
||||
select_user_role: "Please select a user role."
|
||||
add_user_generic_error: "An error occured. "
|
||||
can_add_user_to_project: "Can not add user to the project."
|
||||
|
||||
my_modules:
|
||||
buttons:
|
||||
|
|
Loading…
Add table
Reference in a new issue