rails_admin_comments 0.3.0.1 → 0.3.0.3

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
  SHA1:
3
- metadata.gz: 1d90fe615ad69d325f71424c2ad579f76423a881
4
- data.tar.gz: 85683c150ecc68dc40e2b59269d2a4363d428d79
3
+ metadata.gz: a36dd4a6de4e43c31df2e8a3df90110bc8494576
4
+ data.tar.gz: 1ab93822e030325d93fb86cbb1e17986b3484f80
5
5
  SHA512:
6
- metadata.gz: ab71d47fb118d5856a7ef3d7004c6a357d7567cf9a026ad7cba411eb26faf8db6c6f87bbb179ff2ee6054d2e8dbf51cbeb23ffcc6bb23363ae9a1257bfe44b86
7
- data.tar.gz: 4e861058af63dcd54b59996ff9307e972722abc70193ac0a83ca374c482f96626f902c5ea3e05e946d6b155e13684d6622d5e8fbdb60ed66933bd3bbf92e2e0f
6
+ metadata.gz: ffa516fda31315ab9ec95c9a0a6a4269c118234f8eba5b964c8bc66aae03a268b2516cb7c3bf461f4782af65d9b3cbbdeb46fc1386e5e1c0e637d1ae4e298833
7
+ data.tar.gz: cae1a290fa3a69150a15dd996aed76feb3ac9bd4e9f82cb7fd3b243b92b771eebecf375c58c0c67cf621311079a478f2303f3198ee62a9d83d7f24094495a10f
@@ -5,6 +5,9 @@ require 'mongoid_userstamp'
5
5
 
6
6
  require "rails_admin_comments/engine"
7
7
 
8
+ require 'rails_admin/config/actions'
9
+ require 'rails_admin/config/model'
10
+
8
11
  require 'rails_admin_comments/configuration'
9
12
 
10
13
  require 'rails_admin/config/actions'
@@ -34,9 +34,9 @@ module RailsAdmin
34
34
  begin
35
35
  if params['rails_admin_comments_comment'].present?
36
36
  if params['rails_admin_comments_comment']['id'].present?
37
- @comment = @object.rails_admin_comments.find(params['rails_admin_comments_comment']['id'])
37
+ @comment = @object.rails_admin_comments.where(id: params['rails_admin_comments_comment']['id']).first
38
38
  end
39
- @comment = @object.rails_admin_comments.new if @comment.nil?
39
+ @comment ||= @object.rails_admin_comments.new
40
40
 
41
41
  @comment.content = params['rails_admin_comments_comment']['content']
42
42
  @comment.visible_for_user_ids = params['rails_admin_comments_comment']['visible_for_user_ids']
@@ -61,8 +61,24 @@ module RailsAdmin
61
61
  @message = "<strong class='error'>#{I18n.t('admin.actions.comments.error')}</strong>: #{e}".freeze
62
62
  end
63
63
 
64
+ @comments = @object.rails_admin_comments.by_date.enabled.for_user(current_user) || []
65
+ render action: @action.template_name
66
+
67
+ elsif request.delete?
68
+ if params['rails_admin_comments_comment']['id'].present?
69
+ @comment = @object.rails_admin_comments.where(id: params['rails_admin_comments_comment']['id']).first
70
+ end
71
+ if @comment and @comment.destroy
72
+ @comment = nil
73
+ @message = "<strong class='success'>Удалено</strong>".freeze
74
+ else
75
+ @message = "<strong class='error'>Удаление не удалось</strong>".freeze
76
+ end
77
+
78
+ @comments = @object.rails_admin_comments.by_date.enabled.for_user(current_user) || []
64
79
  render action: @action.template_name
65
80
  end
81
+
66
82
  end
67
83
  end
68
84
  end
@@ -111,7 +127,7 @@ module RailsAdmin
111
127
  begin
112
128
  if params['rails_admin_comments_model_comment'].present?
113
129
  if params['rails_admin_comments_model_comment']['id'].present?
114
- @comment = @model.rails_admin_model_comments.find(params['rails_admin_comments_model_comment']['id'])
130
+ @comment = @model.rails_admin_model_comments.where(id: params['rails_admin_comments_model_comment']['id']).first
115
131
  end
116
132
  @comment ||= @model.rails_admin_model_comments.new
