-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We want an organisation index for each service. This index page will be shown to the user after he sigin in as a persona only if the user has multiple organisations. An organisation can be a school or a provider, the Membership polymorphic table handles this. The Placements service will show both schools and providers, the claims only schools.
- Loading branch information
1 parent
a485bee
commit 19fd4a6
Showing
24 changed files
with
371 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Claims::OrganisationsController < ApplicationController | ||
def index | ||
@schools = current_user.schools | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Placements::OrganisationsController < ApplicationController | ||
def index | ||
@schools = current_user.schools | ||
@providers = current_user.providers | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
class Membership < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :organisation, polymorphic: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl"><%= t("organisations") %></h1> | ||
|
||
<% if @schools.any? %> | ||
<ul class="govuk-list"> | ||
<% @schools.each do |school| %> | ||
<li> | ||
<%= govuk_link_to school.name, request.env["PATH_INFO"], no_visited_state: true %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl"><%= t("organisations") %></h1> | ||
|
||
<% if @schools.any? %> | ||
<h2 class="govuk-heading-l"><%= t("schools") %></h2> | ||
<ul class="govuk-list"> | ||
<% @schools.each do |school| %> | ||
<li> | ||
<%= govuk_link_to school.name, request.env["PATH_INFO"], no_visited_state: true %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
|
||
<% if @providers.any? %> | ||
<h2 class="govuk-heading-l"><%= t("providers") %></h2> | ||
<ul class="govuk-list"> | ||
<% @providers.each do |provider| %> | ||
<li> | ||
<%= govuk_link_to provider.provider_code, request.env["PATH_INFO"], no_visited_state: true %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
scope module: :claims, as: :claims, constraints: { host: ENV["CLAIMS_HOST"] } do | ||
root to: "pages#index" | ||
|
||
resources :organisations, only: [:index] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateMemberships < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :memberships, id: :uuid do |t| | ||
t.references :user, null: false, foreign_key: true, type: :uuid | ||
t.references :organisation, polymorphic: true, null: false, type: :uuid | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
FactoryBot.define do | ||
factory :membership do | ||
association :user | ||
association :organisation, factory: :school | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
require "rails_helper" | ||
|
||
RSpec.describe Membership, type: :model do | ||
subject { create(:membership) } | ||
|
||
context "associations" do | ||
it do | ||
should belong_to(:user) | ||
should belong_to(:organisation) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.