lotus_admin 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d3ca80072d89b813035c6b9362226840dd8acefa668e97002c2cbb142998b9d
4
- data.tar.gz: 1a275b54e059f89ee5384a40fb5fcf697440c1195ada84d50e071d2e31dd3e77
3
+ metadata.gz: 7abae8eb4be2f4c119e4cf91add400abb366b444879111eb93073462db7e1b16
4
+ data.tar.gz: 39bdbb6e979939f91d18b25ed5a8e162227fc0ed13c1df55d69549e18096807c
5
5
  SHA512:
6
- metadata.gz: 90247f44db4b6b0785556c8469c6b1aa62c5e3c45db85213a41b7449bbd02b914981fdda3f76e823349236d902289f52ee9e396adcd3bc4157f17949667e76eb
7
- data.tar.gz: 2b4d3029f59c37c53fd14b213102d870a597ba33096965d4021d7632b8f7ce284691fce30eace6031a1c51c686e8328e724e69fb927050fe50cc65a0282ddc02
6
+ metadata.gz: f8ae4a120f198c54cf944d7b9d995e7acfc0f691bd7a2dbef33ee6c0766643c9e8082ade919efe23d282ab7d9d26961f7e9f4c84ff7107f7b3ad039ca8ed509a
7
+ data.tar.gz: 07c53d084ada45c620c1d9626a638706ecf6127c78c1c90cac10e2869e04e3b525d12717b95ae7e3ec06e578480d780c2e7d605bd98a97c72a5264b55a7b90e8
@@ -15,31 +15,45 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
15
15
  let(:resource_class) { self.class._resource_class }
16
16
  let(:collection_path) { url_for(resource_class) }
17
17
 
18
- def new
18
+ def new(&block)
19
19
  self.resource = build_resource
20
20
 
21
21
  authorize(resource) if using_pundit?
22
+
23
+ block.call if block.present?
22
24
  end
23
25
 
24
- def create
26
+ def create(&block)
25
27
  self.resource = build_resource(permitted_params)
26
28
 
27
29
  authorize(resource) if using_pundit?
28
30
 
29
- if resource.save
30
- redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human } successfully"
31
- else
32
- render :new
31
+ respond_to do |format|
32
+ format.html
33
+
34
+ if block.present?
35
+ block.call
36
+ else
37
+ if resource.save
38
+ redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human } successfully"
39
+ else
40
+ render :new
41
+ end
42
+ end
33
43
  end
34
44
  end
35
45
 
36
- def update
46
+ def update(&block)
37
47
  authorize(resource) if using_pundit?
38
48
 
39
- if resource.update(permitted_params)
40
- redirect_to after_update_redirect, notice: "Updated new #{ resource_class.model_name.human } successfully"
49
+ if block.present?
50
+ block.call
41
51
  else
42
- render :edit
52
+ if resource.update(permitted_params)
53
+ redirect_to after_update_redirect, notice: "Updated #{ resource_class.model_name.human } successfully"
54
+ else
55
+ render :edit
56
+ end
43
57
  end
44
58
  end
45
59
 
@@ -11,39 +11,18 @@ module LotusAdmin
11
11
  filter :created_at
12
12
  filter :last_sign_in_at
13
13
 
14
- def new
15
- self.resource = resource_class.new
16
- end
17
-
18
14
  def create
19
- self.resource = resource_class.new(permitted_params)
20
- resource.password = Devise.friendly_token.first(8)
21
-
22
- if resource.save
23
- resource.send_invited_email_notification
15
+ super do
16
+ resource.password = Devise.friendly_token.first(8)
24
17
 
25
- redirect_to [lotus_admin, resource_class], notice: "Created new #{ resource_class.model_name.human }"
26
- else
27
- render :new
28
- end
29
- end
18
+ if resource.save
19
+ resource.send_invited_email_notification
30
20
 
31
- def update
32
- if resource.update(permitted_params)
33
- redirect_to [lotus_admin, resource], notice: 'Changes saved'
34
- else
35
- render :edit
21
+ redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human }"
22
+ else
23
+ render :new
24
+ end
36
25
  end
37
26
  end
38
-
39
- def destroy
40
- if user.destroy
41
- flash[:notice] = "#{ resource_class.model_name.human } has been removed"
42
- else
43
- flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
44
- end
45
-
46
- redirect_to [lotus_admin, resource_class]
47
- end
48
27
  end
49
28
  end
@@ -1,3 +1,3 @@
1
1
  module LotusAdmin
2
- VERSION = '1.4.4'
2
+ VERSION = '1.4.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lotus_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Millsaps-Brewer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails