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 +4 -4
- data/lib/rails_admin_comments.rb +3 -0
- data/lib/rails_admin_comments/action.rb +25 -6
- data/lib/rails_admin_comments/models/mongoid/comments.rb +1 -1
- data/lib/rails_admin_comments/models/mongoid/model_comments.rb +2 -2
- data/lib/rails_admin_comments/version.rb +1 -1
- data/rails_admin_comments.gemspec +2 -2
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36dd4a6de4e43c31df2e8a3df90110bc8494576
|
4
|
+
data.tar.gz: 1ab93822e030325d93fb86cbb1e17986b3484f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffa516fda31315ab9ec95c9a0a6a4269c118234f8eba5b964c8bc66aae03a268b2516cb7c3bf461f4782af65d9b3cbbdeb46fc1386e5e1c0e637d1ae4e298833
|
7
|
+
data.tar.gz: cae1a290fa3a69150a15dd996aed76feb3ac9bd4e9f82cb7fd3b243b92b771eebecf375c58c0c67cf621311079a478f2303f3198ee62a9d83d7f24094495a10f
|
data/lib/rails_admin_comments.rb
CHANGED
@@ -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.
|
37
|
+
@comment = @object.rails_admin_comments.where(id: params['rails_admin_comments_comment']['id']).first
|
38
38
|
end
|
39
|
-
@comment
|
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.
|
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.
|
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 = "
|
166
|
+
@message = "<strong class='success'>Удалено</strong>".freeze
|
150
167
|
else
|
151
|
-
@message = "
|
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"
|
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
|
@@ -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.
|
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.
|
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:
|
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.
|
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.
|
108
|
+
version: 0.7.0
|
103
109
|
description: Comments for rails_admin
|
104
110
|
email:
|
105
111
|
- i43ack@gmail.com
|