generated from dxw/rails-template
-
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.
Showing
115 changed files
with
1,716 additions
and
574 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
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
23 changes: 23 additions & 0 deletions
23
app/controllers/framework_requests/contract_lengths_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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module FrameworkRequests | ||
class ContractLengthsController < BaseController | ||
skip_before_action :authenticate_user! | ||
|
||
private | ||
|
||
def form | ||
@form ||= FrameworkRequests::ContractLengthForm.new(all_form_params) | ||
end | ||
|
||
def form_params | ||
[:contract_length] | ||
end | ||
|
||
def create_redirect_path | ||
contract_start_date_framework_requests_path(framework_support_form: form.common) | ||
end | ||
|
||
def back_url | ||
@back_url = categories_framework_requests_path(category_path: framework_request.category&.ancestors_slug, framework_support_form: @form.common) | ||
end | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
app/controllers/framework_requests/contract_start_dates_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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module FrameworkRequests | ||
class ContractStartDatesController < BaseController | ||
include Support::Concerns::HasDateParams | ||
|
||
skip_before_action :authenticate_user! | ||
|
||
private | ||
|
||
def form | ||
@form ||= FrameworkRequests::ContractStartDateForm.new(all_form_params) | ||
end | ||
|
||
def form_params | ||
%i[contract_start_date_known contract_start_date] | ||
end | ||
|
||
def all_form_params | ||
super | ||
.except("contract_start_date(3i)", "contract_start_date(2i)", "contract_start_date(1i)") | ||
.merge(contract_start_date: date_param(:framework_support_form, :contract_start_date).compact_blank) | ||
end | ||
|
||
def create_redirect_path | ||
if framework_request.multischool? | ||
same_supplier_framework_requests_path(framework_support_form: form.common) | ||
else | ||
procurement_amount_framework_requests_path(framework_support_form: form.common) | ||
end | ||
end | ||
|
||
def back_url | ||
@back_url = contract_length_framework_requests_path(ramework_support_form: @form.common) | ||
end | ||
end | ||
end |
71 changes: 71 additions & 0 deletions
71
app/controllers/framework_requests/document_uploads_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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module FrameworkRequests | ||
class DocumentUploadsController < BaseController | ||
skip_before_action :authenticate_user! | ||
|
||
before_action :set_document_types, only: %i[index edit] | ||
|
||
def list | ||
files = framework_request.documents.map do |bill| | ||
{ | ||
file_id: bill.id, | ||
name: bill.filename, | ||
size: bill.file.attachment.byte_size, | ||
type: bill.file.attachment.content_type, | ||
} | ||
end | ||
render status: :ok, json: files.to_json | ||
end | ||
|
||
def upload | ||
if file_is_safe? | ||
document = Document.pending.create!( | ||
file: params[:file], | ||
framework_request_id: framework_request.id, | ||
filename: params[:file].original_filename, | ||
) | ||
|
||
render status: :created, json: { file_id: document.id } | ||
else | ||
track_event("Rfh/DocumentUploads/Upload/VirusDetected", framework_request_id: framework_request.id) | ||
|
||
params[:file].tempfile.delete | ||
|
||
render status: :unprocessable_entity, json: { error: "virus detected" } | ||
end | ||
end | ||
|
||
def remove | ||
document = Document.find(params[:file_id]) | ||
document.destroy! | ||
head :ok | ||
end | ||
|
||
private | ||
|
||
def file_is_safe? | ||
# Rails.configuration.clamav_scanner.file_is_safe?(params[:file]) | ||
true | ||
end | ||
|
||
def form | ||
@form ||= FrameworkRequests::DocumentUploadsForm.new(all_form_params) | ||
end | ||
|
||
def update_data | ||
{} | ||
end | ||
|
||
def create_redirect_path | ||
special_requirements_framework_requests_path(framework_support_form: form.common) | ||
end | ||
|
||
def back_url | ||
@back_url = documents_framework_requests_path(framework_support_form: form.common) | ||
end | ||
|
||
def set_document_types | ||
@document_types = framework_request.document_types | ||
@other = framework_request.document_type_other | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
app/controllers/framework_requests/documents_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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FrameworkRequests | ||
class DocumentsController < BaseController | ||
skip_before_action :authenticate_user! | ||
|
||
private | ||
|
||
def form | ||
@form ||= FrameworkRequests::DocumentsForm.new(all_form_params) | ||
end | ||
|
||
def form_params | ||
[:document_type_other, { document_types: [] }] | ||
end | ||
|
||
def create_redirect_path | ||
return special_requirements_framework_requests_path(framework_support_form: @form.common) if framework_request.document_types.include?("none") | ||
|
||
document_uploads_framework_requests_path(framework_support_form: @form.common) | ||
end | ||
|
||
def back_url | ||
@back_url = message_framework_requests_path(framework_support_form: @form.common) | ||
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
Oops, something went wrong.