rails_admin_invite 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +21 -0
- data/Rakefile +27 -0
- data/app/views/rails_admin/main/invite.html.haml +3 -0
- data/config/locales/invite.en.yml +11 -0
- data/lib/rails_admin_invite.rb +60 -0
- data/lib/rails_admin_invite/engine.rb +4 -0
- data/lib/rails_admin_invite/version.rb +3 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 456f12b9b3ba85c81ecb40ce792296a90976afb0
|
4
|
+
data.tar.gz: dda9ac1faa5221281a3bd2db47c22050c73a6411
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ce7bd8d44152102f884990a8374a22146050f1e83503327bdc26d66415e6f418fd22ad09cdbd8f12424889ed5cb31413b79684df93c1baf449a8577c1964ffa
|
7
|
+
data.tar.gz: b98a0bf36f2db8251fa832a4260b98a3240901b71333091df84999759f94c42490d6b30d337fb931afaa2ae853ce8e2d78620f6fbbc188931635aaffaeacf2c0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# RailsAdminInvite
|
2
|
+
|
3
|
+
This gem is for use with RailsAdmin and Devise Invitable. I wanted to be able to invite Admin
|
4
|
+
from the Rails Admin backend, having them confirm their account on the app's front end. This is
|
5
|
+
a quick and dirty way to accomplish that.
|
6
|
+
|
7
|
+
It will add an "Invite <model name>" tab on the collection view of a Rails Admin resource that
|
8
|
+
is configured to use Devise Invitable.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add the following to your `Gemfile`
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'rails_admin_invite', :git => 'git@github.com:tonywok/rails_admin_invite.git'
|
16
|
+
```
|
17
|
+
|
18
|
+
## TODO
|
19
|
+
|
20
|
+
- Look into RailsAdmin I18n convention
|
21
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RailsAdminInvite'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,3 @@
|
|
1
|
+
= rails_admin_form_for @object, :url => invite_path(:model_name => @abstract_model.to_param, :id => @object.id), :as => @abstract_model.param_key, :html => { :multipart => true, :class => "form-horizontal denser", :data => { :title => @page_name } } do |form|
|
2
|
+
= form.generate :action => :create
|
3
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "rails_admin_invite/engine"
|
2
|
+
|
3
|
+
module RailsAdminInvite
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'rails_admin/config/actions'
|
7
|
+
|
8
|
+
module RailsAdmin
|
9
|
+
module Config
|
10
|
+
module Actions
|
11
|
+
class Invite < New
|
12
|
+
RailsAdmin::Config::Actions.register(self)
|
13
|
+
|
14
|
+
register_instance_option :visible? do
|
15
|
+
return false unless authorized?
|
16
|
+
|
17
|
+
invitable_models = Devise.mappings.map do |scope, mapping|
|
18
|
+
mapping.class_name if mapping.modules.include?(:invitable)
|
19
|
+
end.compact
|
20
|
+
|
21
|
+
invitable_models.include?(bindings[:abstract_model].to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
register_instance_option :controller do
|
25
|
+
Proc.new do
|
26
|
+
if request.get?
|
27
|
+
@object = @abstract_model.new
|
28
|
+
@authorization_adapter && @authorization_adapter.attributes_for(:new, @abstract_model).each do |name, value|
|
29
|
+
@object.send("#{name}=", value)
|
30
|
+
end
|
31
|
+
if object_params = params[@abstract_model.to_param]
|
32
|
+
@object.set_attributes(@object.attributes.merge(object_params), _attr_accessible_role)
|
33
|
+
end
|
34
|
+
respond_to do |format|
|
35
|
+
format.html { render @action.template_name }
|
36
|
+
format.js { render @action.template_name, :layout => false }
|
37
|
+
end
|
38
|
+
elsif request.post?
|
39
|
+
satisfy_strong_params!
|
40
|
+
sanitize_params_for!(request.xhr? ? :model : :create)
|
41
|
+
|
42
|
+
@object = @abstract_model.model.invite!(params[@abstract_model.to_param], _current_user)
|
43
|
+
if @object.errors.empty?
|
44
|
+
notice = I18n.t("admin.actions.invite.sent", email: @object.email)
|
45
|
+
if params[:return_to]
|
46
|
+
redirect_to(params[:return_to], notice: notice)
|
47
|
+
else
|
48
|
+
redirect_to(invite_path(:model_name => @abstract_model.to_param), notice: notice)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
handle_save_error :whereto => :invite
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_admin_invite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tony Schneider
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-23 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: 3.2.11
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails_admin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devise_invitable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
description: A custom rails_admin invitation action for use with devise_invitable
|
56
|
+
email:
|
57
|
+
- tonywok@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- app/views/rails_admin/main/invite.html.haml
|
63
|
+
- config/locales/invite.en.yml
|
64
|
+
- lib/rails_admin_invite/engine.rb
|
65
|
+
- lib/rails_admin_invite/version.rb
|
66
|
+
- lib/rails_admin_invite.rb
|
67
|
+
- MIT-LICENSE
|
68
|
+
- Rakefile
|
69
|
+
- README.md
|
70
|
+
homepage: http://github.com/tonywok/rails_admin_invite
|
71
|
+
licenses: []
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.0.3
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: A custom rails_admin invitation action for use with devise_invitable
|
93
|
+
test_files: []
|