-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into CAPT-1527/keep-irp-national-insurance-and-…
…name-for-2-years
- Loading branch information
Showing
159 changed files
with
3,715 additions
and
681 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Backup Database to Azure Storage | ||
concurrency: build_and_deploy_main | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: # 03:00 UTC | ||
- cron: "0 3 * * *" | ||
|
||
jobs: | ||
backup: | ||
name: Backup AKS Database (production) | ||
runs-on: ubuntu-latest | ||
environment: production-aks | ||
|
||
steps: | ||
- name: Backup postgres | ||
uses: DFE-Digital/github-actions/backup-postgres@master | ||
with: | ||
storage-account: s189p01captdbbkppdsa | ||
resource-group: s189p01-capt-pd-rg | ||
app-name: claim-additional-payments-for-teaching-production-web | ||
cluster: production | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
backup-file: capt_prod_$(date +"%F").sql |
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,44 @@ | ||
name: Restore Database from Azure Storage | ||
concurrency: build_and_deploy_main | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
confirm: | ||
description: Set to true to restore nightly backup to production | ||
required: true | ||
default: 'false' | ||
type: choice | ||
options: | ||
- 'false' | ||
- 'true' | ||
backup-file: | ||
description: Name of the backup file in Azure storage. e.g. capt_prod_2024-07-15.sql.gz. The default value is today's backup. | ||
type: string | ||
|
||
jobs: | ||
restore: | ||
name: Restore AKS Database (production) | ||
if: inputs.confirm == 'true' | ||
runs-on: ubuntu-latest | ||
environment: production-aks | ||
|
||
steps: | ||
- name: Set backup file | ||
run: | | ||
if [ "${{ inputs.backup-file }}" != "" ]; then | ||
BACKUP_FILE=${{ inputs.backup-file }} | ||
else | ||
BACKUP_FILE=capt_prod_$(date +"%F").sql.gz | ||
fi | ||
echo "BACKUP_FILE=$BACKUP_FILE" >> $GITHUB_ENV | ||
- name: Restore postgres | ||
uses: DFE-Digital/github-actions/restore-postgres-backup@master | ||
with: | ||
storage-account: s189p01captdbbkppdsa | ||
resource-group: s189p01-capt-pd-rg | ||
app-name: claim-additional-payments-for-teaching-production-web | ||
cluster: production | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
backup-file: ${{ env.BACKUP_FILE }} |
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,45 @@ | ||
module Admin | ||
class EligibleFeProvidersController < BaseAdminController | ||
before_action :ensure_service_operator | ||
|
||
helper_method :journey_configuration | ||
|
||
def create | ||
@download_form = EligibleFeProvidersForm.new | ||
@upload_form = EligibleFeProvidersForm.new(upload_params) | ||
|
||
if @upload_form.invalid? | ||
render "admin/journey_configurations/edit" | ||
else | ||
@upload_form.importer.run | ||
flash[:notice] = @upload_form.importer.results_message | ||
|
||
redirect_to edit_admin_journey_configuration_path(Journeys::FurtherEducationPayments::ROUTING_NAME, eligible_fe_providers_upload: {academic_year: @upload_form.academic_year}) | ||
end | ||
end | ||
|
||
def show | ||
@download_form = EligibleFeProvidersForm.new(download_params) | ||
|
||
send_data EligibleFeProvider.csv_for_academic_year(@download_form.academic_year), | ||
type: "text/csv", | ||
filename: "eligible_further_education_providers_#{@download_form.academic_year}.csv" | ||
end | ||
|
||
private | ||
|
||
def journey_configuration | ||
@journey_configuration ||= Journeys::Configuration.find_by( | ||
routing_name: Journeys::FurtherEducationPayments::ROUTING_NAME | ||
) | ||
end | ||
|
||
def upload_params | ||
params.require(:eligible_fe_providers_upload).permit(:academic_year, :file) | ||
end | ||
|
||
def download_params | ||
params.require(:eligible_fe_providers_download).permit(:academic_year) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Admin::EligibleFeProvidersForm | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
|
||
attribute :academic_year, AcademicYear::Type.new | ||
attribute :file | ||
|
||
validates :file, | ||
presence: {message: "Choose a CSV file of eligible FE providers to upload"} | ||
|
||
validate :validate_importer_errors | ||
|
||
def select_options | ||
(0..2).map do |relative_year| | ||
academic_year = AcademicYear.current + relative_year | ||
OpenStruct.new(id: academic_year.to_s, name: academic_year) | ||
end | ||
end | ||
|
||
def importer | ||
@importer ||= EligibleFeProvidersImporter.new( | ||
file, | ||
academic_year | ||
) | ||
end | ||
|
||
private | ||
|
||
# importer is not activemodel::errors compliant | ||
def validate_importer_errors | ||
importer.errors.each do |error| | ||
errors.add(:file, error) | ||
end | ||
end | ||
end |
Oops, something went wrong.