117
133
 
@@ -138,18 +154,21 @@ module RailsAdmin
138
154
  @message = "<strong class='error'>#{I18n.t('admin.actions.comments.error')}</strong>: #{e}".freeze
139
155
  end
140
156
 
157
+ @comments = @object.rails_admin_comments.by_date.enabled.for_user(current_user) || []
141
158
  render action: @action.template_name
142
159
 
143
160
  elsif request.delete?
144
161
  if params['rails_admin_comments_model_comment']['id'].present?
145
- @comment = @model.rails_admin_model_comments.find(params['rails_admin_comments_model_comment']['id'])
162
+ @comment = @model.rails_admin_model_comments.where(id: params['rails_admin_comments_model_comment']['id']).first
146
163
  end
147
164
  if @comment and @comment.destroy
148
165
  @comment = nil
149
- @message = "Удалено".freeze
166
+ @message = "<strong class='success'>Удалено</strong>".freeze
150
167
  else
151
- @message = "Удаление не удалось".freeze
168
+ @message = "<strong class='error'>Удаление не удалось</strong>".freeze
152
169
  end
170
+
171
+ @comments = @model.rails_admin_model_comments.by_date.enabled.for_user(current_user) || []
153
172
  render action: @action.template_name
154
173
  end
155
174
  end
@@ -21,7 +21,7 @@ module RailsAdminComments
21
21
 
22
22
  has_and_belongs_to_many :visible_for_users, class_name: "User", inverse_of: nil
23
23
  scope :for_user, ->(user) {
24
- any_of({visible_for_user_ids: user}, {visible_for_user_ids: nil})
24
+ any_of({visible_for_user_ids: user}, {visible_for_user_ids: nil}, {visible_for_user_ids: []})
25
25
  }
26
26
  end
27
27
  end
@@ -9,7 +9,7 @@ module RailsAdminComments
9
9
 
10
10
  field :model_name, type: String
11
11
 
12
- store_in collection: "rails_admin_model_comments".freeze
12
+ store_in collection: "rails_admin_model_comments"
13
13
 
14
14
  field :enabled, type: ::Mongoid::VERSION.to_i < 4 ? Boolean : ::Mongoid::Boolean, default: true
15
15
  scope :enabled, -> { where(enabled: true) }
@@ -21,7 +21,7 @@ module RailsAdminComments
21
21
 
22
22
  has_and_belongs_to_many :visible_for_users, class_name: "User", inverse_of: nil
23
23
  scope :for_user, ->(user) {
24
- any_of({visible_for_user_ids: user}, {visible_for_user_ids: nil})
24
+ any_of({visible_for_user_ids: user}, {visible_for_user_ids: nil}, {visible_for_user_ids: []})
25
25
  }
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminComments
2
- VERSION = "0.3.0.1".freeze
2
+ VERSION = "0.3.0.3".freeze
3
3
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency "rails", '>= 5.0.0'
34
34
 
35
- spec.add_dependency "rails_admin", '>= 1.0.0.rc'
35
+ spec.add_dependency "rails_admin", ['>= 1.0.0.rc', "< 2.0"]
36
36
  spec.add_dependency "mongoid", [">= 6.0.0.rc0", "< 7.0"]
37
- spec.add_dependency "glebtv_mongoid_userstamp", '~> 0.6.1'
37
+ spec.add_dependency "glebtv_mongoid_userstamp", '~> 0.7.0'
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.1
4
+ version: 0.3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,6 +59,9 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.0.0.rc
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '2.0'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,6 +69,9 @@ dependencies:
66
69
  - - ">="
67
70
  - !ruby/object:Gem::Version
68
71
  version: 1.0.0.rc
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: mongoid
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +98,14 @@ dependencies:
92
98
  requirements:
93
99
  - - "~>"
94
100
  - !ruby/object:Gem::Version
95
- version: 0.6.1
101
+ version: 0.7.0
96
102
  type: :runtime
97
103
  prerelease: false
98
104
  version_requirements: !ruby/object:Gem::Requirement
99
105
  requirements:
100
106
  - - "~>"
101
107
  - !ruby/object:Gem::Version
102
- version: 0.6.1
108
+ version: 0.7.0
103
109
  description: Comments for rails_admin
104
110
  email:
105
111
  - i43ack@gmail.com