Merge commenting support
This commit is contained in:
@ -44,6 +44,7 @@ class SubmissionsController < ApplicationController
|
||||
comment.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def download_file
|
||||
if @file.native_file?
|
||||
|
6
app/models/comment.rb
Normal file
6
app/models/comment.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
# inherit the creation module: encapsulates that this is a polymorphic user, offers some aliases and makes sure that all necessary attributes are set.
|
||||
include Creation
|
||||
|
||||
belongs_to :file, class: CodeOcean::File
|
||||
end
|
37
app/views/comments/_form.html.erb
Normal file
37
app/views/comments/_form.html.erb
Normal file
@ -0,0 +1,37 @@
|
||||
<%= form_for(@comment) do |f| %>
|
||||
<% if @comment.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @comment.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :user_id %><br>
|
||||
<%= f.text_field :user_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :file_id %><br>
|
||||
<%= f.text_field :file_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :row %><br>
|
||||
<%= f.number_field :row %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :column %><br>
|
||||
<%= f.number_field :column %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :text %><br>
|
||||
<%= f.text_field :text %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
6
app/views/comments/edit.html.erb
Normal file
6
app/views/comments/edit.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<h1>Editing comment</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @comment %> |
|
||||
<%= link_to 'Back', comments_path %>
|
33
app/views/comments/index.html.erb
Normal file
33
app/views/comments/index.html.erb
Normal file
@ -0,0 +1,33 @@
|
||||
<h1>Listing comments</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>File</th>
|
||||
<th>Row</th>
|
||||
<th>Column</th>
|
||||
<th>Text</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @comments.each do |comment| %>
|
||||
<tr>
|
||||
<td><%= comment.user %></td>
|
||||
<td><%= comment.file %></td>
|
||||
<td><%= comment.row %></td>
|
||||
<td><%= comment.column %></td>
|
||||
<td><%= comment.text %></td>
|
||||
<td><%= link_to 'Show', comment %></td>
|
||||
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
|
||||
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Comment', new_comment_path %>
|
4
app/views/comments/index.json.jbuilder
Normal file
4
app/views/comments/index.json.jbuilder
Normal file
@ -0,0 +1,4 @@
|
||||
json.array!(@comments) do |comment|
|
||||
json.extract! comment, :id, :user_id, :file_id, :row, :column, :text
|
||||
json.url comment_url(comment, format: :json)
|
||||
end
|
5
app/views/comments/new.html.erb
Normal file
5
app/views/comments/new.html.erb
Normal file
@ -0,0 +1,5 @@
|
||||
<h1>New comment</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', comments_path %>
|
29
app/views/comments/show.html.erb
Normal file
29
app/views/comments/show.html.erb
Normal file
@ -0,0 +1,29 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>User:</strong>
|
||||
<%= @comment.user %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>File:</strong>
|
||||
<%= @comment.file %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Row:</strong>
|
||||
<%= @comment.row %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Column:</strong>
|
||||
<%= @comment.column %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Text:</strong>
|
||||
<%= @comment.text %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_comment_path(@comment) %> |
|
||||
<%= link_to 'Back', comments_path %>
|
1
app/views/comments/show.json.jbuilder
Normal file
1
app/views/comments/show.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.extract! @comment, :id, :user_id, :file_id, :row, :column, :text, :created_at, :updated_at
|
Reference in New Issue
Block a user