Merge commenting support

This commit is contained in:
Felix Wolff
2015-03-27 11:57:35 +01:00
parent 6e5e9a6634
commit a70053532b
9 changed files with 122 additions and 0 deletions

View File

@ -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
View 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

View 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 %>

View File

@ -0,0 +1,6 @@
<h1>Editing comment</h1>
<%= render 'form' %>
<%= link_to 'Show', @comment %> |
<%= link_to 'Back', comments_path %>

View 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 %>

View 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

View File

@ -0,0 +1,5 @@
<h1>New comment</h1>
<%= render 'form' %>
<%= link_to 'Back', comments_path %>

View 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 %>

View File

@ -0,0 +1 @@
json.extract! @comment, :id, :user_id, :file_id, :row, :column, :text, :created_at, :updated_at