mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add upload of Terms of Service files
Admins can upload files and view the most recent (current) one.
This commit is contained in:
@@ -3,6 +3,25 @@
|
||||
module Admin
|
||||
class TermsOfServiceFilesController < Spree::Admin::BaseController
|
||||
def show
|
||||
@current_file = TermsOfServiceFile.current
|
||||
@new_file = TermsOfServiceFile.new
|
||||
end
|
||||
|
||||
def create
|
||||
TermsOfServiceFile.create!(file_params)
|
||||
redirect_to main_app.admin_terms_of_service_files_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Needed by Spree::Admin::BaseController#authorize_admin or it
|
||||
# tries to find a Spree model.
|
||||
def model_class
|
||||
TermsOfServiceFile
|
||||
end
|
||||
|
||||
def file_params
|
||||
params.require(:terms_of_service_file).permit(:attachment)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
- content_for :page_title do
|
||||
= t(".title")
|
||||
|
||||
= t(".no_files")
|
||||
- if @current_file
|
||||
= link_to t(".terms_of_service"), @current_file.attachment.url
|
||||
- else
|
||||
= t(".no_files")
|
||||
|
||||
= form_for [main_app, :admin, @new_file] do |f|
|
||||
= f.label :attachment
|
||||
= f.file_field :attachment
|
||||
= f.submit
|
||||
|
||||
@@ -450,7 +450,9 @@ en:
|
||||
|
||||
terms_of_service_files:
|
||||
show:
|
||||
title: "Terms of Service files"
|
||||
no_files: "No terms of services have been uploaded yet."
|
||||
terms_of_service: "Terms of Service"
|
||||
number_localization:
|
||||
number_localization_settings: "Number Localization Settings"
|
||||
enable_localized_number: "Use the international thousand/decimal separator logic"
|
||||
|
||||
@@ -13,5 +13,13 @@ describe "Terms of Service files" do
|
||||
click_link "Terms of Service"
|
||||
expect(page).to have_content "No terms of services have been uploaded yet."
|
||||
end
|
||||
|
||||
it "can be uploaded" do
|
||||
visit admin_terms_of_service_files_path
|
||||
attach_file "Attachment", Rails.root.join("public/Terms-of-service.pdf")
|
||||
click_button "Create Terms of service file"
|
||||
|
||||
expect(page).to have_link "Terms of Service"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user