mirror of
https://github.com/we-promise/sure.git
synced 2026-04-09 15:24:48 +00:00
* feat(settings): split imports and exports * feat(security): sanitize pagination params to prevent abuse * fix(settings): fix syntax in settings nav * feat(settings): internationalize family_exports and imports UI strings * fix(settings): fix coderabbit review * fix(settings): fix coderabbit review * fix(settings): fix coderabbit review * Change default per_page value from 20 to 10 Signed-off-by: Juan José Mata <jjmata@jjmata.com> * Add `/family_export` to navigation * Consistency with old defaults * Align `safe_per_page` even if not DRY --------- Signed-off-by: Julien Orain <julien.orain@gmail.com> Signed-off-by: Juan José Mata <jjmata@jjmata.com> Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: JulienOrain <your-github-email@example.com> Co-authored-by: Juan José Mata <jjmata@jjmata.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
57 lines
1.4 KiB
Ruby
57 lines
1.4 KiB
Ruby
class FamilyExportsController < ApplicationController
|
|
include StreamExtensions
|
|
|
|
before_action :require_admin
|
|
before_action :set_export, only: [ :download, :destroy ]
|
|
|
|
def new
|
|
# Modal view for initiating export
|
|
end
|
|
|
|
def create
|
|
@export = Current.family.family_exports.create!
|
|
FamilyDataExportJob.perform_later(@export)
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to family_exports_path, notice: t("family_exports.create.success") }
|
|
format.turbo_stream {
|
|
stream_redirect_to family_exports_path, notice: t("family_exports.create.success")
|
|
}
|
|
end
|
|
end
|
|
|
|
def index
|
|
@pagy, @exports = pagy(Current.family.family_exports.ordered, limit: safe_per_page)
|
|
@breadcrumbs = [
|
|
[ t("breadcrumbs.home"), root_path ],
|
|
[ t("breadcrumbs.exports"), family_exports_path ]
|
|
]
|
|
render layout: "settings"
|
|
end
|
|
|
|
def download
|
|
if @export.downloadable?
|
|
redirect_to @export.export_file, allow_other_host: true
|
|
else
|
|
redirect_to family_exports_path, alert: t("family_exports.export_not_ready")
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@export.destroy
|
|
redirect_to family_exports_path, notice: t("family_exports.destroy.success")
|
|
end
|
|
|
|
private
|
|
|
|
def set_export
|
|
@export = Current.family.family_exports.find(params[:id])
|
|
end
|
|
|
|
def require_admin
|
|
unless Current.user.admin?
|
|
redirect_to root_path, alert: t("family_exports.access_denied")
|
|
end
|
|
end
|
|
end
|