-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1701 from DFE-Digital/feature/169471-dao-revocati…
…on-not-show-in-export (169471) DAO dao revocations in exports
- Loading branch information
Showing
17 changed files
with
183 additions
and
82 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
24 changes: 12 additions & 12 deletions
24
app/controllers/all/export/by_significant_date/conversions/all_data/projects_controller.rb
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,30 +1,30 @@ | ||
class All::Export::BySignificantDate::Conversions::AllData::ProjectsController < ApplicationController | ||
include DateRangable | ||
|
||
def date_range_csv | ||
authorize Project, :index? | ||
|
||
from_date = "#{params[:from_year]}-#{params[:from_month]}-1" | ||
to_date = "#{params[:to_year]}-#{params[:to_month]}-1" | ||
return redirect_if_dates_incorrect if Date.parse(to_date) < Date.parse(from_date) | ||
return redirect_if_dates_incorrect if @to_date < @from_date | ||
|
||
projects = ByMonthProjectFetcherService.new.conversion_projects_by_date_range(from_date, to_date) | ||
csv = Export::Conversions::AllDataCsvExportService.new(projects).call | ||
csv = create_csv | ||
|
||
send_data csv, filename: "#{from_date}-#{to_date}_schools_due_to_convert.csv", type: :csv, disposition: "attachment" | ||
send_data csv, filename: "#{@from_date}-#{@to_date}_schools_due_to_convert.csv", type: :csv, disposition: "attachment" | ||
end | ||
|
||
def single_month_csv | ||
authorize Project, :index? | ||
|
||
month = params[:month] | ||
year = params[:year] | ||
|
||
projects = ByMonthProjectFetcherService.new.conversion_projects_by_date(month, year) | ||
csv = Export::Conversions::AllDataCsvExportService.new(projects).call | ||
csv = create_csv | ||
|
||
send_data csv, filename: "#{month}-#{year}_schools_due_to_convert.csv", type: :csv, disposition: "attachment" | ||
send_data csv, filename: "#{@from_date.month}-#{@from_date.year}_schools_due_to_convert.csv", type: :csv, disposition: "attachment" | ||
end | ||
|
||
private def redirect_if_dates_incorrect | ||
redirect_to date_range_this_month_all_by_month_conversions_projects_path, alert: I18n.t("project.date_range.date_form.from_date_before_to_date") | ||
end | ||
|
||
private def create_csv | ||
projects = ByMonthProjectFetcherService.new.conversion_projects_by_date_range(@from_date.to_s, @to_date.to_s) | ||
Export::Conversions::AllDataCsvExportService.new(projects).call | ||
end | ||
end |
17 changes: 7 additions & 10 deletions
17
app/controllers/all/export/by_significant_date/transfers/all_data/projects_controller.rb
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,28 @@ | ||
module DateRangable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :set_from_and_to_date | ||
end | ||
|
||
private def set_from_and_to_date | ||
if ranged_params? | ||
from_year = params[:from_year] | ||
from_month = params[:from_month] | ||
to_year = params[:to_year] | ||
to_month = params[:to_month] | ||
else | ||
from_year = params[:year] | ||
from_month = params[:month] | ||
to_year = params[:year] | ||
to_month = params[:month] | ||
end | ||
|
||
@from_date = Date.new(from_year.to_i, from_month.to_i).at_beginning_of_month | ||
@to_date = Date.new(to_year.to_i, to_month.to_i).at_end_of_month | ||
end | ||
|
||
private def ranged_params? | ||
params[:from_year].present? && params[:from_month].present? && params[:to_year].present? && params[:to_month].present? | ||
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
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,10 @@ | ||
FactoryBot.define do | ||
factory :dao_revocation do | ||
project { association :conversion_project } | ||
decision_makers_name { "Minister Name" } | ||
date_of_decision { Date.today - 1.week } | ||
reason_school_rating_improved { false } | ||
reason_safeguarding_addressed { false } | ||
reason_school_closed { true } | ||
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.