summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 12:41:07 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-05 12:41:07 +0100
commit1c2d8375d32cda0d7819322b165a8270c6500ee9 (patch)
tree8804da99d69819b2d4253e827230f459c0ebac1c
parente13f041741fd3a44f407b623da0274d9748c5c54 (diff)
parentbb8168c33f9501fe877345a7bbc7b7f7b64cdfc7 (diff)
Merge branch 'backup' into develop
-rw-r--r--app/controllers/backup_jobs_controller.rb43
-rw-r--r--app/helpers/backup_jobs_helper.rb2
-rw-r--r--app/models/backup_job.rb14
-rw-r--r--app/views/backup_jobs/_form.html.haml7
-rw-r--r--app/views/backup_jobs/_form_core.html.haml6
-rw-r--r--app/views/backup_jobs/_index_core.html.haml17
-rw-r--r--app/views/backup_jobs/edit.html.haml3
-rw-r--r--app/views/backup_jobs/index.html.haml6
-rw-r--r--app/views/backup_jobs/new.html.haml3
-rw-r--r--app/views/backup_jobs/show.html.haml19
-rw-r--r--config/backup.rb12
-rw-r--r--config/locales/views/backup_jobs/de.yml60
-rw-r--r--config/locales/views/backup_jobs/en.yml60
-rw-r--r--config/routes.rb2
-rw-r--r--db/migrate/20130205102838_create_backup_jobs.rb16
-rw-r--r--test/functional/backup_jobs_controller_test.rb49
-rw-r--r--test/unit/backup_job_test.rb7
17 files changed, 320 insertions, 6 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
diff --git a/config/backup.rb b/config/backup.rb
index c3da9bc..4e5cbf2 100644
--- a/config/backup.rb
+++ b/config/backup.rb
@@ -29,10 +29,10 @@ Backup::Model.new(:gs5, 'GS5 backup') do
##
# Faxes
#
- archive :faxes do |archive|
- archive.add '/opt/gemeinschaft/public/uploads/fax_document/'
- archive.add '/opt/gemeinschaft/public/uploads/fax_thumbnail/'
- end
+ #archive :faxes do |archive|
+ # archive.add '/opt/gemeinschaft/public/uploads/fax_document/'
+ # archive.add '/opt/gemeinschaft/public/uploads/fax_thumbnail/'
+ #end
##
# Voicemails
@@ -45,8 +45,8 @@ Backup::Model.new(:gs5, 'GS5 backup') do
# Local (Copy) [Storage]
#
store_with Local do |local|
- local.path = "/var/backups/"
- local.keep = 5
+ local.path = "/var/backups/GS5/"
+ local.keep = 3
end
##
diff --git a/config/locales/views/backup_jobs/de.yml b/config/locales/views/backup_jobs/de.yml
new file mode 100644
index 0000000..b81b532
--- /dev/null
+++ b/config/locales/views/backup_jobs/de.yml
@@ -0,0 +1,60 @@
+de:
+ backup_jobs:
+ name: 'Backup job'
+ controller:
+ successfuly_created: 'Backup job wurde angelegt.'
+ successfuly_updated: 'Backup job wurde aktualisiert.'
+ successfuly_destroyed: 'Backup job wurde gelöscht.'
+ index:
+ page_title: 'Übersicht von Backup job'
+ started_at: 'Started at'
+ finished_at: 'Finished at'
+ state: 'State'
+ directory: 'Directory'
+ size_of_the_backup: 'Size of the backup'
+ actions:
+ confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Backup job'
+ destroy: 'Löschen'
+ edit: 'Bearbeiten'
+ show: 'Anzeigen'
+ create: 'Neu anlegen'
+ create_for: 'Backup job neu anlegen für %{resource}'
+ show:
+ page_title: 'Backup job bearbeiten'
+ started_at: 'Started at'
+ finished_at: 'Finished at'
+ state: 'State'
+ directory: 'Directory'
+ size_of_the_backup: 'Size of the backup'
+ actions:
+ confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?'
+ destroy: 'Löschen'
+ edit: 'Bearbeiten'
+ view_all: 'Alle anzeigen'
+ new:
+ page_title: 'Backup job neu anlegen'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit:
+ page_title: 'Backup job bearbeiten'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit: 'Bearbeiten'
+ view_all: 'Alle anzeigen'
+ form:
+ started_at:
+ label: 'Started at'
+ hint: ''
+ finished_at:
+ label: 'Finished at'
+ hint: ''
+ state:
+ label: 'State'
+ hint: ''
+ directory:
+ label: 'Directory'
+ hint: ''
+ size_of_the_backup:
+ label: 'Size of the backup'
+ hint: ''
+ submit: 'Absenden' \ No newline at end of file
diff --git a/config/locales/views/backup_jobs/en.yml b/config/locales/views/backup_jobs/en.yml
new file mode 100644
index 0000000..83f4388
--- /dev/null
+++ b/config/locales/views/backup_jobs/en.yml
@@ -0,0 +1,60 @@
+en:
+ backup_jobs:
+ name: 'Backup job'
+ controller:
+ successfuly_created: 'Successfully created Backup job.'
+ successfuly_updated: 'Successfully updated Backup job.'
+ successfuly_destroyed: 'Successfully destroyed Backup job.'
+ index:
+ page_title: 'Listing Backup job'
+ started_at: 'Started at'
+ finished_at: 'Finished at'
+ state: 'State'
+ directory: 'Directory'
+ size_of_the_backup: 'Size of the backup'
+ actions:
+ confirm_destroy: 'Are you sure you want to delete this Backup job?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ show: 'View'
+ create: 'New'
+ create_for: 'New Backup job for %{resource}'
+ show:
+ page_title: 'Show Backup job'
+ started_at: 'Started at'
+ finished_at: 'Finished at'
+ state: 'State'
+ directory: 'Directory'
+ size_of_the_backup: 'Size of the backup'
+ actions:
+ confirm_destroy: 'Are you sure you want to delete this element?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ view_all: 'View All'
+ new:
+ page_title: 'New Backup job'
+ actions:
+ back_to_list: 'Back to Index'
+ edit:
+ page_title: 'Editing Backup job'
+ actions:
+ back_to_list: 'Back to Index'
+ edit: 'Edit'
+ view_all: 'View All'
+ form:
+ started_at:
+ label: 'Started at'
+ hint: ''
+ finished_at:
+ label: 'Finished at'
+ hint: ''
+ state:
+ label: 'State'
+ hint: ''
+ directory:
+ label: 'Directory'
+ hint: ''
+ size_of_the_backup:
+ label: 'Size of the backup'
+ hint: ''
+ submit: 'Submit' \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index fbb32f6..3c3928f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,7 @@
Gemeinschaft42c::Application.routes.draw do
+ resources :backup_jobs, :except => [:edit, :update]
+
scope :constraints => lambda{|req|%w(127.0.0.1).include? req.remote_addr} do
get "trigger/voicemail"
get "trigger/fax"
diff --git a/db/migrate/20130205102838_create_backup_jobs.rb b/db/migrate/20130205102838_create_backup_jobs.rb
new file mode 100644
index 0000000..0d71421
--- /dev/null
+++ b/db/migrate/20130205102838_create_backup_jobs.rb
@@ -0,0 +1,16 @@
+class CreateBackupJobs < ActiveRecord::Migration
+ def self.up
+ create_table :backup_jobs do |t|
+ t.datetime :started_at
+ t.datetime :finished_at
+ t.string :state
+ t.string :directory
+ t.string :size_of_the_backup
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :backup_jobs
+ end
+end
diff --git a/test/functional/backup_jobs_controller_test.rb b/test/functional/backup_jobs_controller_test.rb
new file mode 100644
index 0000000..17a0caf
--- /dev/null
+++ b/test/functional/backup_jobs_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class BackupJobsControllerTest < ActionController::TestCase
+ setup do
+ @backup_job = backup_jobs(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:backup_jobs)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create backup_job" do
+ assert_difference('BackupJob.count') do
+ post :create, backup_job: @backup_job.attributes
+ end
+
+ assert_redirected_to backup_job_path(assigns(:backup_job))
+ end
+
+ test "should show backup_job" do
+ get :show, id: @backup_job.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @backup_job.to_param
+ assert_response :success
+ end
+
+ test "should update backup_job" do
+ put :update, id: @backup_job.to_param, backup_job: @backup_job.attributes
+ assert_redirected_to backup_job_path(assigns(:backup_job))
+ end
+
+ test "should destroy backup_job" do
+ assert_difference('BackupJob.count', -1) do
+ delete :destroy, id: @backup_job.to_param
+ end
+
+ assert_redirected_to backup_jobs_path
+ end
+end
diff --git a/test/unit/backup_job_test.rb b/test/unit/backup_job_test.rb
new file mode 100644
index 0000000..a63c219
--- /dev/null
+++ b/test/unit/backup_job_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class BackupJobTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert BackupJob.new.valid?
+ end
+end