Skip to content

Commit

Permalink
Merge pull request #8293 from alphagov/allow-csv-with-non-legacy
Browse files Browse the repository at this point in the history
Allow csv attachments to use modern urls
  • Loading branch information
syed-ali-tw authored Sep 22, 2023
2 parents 190ec40 + ff0ac31 commit e940295
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def update
attachment.attributes = attachment_params
message = "Attachment '#{attachment.title}' updated"
if attachment.is_a?(FileAttachment)
attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints unless attachment.attachment_data.csv?
attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints

attachment.attachment_data.attachable = attachable
if attachment.filename_changed? && attachable.allows_inline_attachments?
Expand Down Expand Up @@ -104,7 +104,7 @@ def build_file_attachment
FileAttachment.new(attachment_params).tap do |file_attachment|
file_attachment.build_attachment_data unless file_attachment.attachment_data
file_attachment.attachment_data.attachable = attachable
file_attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints? unless file_attachment.attachment_data.csv?
file_attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints?
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/bulk_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create
@bulk_upload.attachments_attributes = create_params[:attachments_attributes]
@bulk_upload.attachments.each do |attachment|
attachment.attachment_data.attachable = @edition
attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints? unless attachment.attachment_data.csv?
attachment.attachment_data.use_non_legacy_endpoints = use_non_legacy_endpoints?
end
if @bulk_upload.save_attachments
redirect_to admin_edition_attachments_path(@edition)
Expand Down
2 changes: 1 addition & 1 deletion app/workers/create_asset_relationship_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateAssetRelationshipWorker < WorkerBase
def perform(start_id, end_id)
logger.info("CreateAssetRelationshipWorker start!")
assetable_type = AttachmentData
assetables = assetable_type.where(id: start_id..end_id).where.not(content_type: "text/csv")
assetables = assetable_type.where(id: start_id..end_id)
logger.info "Number of #{assetable_type} found: #{assetables.count}"
logger.info "Creating Asset for records from #{start_id} to #{end_id}"

Expand Down

0 comments on commit e940295

Please sign in to comment.