diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-05 12:40:42 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-05 12:40:42 +0100 |
commit | bb8168c33f9501fe877345a7bbc7b7f7b64cdfc7 (patch) | |
tree | 8804da99d69819b2d4253e827230f459c0ebac1c /app | |
parent | e13f041741fd3a44f407b623da0274d9748c5c54 (diff) |
Added a BackupJob scaffold.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/backup_jobs_controller.rb | 43 | ||||
-rw-r--r-- | app/helpers/backup_jobs_helper.rb | 2 | ||||
-rw-r--r-- | app/models/backup_job.rb | 14 | ||||
-rw-r--r-- | app/views/backup_jobs/_form.html.haml | 7 | ||||
-rw-r--r-- | app/views/backup_jobs/_form_core.html.haml | 6 | ||||
-rw-r--r-- | app/views/backup_jobs/_index_core.html.haml | 17 | ||||
-rw-r--r-- | app/views/backup_jobs/edit.html.haml | 3 | ||||
-rw-r--r-- | app/views/backup_jobs/index.html.haml | 6 | ||||
-rw-r--r-- | app/views/backup_jobs/new.html.haml | 3 | ||||
-rw-r--r-- | app/views/backup_jobs/show.html.haml | 19 |
10 files changed, 120 insertions, 0 deletions
diff --git a/app/controllers/backup_jobs_controller.rb b/app/controllers/backup_jobs_controller.rb new file mode 100644 index 0000000..e500f4c --- /dev/null +++ b/app/controllers/backup_jobs_controller.rb @@ -0,0 +1,43 @@ +class BackupJobsController < ApplicationController + def index + @backup_jobs = BackupJob.all + end + + def show + @backup_job = BackupJob.find(params[:id]) + end + + def new + @backup_job = BackupJob.new + end + + def create +# @backup_job = BackupJob.new(params[:backup_job]) + @backup_job = BackupJob.new(:started_at => Time.now) + + if @backup_job.save + redirect_to @backup_job, :notice => t('backup_jobs.controller.successfuly_created') + else + render :new + end + end + + # def edit + # @backup_job = BackupJob.find(params[:id]) + # end + + # def update + # @backup_job = BackupJob.find(params[:id]) + # if @backup_job.update_attributes(params[:backup_job]) + # redirect_to @backup_job, :notice => t('backup_jobs.controller.successfuly_updated') + # else + # render :edit + # end + # end + + def destroy + @backup_job = BackupJob.find(params[:id]) + @backup_job.destroy + redirect_to backup_jobs_url, :notice => t('backup_jobs.controller.successfuly_destroyed') + end +end diff --git a/app/helpers/backup_jobs_helper.rb b/app/helpers/backup_jobs_helper.rb new file mode 100644 index 0000000..06d8b9b --- /dev/null +++ b/app/helpers/backup_jobs_helper.rb @@ -0,0 +1,2 @@ +module BackupJobsHelper +end diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb new file mode 100644 index 0000000..d579b79 --- /dev/null +++ b/app/models/backup_job.rb @@ -0,0 +1,14 @@ +class BackupJob < ActiveRecord::Base + attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup + + after_save :start_the_backup + + private + def start_the_backup + if self.finished_at.nil? + sh "backup perform --trigger gs5 --config_file #{Rails.root.join('config','backup.rb')}" + self.finished_at = Time.now + self.save + end + end +end diff --git a/app/views/backup_jobs/_form.html.haml b/app/views/backup_jobs/_form.html.haml new file mode 100644 index 0000000..e0adceb --- /dev/null +++ b/app/views/backup_jobs/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@backup_job) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('backup_jobs.form.submit')
\ No newline at end of file diff --git a/app/views/backup_jobs/_form_core.html.haml b/app/views/backup_jobs/_form_core.html.haml new file mode 100644 index 0000000..536fb18 --- /dev/null +++ b/app/views/backup_jobs/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :started_at, :label => t('backup_jobs.form.started_at.label'), :hint => conditional_hint('backup_jobs.form.started_at.hint') + = f.input :finished_at, :label => t('backup_jobs.form.finished_at.label'), :hint => conditional_hint('backup_jobs.form.finished_at.hint') + = f.input :state, :label => t('backup_jobs.form.state.label'), :hint => conditional_hint('backup_jobs.form.state.hint') + = f.input :directory, :label => t('backup_jobs.form.directory.label'), :hint => conditional_hint('backup_jobs.form.directory.hint') + = f.input :size_of_the_backup, :label => t('backup_jobs.form.size_of_the_backup.label'), :hint => conditional_hint('backup_jobs.form.size_of_the_backup.hint') diff --git a/app/views/backup_jobs/_index_core.html.haml b/app/views/backup_jobs/_index_core.html.haml new file mode 100644 index 0000000..6babf3e --- /dev/null +++ b/app/views/backup_jobs/_index_core.html.haml @@ -0,0 +1,17 @@ +%table.table.table-striped + %tr + %th= t('backup_jobs.index.started_at') + %th= t('backup_jobs.index.finished_at') + %th= t('backup_jobs.index.state') + %th= t('backup_jobs.index.directory') + %th= t('backup_jobs.index.size_of_the_backup') + + + - for backup_job in backup_jobs + %tr + %td= backup_job.started_at + %td= backup_job.finished_at + %td= backup_job.state + %td= backup_job.directory + %td= backup_job.size_of_the_backup + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => backup_job}
\ No newline at end of file diff --git a/app/views/backup_jobs/edit.html.haml b/app/views/backup_jobs/edit.html.haml new file mode 100644 index 0000000..7892edb --- /dev/null +++ b/app/views/backup_jobs/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("backup_jobs.edit.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/backup_jobs/index.html.haml b/app/views/backup_jobs/index.html.haml new file mode 100644 index 0000000..0bb4747 --- /dev/null +++ b/app/views/backup_jobs/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("backup_jobs.index.page_title") + +- if @backup_jobs && @backup_jobs.count > 0 + = render "index_core", :backup_jobs => @backup_jobs + += render :partial => 'shared/create_link', :locals => {:child_class => BackupJob}
\ No newline at end of file diff --git a/app/views/backup_jobs/new.html.haml b/app/views/backup_jobs/new.html.haml new file mode 100644 index 0000000..65efd4f --- /dev/null +++ b/app/views/backup_jobs/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("backup_jobs.new.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/backup_jobs/show.html.haml b/app/views/backup_jobs/show.html.haml new file mode 100644 index 0000000..7f021bb --- /dev/null +++ b/app/views/backup_jobs/show.html.haml @@ -0,0 +1,19 @@ +- 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') + ":" + = @backup_job.size_of_the_backup + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @backup_job }
\ No newline at end of file |