summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-26 10:48:08 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-26 10:48:08 +0100
commitffaa80e8d46b3b6b7597af6f157724005f48bae4 (patch)
tree0ba02970c4ce7a30d2859b01d9121fbf04cd5c75 /app
parent0442cd19bc9383669b506185356227361a16e442 (diff)
RestoreJob scaffold
Diffstat (limited to 'app')
-rw-r--r--app/controllers/restore_jobs_controller.rb24
-rw-r--r--app/helpers/restore_jobs_helper.rb2
-rw-r--r--app/models/ability.rb1
-rw-r--r--app/models/restore_job.rb13
-rw-r--r--app/uploaders/backup_file_uploader.rb6
-rw-r--r--app/views/backup_jobs/show.html.haml48
-rw-r--r--app/views/restore_jobs/_form.html.haml7
-rw-r--r--app/views/restore_jobs/_form_core.html.haml2
-rw-r--r--app/views/restore_jobs/_index_core.html.haml12
-rw-r--r--app/views/restore_jobs/index.html.haml6
-rw-r--r--app/views/restore_jobs/new.html.haml3
-rw-r--r--app/views/restore_jobs/show.html.haml22
12 files changed, 125 insertions, 21 deletions
diff --git a/app/controllers/restore_jobs_controller.rb b/app/controllers/restore_jobs_controller.rb
new file mode 100644
index 0000000..1cccdc1
--- /dev/null
+++ b/app/controllers/restore_jobs_controller.rb
@@ -0,0 +1,24 @@
+class RestoreJobsController < ApplicationController
+ skip_before_filter :start_setup_if_new_installation, :only => [:new, :create, :show, :index]
+
+ load_and_authorize_resource :restore_job
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ @restore_job.state = 'new'
+
+ if @restore_job.save
+ redirect_to @restore_job, :notice => t('restore_jobs.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+end
diff --git a/app/helpers/restore_jobs_helper.rb b/app/helpers/restore_jobs_helper.rb
new file mode 100644
index 0000000..9a5d120
--- /dev/null
+++ b/app/helpers/restore_jobs_helper.rb
@@ -0,0 +1,2 @@
+module RestoreJobsHelper
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index d886d53..690ee76 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -176,6 +176,7 @@ class Ability
#
can :create, GemeinschaftSetup
can :manage, SipDomain
+ can [:create, :new, :show, :index], RestoreJob
end
end
diff --git a/app/models/restore_job.rb b/app/models/restore_job.rb
new file mode 100644
index 0000000..2c2da54
--- /dev/null
+++ b/app/models/restore_job.rb
@@ -0,0 +1,13 @@
+class RestoreJob < ActiveRecord::Base
+ attr_accessible :state, :backup_file
+
+ mount_uploader :backup_file, BackupFileUploader
+
+ def to_s
+ if self.backup_file?
+ File.basename(self.backup_file.to_s)
+ else
+ "RestoreJob ID #{self.id}"
+ end
+ end
+end
diff --git a/app/uploaders/backup_file_uploader.rb b/app/uploaders/backup_file_uploader.rb
index 8b126a9..0244ba5 100644
--- a/app/uploaders/backup_file_uploader.rb
+++ b/app/uploaders/backup_file_uploader.rb
@@ -42,9 +42,9 @@ class BackupFileUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
- # def extension_white_list
- # %w(jpg jpeg gif png)
- # end
+ def extension_white_list
+ %w(tar.gz)
+ end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
diff --git a/app/views/backup_jobs/show.html.haml b/app/views/backup_jobs/show.html.haml
index 6fcb1dc..ddc4766 100644
--- a/app/views/backup_jobs/show.html.haml
+++ b/app/views/backup_jobs/show.html.haml
@@ -1,22 +1,34 @@
- content_for :title, t("backup_jobs.show.page_title")
-%p
- %strong= t('backup_jobs.show.started_at') + ":"
- = @backup_job.started_at
-%p
- %strong= t('backup_jobs.show.finished_at') + ":"
- = @backup_job.finished_at
-%p
- %strong= t('backup_jobs.show.state') + ":"
- = @backup_job.state
-%p
- %strong= t('backup_jobs.show.directory') + ":"
- = @backup_job.directory
-%p
- %strong= t('backup_jobs.show.size_of_the_backup') + ":"
- - if @backup_job.backup_file?
- %a{:href => backup_job.backup_file.url}
- %i{:class => 'icon-download'}
- = number_to_human_size(backup_job.backup_file.size, :precision => 2)
+%table.table.table-striped
+ %tbody
+ %tr
+ %td
+ %strong= t('backup_jobs.show.started_at') + ":"
+ %td
+ = @backup_job.started_at
+ %tr
+ %td
+ %strong= t('backup_jobs.show.finished_at') + ":"
+ %td
+ = @backup_job.finished_at
+ %tr
+ %td
+ %strong= t('backup_jobs.show.state') + ":"
+ %td
+ = @backup_job.state
+ %tr
+ %td
+ %strong= t('backup_jobs.show.directory') + ":"
+ %td
+ = @backup_job.directory
+ %tr
+ %td
+ %strong= t('backup_jobs.show.size_of_the_backup') + ":"
+ %td
+ - if @backup_job.backup_file?
+ %a{:href => backup_job.backup_file.url}
+ %i{:class => 'icon-download'}
+ = number_to_human_size(backup_job.backup_file.size, :precision => 2)
= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @backup_job } \ No newline at end of file
diff --git a/app/views/restore_jobs/_form.html.haml b/app/views/restore_jobs/_form.html.haml
new file mode 100644
index 0000000..43ced9a
--- /dev/null
+++ b/app/views/restore_jobs/_form.html.haml
@@ -0,0 +1,7 @@
+= simple_form_for(@restore_job) do |f|
+ = f.error_notification
+
+ = render "form_core", :f => f
+
+ .form-actions
+ = f.button :submit, conditional_t('restore_jobs.form.submit')
diff --git a/app/views/restore_jobs/_form_core.html.haml b/app/views/restore_jobs/_form_core.html.haml
new file mode 100644
index 0000000..017c124
--- /dev/null
+++ b/app/views/restore_jobs/_form_core.html.haml
@@ -0,0 +1,2 @@
+.inputs
+ = f.input :backup_file, :label => t('restore_jobs.form.backup_file.label'), :hint => conditional_hint('restore_jobs.form.backup_file.hint')
diff --git a/app/views/restore_jobs/_index_core.html.haml b/app/views/restore_jobs/_index_core.html.haml
new file mode 100644
index 0000000..f6127ba
--- /dev/null
+++ b/app/views/restore_jobs/_index_core.html.haml
@@ -0,0 +1,12 @@
+%table.table.table-striped
+ %tr
+ %th= t('restore_jobs.index.state')
+ %th= t('restore_jobs.index.backup_file')
+ %th
+
+
+ - for restore_job in restore_jobs
+ %tr
+ %td= restore_job.state
+ %td= restore_job.to_s
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => restore_job} \ No newline at end of file
diff --git a/app/views/restore_jobs/index.html.haml b/app/views/restore_jobs/index.html.haml
new file mode 100644
index 0000000..b8aa74e
--- /dev/null
+++ b/app/views/restore_jobs/index.html.haml
@@ -0,0 +1,6 @@
+- content_for :title, t("restore_jobs.index.page_title")
+
+- if @restore_jobs && @restore_jobs.count > 0
+ = render "index_core", :restore_jobs => @restore_jobs
+
+= render :partial => 'shared/create_link', :locals => {:child_class => RestoreJob} \ No newline at end of file
diff --git a/app/views/restore_jobs/new.html.haml b/app/views/restore_jobs/new.html.haml
new file mode 100644
index 0000000..ffae792
--- /dev/null
+++ b/app/views/restore_jobs/new.html.haml
@@ -0,0 +1,3 @@
+- content_for :title, t("restore_jobs.new.page_title")
+
+= render "form" \ No newline at end of file
diff --git a/app/views/restore_jobs/show.html.haml b/app/views/restore_jobs/show.html.haml
new file mode 100644
index 0000000..5993872
--- /dev/null
+++ b/app/views/restore_jobs/show.html.haml
@@ -0,0 +1,22 @@
+- content_for :title, t("restore_jobs.show.page_title")
+
+%table.table.table-striped
+ %tbody
+ %tr
+ %td
+ %strong= t('restore_jobs.show.state') + ":"
+ %td
+ = @restore_job.state
+ %tr
+ %td
+ %strong= t('restore_jobs.show.backup_file') + ":"
+ %td
+ = @restore_job.to_s
+ %tr
+ %td
+ %strong= t('backup_jobs.show.size_of_the_backup') + ":"
+ %td
+ - if @restore_job.backup_file?
+ = number_to_human_size(@restore_job.backup_file.size, :precision => 2)
+
+= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @restore_job } \ No newline at end of file