Skip to content

Commit

Permalink
Merge pull request #904 from griffithlab/therapy-admin-fixes
Browse files Browse the repository at this point in the history
small admin fixes: display error message on duplicate ncit ids, add search
  • Loading branch information
acoffman authored Oct 4, 2023
2 parents 4a9a591 + 5bbc2fd commit dc155fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/app/admin/therapies_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
scope :all, default: true
scope :without_ncit_id, -> { Therapy.where(ncit_id: nil) }

search do |q|
q ? collection.where("name ILIKE ? OR ncit_id ILIKE ?", "%#{q}%", "%#{q}%") : collection
end

# Customize the table columns shown on the index view.
table do
column :id
Expand Down
2 changes: 2 additions & 0 deletions server/app/models/therapy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Therapy < ApplicationRecord
has_and_belongs_to_many :assertions
has_and_belongs_to_many :therapy_aliases

validates :ncit_id, uniqueness: true

def self.url_for(ncit_id:)
if ncit_id.nil?
nil
Expand Down

0 comments on commit dc155fe

Please sign in to comment.