diff --git a/app/controllers/casa_orgs_controller.rb b/app/controllers/casa_orgs_controller.rb
index 222cd22ec8..abf9d668d3 100644
--- a/app/controllers/casa_orgs_controller.rb
+++ b/app/controllers/casa_orgs_controller.rb
@@ -3,6 +3,7 @@ class CasaOrgsController < ApplicationController
before_action :set_casa_org, only: %i[edit update]
before_action :set_contact_type_data, only: %i[edit update]
before_action :set_hearing_types, only: %i[edit update]
+ before_action :set_judges, only: %i[edit update]
before_action :must_be_admin
before_action :require_organization!
@@ -42,4 +43,8 @@ def set_contact_type_data
def set_hearing_types
@hearing_types = HearingType.for_organization(@casa_org)
end
+
+ def set_judges
+ @judges = Judge.for_organization(@casa_org)
+ end
end
diff --git a/app/controllers/judges_controller.rb b/app/controllers/judges_controller.rb
new file mode 100644
index 0000000000..5d04c17cb6
--- /dev/null
+++ b/app/controllers/judges_controller.rb
@@ -0,0 +1,43 @@
+class JudgesController < ApplicationController
+ before_action :authenticate_user!, :must_be_admin
+ before_action :set_judge, except: [:new, :create]
+
+ def new
+ @judge = Judge.new
+ end
+
+ def create
+ @judge = Judge.new(judge_params)
+
+ respond_to do |format|
+ if @judge.save
+ format.html { redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully created." }
+ else
+ format.html { render :new }
+ end
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @judge.update(judge_params)
+ redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully updated."
+ else
+ render :edit
+ end
+ end
+
+ private
+
+ def set_judge
+ @judge = Judge.find(params[:id])
+ end
+
+ def judge_params
+ params.require(:judge).permit(:name, :active).merge(
+ casa_org: current_organization
+ )
+ end
+end
diff --git a/app/models/judge.rb b/app/models/judge.rb
new file mode 100644
index 0000000000..5ea4f03bc7
--- /dev/null
+++ b/app/models/judge.rb
@@ -0,0 +1,30 @@
+class Judge < ApplicationRecord
+ has_paper_trail
+
+ belongs_to :casa_org
+
+ validates :name, presence: true, uniqueness: {scope: %i[casa_org]}
+
+ scope :for_organization, ->(org) { where(casa_org: org) }
+ scope :active, -> { where(active: true) }
+end
+
+# == Schema Information
+#
+# Table name: judges
+#
+# id :bigint not null, primary key
+# active :boolean default(TRUE)
+# name :string
+# created_at :datetime not null
+# updated_at :datetime not null
+# casa_org_id :bigint not null
+#
+# Indexes
+#
+# index_judges_on_casa_org_id (casa_org_id)
+#
+# Foreign Keys
+#
+# fk_rails_... (casa_org_id => casa_orgs.id)
+#
diff --git a/app/views/casa_orgs/_hearing_types.html.erb b/app/views/casa_orgs/_hearing_types.html.erb
index 4edd081108..bfff894157 100644
--- a/app/views/casa_orgs/_hearing_types.html.erb
+++ b/app/views/casa_orgs/_hearing_types.html.erb
@@ -9,7 +9,7 @@
diff --git a/app/views/casa_orgs/_judges.html.erb b/app/views/casa_orgs/_judges.html.erb
new file mode 100644
index 0000000000..f5283ea785
--- /dev/null
+++ b/app/views/casa_orgs/_judges.html.erb
@@ -0,0 +1,32 @@
+Name
- Active
+ Active?
Actions
| Name | +Active? | +Actions | +
|---|---|---|
| + <%= judge.name %> + | ++ <%= judge.active ? "Yes" : "No" %> + | ++ <%= link_to "Edit", edit_judge_path(judge) %> + | +