summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Pawlowski <julian.pawlowski@gmail.com>2013-02-26 11:30:52 +0100
committerJulian Pawlowski <julian.pawlowski@gmail.com>2013-02-26 11:30:52 +0100
commit7c7b788d0d1aa1abe63b3506c4ced555de157fd5 (patch)
treeb19e0056c97eccb910dd8c3c7df9ce76c0c2e47a
parent6c2ba1352010ef4c63b2dad1e90ab8b4366b0195 (diff)
parentececfdf24075dd4e2794734a07187750b1b33e13 (diff)
Merge branches 'develop' and 'develop' of https://github.com/amooma/GS5 into develop
-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
-rw-r--r--config/locales/views/restore_jobs/de.yml45
-rw-r--r--config/locales/views/restore_jobs/en.yml45
-rw-r--r--config/routes.rb2
-rw-r--r--db/migrate/20130225160423_create_restore_jobs.rb13
-rw-r--r--db/schema.rb33
-rw-r--r--test/functional/restore_jobs_controller_test.rb49
-rw-r--r--test/unit/restore_job_test.rb7
19 files changed, 318 insertions, 22 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
diff --git a/config/locales/views/restore_jobs/de.yml b/config/locales/views/restore_jobs/de.yml
new file mode 100644
index 0000000..18ee349
--- /dev/null
+++ b/config/locales/views/restore_jobs/de.yml
@@ -0,0 +1,45 @@
+de:
+ restore_jobs:
+ name: 'Restore Auftrag'
+ controller:
+ successfuly_created: 'Restore Auftrag wurde angelegt.'
+ successfuly_updated: 'Restore Auftrag wurde aktualisiert.'
+ successfuly_destroyed: 'Restore Auftrag wurde gelöscht.'
+ index:
+ page_title: 'Liste Restore Aufträge'
+ state: 'Status'
+ backup_file: 'Backup Datei'
+ actions:
+ confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Restore Auftrag'
+ destroy: 'Löschen'
+ edit: 'Bearbeiten'
+ show: 'Anzeigen'
+ create: 'Neu anlegen'
+ create_for: 'Restore Auftrag neu anlegen für %{resource}'
+ show:
+ page_title: 'Restore Auftrag bearbeiten'
+ state: 'Status'
+ backup_file: 'Backup Datei'
+ 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: 'Restore Auftrag neu anlegen'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit:
+ page_title: 'Restore Auftrag bearbeiten'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit: 'Bearbeiten'
+ view_all: 'Alle anzeigen'
+ form:
+ state:
+ label: 'Status'
+ hint: ''
+ backup_file:
+ label: 'Backup Datei'
+ hint: ''
+ submit: 'Absenden' \ No newline at end of file
diff --git a/config/locales/views/restore_jobs/en.yml b/config/locales/views/restore_jobs/en.yml
new file mode 100644
index 0000000..d75de95
--- /dev/null
+++ b/config/locales/views/restore_jobs/en.yml
@@ -0,0 +1,45 @@
+en:
+ restore_jobs:
+ name: 'Restorejob'
+ controller:
+ successfuly_created: 'Successfully created Restorejob.'
+ successfuly_updated: 'Successfully updated Restorejob.'
+ successfuly_destroyed: 'Successfully destroyed Restorejob.'
+ index:
+ page_title: 'Listing Restorejob'
+ state: 'State'
+ backup_file: 'Backup file'
+ actions:
+ confirm_destroy: 'Are you sure you want to delete this Restorejob?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ show: 'View'
+ create: 'New'
+ create_for: 'New Restorejob for %{resource}'
+ show:
+ page_title: 'Show Restorejob'
+ state: 'State'
+ backup_file: 'Backup file'
+ actions:
+ confirm_destroy: 'Are you sure you want to delete this element?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ view_all: 'View All'
+ new:
+ page_title: 'New Restorejob'
+ actions:
+ back_to_list: 'Back to Index'
+ edit:
+ page_title: 'Editing Restorejob'
+ actions:
+ back_to_list: 'Back to Index'
+ edit: 'Edit'
+ view_all: 'View All'
+ form:
+ state:
+ label: 'State'
+ hint: ''
+ backup_file:
+ label: 'Backup file'
+ hint: ''
+ submit: 'Submit' \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index b6943ab..87c9c66 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,7 @@
Gemeinschaft42c::Application.routes.draw do
+ resources :restore_jobs
+
resources :groups do
resources :group_memberships
resources :group_permissions
diff --git a/db/migrate/20130225160423_create_restore_jobs.rb b/db/migrate/20130225160423_create_restore_jobs.rb
new file mode 100644
index 0000000..9f83791
--- /dev/null
+++ b/db/migrate/20130225160423_create_restore_jobs.rb
@@ -0,0 +1,13 @@
+class CreateRestoreJobs < ActiveRecord::Migration
+ def self.up
+ create_table :restore_jobs do |t|
+ t.string :state
+ t.string :backup_file
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :restore_jobs
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index df55604..60bc7f5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130215133749) do
+ActiveRecord::Schema.define(:version => 20130225160423) do
create_table "access_authorizations", :force => true do |t|
t.string "access_authorizationable_type"
@@ -554,6 +554,30 @@ ActiveRecord::Schema.define(:version => 20130215133749) do
t.string "trunk_access_code"
end
+ create_table "group_memberships", :force => true do |t|
+ t.integer "group_id"
+ t.string "item_type"
+ t.integer "item_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "group_permissions", :force => true do |t|
+ t.integer "group_id"
+ t.string "permission"
+ t.integer "target_group_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "groups", :force => true do |t|
+ t.string "name"
+ t.boolean "active"
+ t.string "comment"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "gs_cluster_sync_log_entries", :force => true do |t|
t.integer "gs_node_id"
t.string "class_name"
@@ -854,6 +878,13 @@ ActiveRecord::Schema.define(:version => 20130215133749) do
add_index "registrations", ["reg_user", "realm", "hostname"], :name => "regindex1"
+ create_table "restore_jobs", :force => true do |t|
+ t.string "state"
+ t.string "backup_file"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "ringtones", :force => true do |t|
t.string "ringtoneable_type"
t.integer "ringtoneable_id"
diff --git a/test/functional/restore_jobs_controller_test.rb b/test/functional/restore_jobs_controller_test.rb
new file mode 100644
index 0000000..bd06b25
--- /dev/null
+++ b/test/functional/restore_jobs_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class RestoreJobsControllerTest < ActionController::TestCase
+ setup do
+ @restore_job = restore_jobs(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:restore_jobs)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create restore_job" do
+ assert_difference('RestoreJob.count') do
+ post :create, restore_job: @restore_job.attributes
+ end
+
+ assert_redirected_to restore_job_path(assigns(:restore_job))
+ end
+
+ test "should show restore_job" do
+ get :show, id: @restore_job.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @restore_job.to_param
+ assert_response :success
+ end
+
+ test "should update restore_job" do
+ put :update, id: @restore_job.to_param, restore_job: @restore_job.attributes
+ assert_redirected_to restore_job_path(assigns(:restore_job))
+ end
+
+ test "should destroy restore_job" do
+ assert_difference('RestoreJob.count', -1) do
+ delete :destroy, id: @restore_job.to_param
+ end
+
+ assert_redirected_to restore_jobs_path
+ end
+end
diff --git a/test/unit/restore_job_test.rb b/test/unit/restore_job_test.rb
new file mode 100644
index 0000000..ce69ced
--- /dev/null
+++ b/test/unit/restore_job_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RestoreJobTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert RestoreJob.new.valid?
+ end
+end