Create first comment automatically from the annotation

This commit is contained in:
Amaia Castro
2017-01-09 17:03:00 +01:00
parent b8f034d896
commit f43f13e826
6 changed files with 21 additions and 18 deletions

View File

@@ -13,6 +13,12 @@ class Legislation::Annotation < ActiveRecord::Base
validates :draft_version, presence: true
validates :author, presence: true
after_create :create_first_comment
def create_first_comment
comments.create(body: self.text, user: self.author)
end
def title
text[0..50]
end

View File

@@ -23,7 +23,7 @@
<%= annotation.quote %>
</div>
<%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %>
<span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count + 1) %></span></a>
<span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count) %></span></a>
<% end %>
</div>
<% end %>

View File

@@ -27,12 +27,6 @@
</div>
</div>
<div class="row">
<div class="small-12 medium-10 column legislation-comment">
<%= @annotation.text %>
</div>
</div>
<%= render 'comments', commentable: @annotation %>
</div>