active_admin_paranoia 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2de9b380c61b06c7d5fae83324238ab7c0dc3221
4
+ data.tar.gz: fd675d9ae5beb4d75e0c15867d283baa1e6675b3
5
+ SHA512:
6
+ metadata.gz: e136677207878aae8b5d5018235a327e969377e419dd9a78bf4b2a74b0901880bece6d9fb3b3b87e905b37057fd840ba5d48bd28581a224e92031d2ac563d5e9
7
+ data.tar.gz: 14a0c898fe8bd7193a487fbf90c55ba1bc58fbe2f84fff1b2cb153ac2fbe1183964a769a0ba1a8c59c36482802861a8149d79501b5fc6fabc8b690fb2505871c
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ /.idea
37
+ /.ruby-version
38
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in active_admin_paranoiaable.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Miah Raihan Mahmud Arman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # active_admin_paranoia
2
+ This gem extends ActiveAdmin so that batch restore and batch archive actions will be available in resource index page. Also 'All' and 'Archived' scope will be available for resource index page. 'All' scope will show non archived resources and 'Archived' scope will show deleted or archived resources.
3
+
4
+ # Installation
5
+ This gem assumes that you have already configured [paranoia](https://github.com/radar/paranoia) for you desire resource. Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem "active_admin_paranoia" , '~> 1.0.0'
9
+
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ # Usages
17
+
18
+ ```ruby
19
+ ActiveAdmin.register Post do
20
+ active_admin_paranoia
21
+ end
22
+ ```
@@ -0,0 +1,7 @@
1
+ require "bundler"
2
+ require 'rake'
3
+ Bundler.setup
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ # Import all our rake tasks
7
+ FileList['tasks/**/*.rake'].each { |task| import task }
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/active_admin_paranoia/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'active_admin_paranoia'
6
+ gem.version = ActiveAdminParanoia::VERSION
7
+ gem.license = 'MIT'
8
+ gem.authors = ['Miah Raihan Mahmud Arman']
9
+ gem.email = ['raihan2006i@gmail.com']
10
+ gem.description = %q{This gem extends ActiveAdmin so that batch restore and batch archive actions will be available in resource index page. Also 'All' and 'Archived' scope will be available for resource index page. 'All' scope will show non archived resources and 'Archived' scope will show deleted or archived resources.}
11
+ gem.summary = %q{Paranoia extension for ActiveAdmin}
12
+ gem.homepage = 'https://github.com/raihan2006i/active_admin_paranoia'
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = %w(lib)
18
+
19
+ gem.add_dependency 'rails', '~> 4.0'
20
+ gem.add_dependency 'paranoia', '~> 1.0'
21
+ end
@@ -0,0 +1,20 @@
1
+ en:
2
+ active_admin:
3
+ delete_model: "Archive %{model}"
4
+ delete: "Archive"
5
+ delete_confirmation: "Are you sure you want to archive this?"
6
+ batch_actions:
7
+ delete_confirmation: "Are you sure you want to archive these %{plural_model}?"
8
+ succesfully_destroyed:
9
+ one: "Successfully archived 1 %{model}"
10
+ other: "Successfully archived %{count} %{plural_model}"
11
+ labels:
12
+ destroy: "Archive"
13
+ active_admin_paranoia:
14
+ batch_actions:
15
+ restore_confirmation: "Are you sure you want to restore these %{plural_model}?"
16
+ succesfully_restored:
17
+ one: "Successfully restored 1 %{model}"
18
+ other: "Successfully restored %{count} %{plural_model}"
19
+ archived: "Archived"
20
+ something_wrong: "Something went wrong. Please try again"
@@ -0,0 +1,6 @@
1
+ require 'active_admin'
2
+ require 'active_admin_paranoia/version'
3
+ require 'active_admin_paranoia/engine'
4
+ require 'active_admin_paranoia/dsl'
5
+ require 'active_admin_paranoia/authorization'
6
+ ::ActiveAdmin::DSL.send(:include, ActiveAdminParanoia::DSL)
@@ -0,0 +1,9 @@
1
+ module ActiveAdminParanoia
2
+ # Default Authorization permission for ActiveAdminParanoia
3
+ module Authorization
4
+ RESTORE = :restore
5
+ PERMANENT_DELETE = :permanent_delete
6
+ end
7
+
8
+ Auth = Authorization
9
+ end
@@ -0,0 +1,34 @@
1
+ module ActiveAdminParanoia
2
+ module DSL
3
+ def active_admin_paranoia
4
+ controller do
5
+ def find_resource
6
+ resource_class.to_s.camelize.constantize.unscoped.where(id: params[:id]).first!
7
+ end
8
+
9
+ def action_methods
10
+ if params[:scope].present? && params[:scope] == 'archived'
11
+ %w(index)
12
+ else
13
+ super
14
+ end
15
+ end
16
+ end
17
+
18
+ batch_action :destroy, confirm: proc{ I18n.t('active_admin.batch_actions.delete_confirmation', plural_model: resource_class.to_s.downcase.pluralize) }, if: proc{ authorized?(ActiveAdmin::Auth::DESTROY, resource_class) && params[:scope].present? && params[:scope] != 'archived' } do |ids|
19
+ resource_class.to_s.camelize.constantize.where(id: ids).destroy_all
20
+ redirect_to :back, notice: I18n.t('active_admin.batch_actions.succesfully_destroyed', count: ids.count, model: resource_class.to_s.camelize.constantize.model_name, plural_model: resource_class.to_s.downcase.pluralize)
21
+ end
22
+
23
+ batch_action :restore, confirm: proc{ I18n.t('active_admin_paranoia.batch_actions.restore_confirmation', plural_model: resource_class.to_s.downcase.pluralize) }, if: proc{ authorized?(ActiveAdminParanoia::Auth::RESTORE, resource_class) && params[:scope].present? && params[:scope] == 'archived' } do |ids|
24
+ ids.each do |id|
25
+ resource_class.to_s.camelize.constantize.restore(id)
26
+ end
27
+ redirect_to :back, notice: I18n.t('active_admin_paranoia.batch_actions.succesfully_restored', count: ids.count, model: resource_class.to_s.camelize.constantize.model_name, plural_model: resource_class.to_s.downcase.pluralize)
28
+ end
29
+
30
+ scope :all, default: true
31
+ scope(I18n.t('active_admin_paranoia.archived')) { |scope| scope.unscoped.where.not(resource_class.to_s.camelize.constantize.paranoia_column => resource_class.to_s.camelize.constantize.paranoia_sentinel_value) }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails'
2
+
3
+ module ActiveAdminParanoia
4
+ class Engine < ::Rails::Engine
5
+
6
+ config.mount_at = '/'
7
+
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveAdminParanoia
2
+ VERSION = '1.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_admin_paranoia
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Miah Raihan Mahmud Arman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: paranoia
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: This gem extends ActiveAdmin so that batch restore and batch archive
42
+ actions will be available in resource index page. Also 'All' and 'Archived' scope
43
+ will be available for resource index page. 'All' scope will show non archived resources
44
+ and 'Archived' scope will show deleted or archived resources.
45
+ email:
46
+ - raihan2006i@gmail.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - active_admin_paranoia.gemspec
57
+ - config/locales/en.yml
58
+ - lib/active_admin_paranoia.rb
59
+ - lib/active_admin_paranoia/authorization.rb
60
+ - lib/active_admin_paranoia/dsl.rb
61
+ - lib/active_admin_paranoia/engine.rb
62
+ - lib/active_admin_paranoia/version.rb
63
+ homepage: https://github.com/raihan2006i/active_admin_paranoia
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Paranoia extension for ActiveAdmin
87
+ test_files: []