Class: BackupController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/backup_controller.rb

Constant Summary collapse

EXPORT_PERMISSION =
'redmine_with_git.backup.export'
IMPORT_PERMISSION =
'redmine_with_git.backup.import'
PERMISSIONS =
{ or: [EXPORT_PERMISSION, IMPORT_PERMISSION] }.freeze

Instance Method Summary collapse

Instance Method Details

#exportObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/backup_controller.rb', line 22

def export
  Tempfile.open('redmine_export') do |file|
    ::RedmineWithGit::Dump::All.new(
      file.path,
      overwrite: ::RedmineWithGit::Dump::Base::OVERWRITE_ALLOWED
    )
    send_file(file.path, filename: export_file_name, type: 'application/x-tar',
                         size: file.size)
  end
end

#importObject



33
34
35
36
37
38
39
40
# File 'app/controllers/backup_controller.rb', line 33

def import
  @load = ::RedmineWithGit::Tableless::Load.new(import_params)
  @load.save
  respond_to do |format|
    format.html { import_respond_to_html }
    format.api { render_validation_errors(@load) }
  end
end

#indexObject



18
19
20
# File 'app/controllers/backup_controller.rb', line 18

def index
  @load = ::RedmineWithGit::Tableless::Load.new
end