Skip to content

Commit

Permalink
Add a all DAO revoked projects view
Browse files Browse the repository at this point in the history
Right now there is no way to see these projects once the DAO is revoked,
for now we'll add this view just to have something, we will not link to
it in the application.
  • Loading branch information
mec committed Jun 27, 2024
1 parent 97224e6 commit 297c78a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/all/dao_revoked/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class All::DaoRevoked::ProjectsController < ApplicationController
after_action :verify_authorized
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error

def index
authorize Project, :index?
@pager, @projects = pagy(Project.dao_revoked.includes(:dao_revocation))

AcademiesApiPreFetcherService.new.call!(@projects)
end
end
17 changes: 17 additions & 0 deletions app/views/all/dao_revoked/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% content_for :primary_navigation do %>
<%= render partial: "shared/navigation/all_projects_primary_navigation" %>
<% end %>
<% content_for :page_title do %>
<%= page_title(t("project.all.dao_revoked.title")) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">
<%= t("project.all.dao_revoked.title") %>
</h1>

<%= render partial: "/projects/shared/dao_revoked_table", locals: {projects: @projects, pager: @pager} %>
</div>
</div>
33 changes: 33 additions & 0 deletions app/views/projects/shared/_dao_revoked_table.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<% if projects.empty? %>
<%= govuk_inset_text(text: t("project.table.dao_revoked.empty")) %>
<% else %>
<table class="govuk-table" name="projects_table" aria-label="Projects table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.school_name") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.school_urn") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.local_authority_name") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.team") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.conversion_date") %></th>
<th class="govuk-table__header" scope="col"><%= t("project.table.headers.dao_date_of_decision") %></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% projects.each do |project| %>
<tr class="govuk-table__row">
<td class="govuk-table__header govuk-table__cell">
<%= link_to project.establishment.name, project_path(project), class: "govuk-link govuk-link--no-visited-state" %>
</td>
<td class="govuk-table__cell"><%= project.urn %></td>
<td class="govuk-table__cell"><%= project.establishment.local_authority_name %></td>
<td class="govuk-table__cell"><%= t("teams.#{project.team}") %></td>
<td class="govuk-table__cell"><%= project.significant_date.to_formatted_s(:significant_date) %></td>
<td class="govuk-table__cell"><%= project.dao_revocation.date_of_decision.to_fs(:govuk) %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<%= govuk_pagination(pagy: pager) %>
3 changes: 3 additions & 0 deletions config/locales/project.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ en:
tab: Form a MAT
by_trust:
title: All projects by trust
dao_revoked:
title: Conversions with a revoked DAO (Directive Academy Order)
completed:
title: All completed projects
trust_ukprn:
Expand Down Expand Up @@ -177,6 +179,7 @@ en:
school_urn: URN
type: Type of project
completed_at: Project completion date
dao_date_of_decision: Date of the decision to revoked the DAO
assigned_to: Assigned to
view: View project
assign: Assign project
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
resources :projects, only: %i[index] do
collection do
namespace :all do
namespace :dao_revoked, path: "dao-revoked" do
get "/", to: "projects#index"
end
namespace :completed do
get "/", to: "projects#index"
end
Expand Down
19 changes: 19 additions & 0 deletions spec/features/projects/dao_revoked/projects_can_be_viewed_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "rails_helper"

RSpec.feature "DAO projects can be viewed" do
before do
user = create(:user, :caseworker)
sign_in_with_user(user)
mock_all_academies_api_responses
end

scenario "on the all project dao revoked view" do
dao_project = create(:conversion_project, state: :dao_revoked, directive_academy_order: true)
dao_revocation = create(:dao_revocation, project: dao_project)

visit all_dao_revoked_projects_path

expect(page).to have_content "Conversions with a revoked DAO (Directive Academy Order)"
expect(page).to have_content dao_revocation.date_of_decision.to_fs(:govuk)
end
end

0 comments on commit 297c78a

Please sign in to comment.