foreman_datacenter 0.1.29 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a51927a6d6c5ab0213cf5133fbf9e5128ab0d9f6
4
- data.tar.gz: 3f176391dd82707b426739969ac176b61fd5b61a
3
+ metadata.gz: 49cdb573f462e46ab86a64cd7b8915f0c09ff72e
4
+ data.tar.gz: 8944573b46fa5dfa2932be16d7c8586ae9907687
5
5
  SHA512:
6
- metadata.gz: 47fa4ed6fcd7cdefa808b58db7af49ebb20c8cd0743a794afbbcf7463d2417b92db3b81f4419b32d4721f941fc7ff1e5157d246f233420562d12b3976dc62ade
7
- data.tar.gz: 27c6ba3746379282ef251e985a72df79d1a010471c0a195872378209763aba4977fafddd509a9d44b72cf8d5c6d6738b421b1703b781dba99aeccf38d0630da9
6
+ metadata.gz: c69e5748012abb678d68b200eca283cfd60825992cca16e7632cad172d20d228a5970e71787630752b4991b8d5480961e55410c05beabea829df7ec30c84b96a
7
+ data.tar.gz: a8193287b95f9c995546bb339c5e0f2f23f8dd7397c5f1ae170319ad5f1ab88e7a35580c25b3b81705275806a01f42eb96274cf262d702fe07b8deb95535a690
@@ -13,7 +13,7 @@ module ForemanDatacenter
13
13
  end
14
14
 
15
15
  def create
16
- @comment = @commentable.comments.new(comment_params)
16
+ @comment = @commentable.comments.new(comment_params.merge(user_id: User.current.id))
17
17
  if @comment.save
18
18
  process_success :success_redirect => "/datacenter/#{@resource}/#{@id}#comment-#{@comment.id}"
19
19
  else
@@ -25,7 +25,7 @@ module ForemanDatacenter
25
25
  @comment = Comment.find(params[:id])
26
26
  @device = find_commentable(@comment)
27
27
  @submodule = parse_submodule(@comment)
28
- if @comment.update(comment_params)
28
+ if @comment.update(comment_params.merge(user_id: User.current.id))
29
29
  process_success :success_redirect => "/datacenter/#{@submodule}/#{@comment.commentable_id}#comment-#{@comment.id}"
30
30
  else
31
31
  process_error :redirect => "/datacenter/#{@submodule}/#{@comment.commentable_id}#comment-#{@comment.id}", :error_msg => _("Failed: %s") % (e)
@@ -60,7 +60,7 @@ module ForemanDatacenter
60
60
  end
61
61
 
62
62
  def comment_params
63
- params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id, :parent_id)
63
+ params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id, :parent_id, :user_id)
64
64
  end
65
65
 
66
66
  def find_commentable(comment)
@@ -2,6 +2,7 @@ module ForemanDatacenter
2
2
  class Comment < ActiveRecord::Base
3
3
  self.table_name = "datacenter_comments"
4
4
  belongs_to :commentable, polymorphic: true
5
+ belongs_to :user
5
6
  has_ancestry
6
7
  # belongs_to :parent, class_name: "ForemanDatacenter::Comment"
7
8
  # has_many :children, class_name: "ForemanDatacenter::Comment", foreign_key: "parent_id"
@@ -1,6 +1,10 @@
1
1
  <strong id="comment-<%= comment.id %>">
2
2
  <small class="text-left pull-left">
3
- Posted by ... <%#= "#{@user.firstname} #{@user.lastname}" %> at <%= comment.updated_at %>
3
+ <% if comment.user %>
4
+ Posted by <%= "#{comment.try(:user).try(:firstname)} #{comment.try(:user).try(:lastname)}" %> at <%= comment.updated_at %>
5
+ <% else %>
6
+ Posted at <%= comment.updated_at %>
7
+ <% end %>
4
8
  </small>
5
9
 
6
10
  <small class="text-right pull-right">
@@ -1,3 +1,3 @@
1
1
  module ForemanDatacenter
2
- VERSION = '0.1.29'.freeze
2
+ VERSION = '0.1.30'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_datacenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Ivanov