Merge pull request #125 from openHPI/rework-comment-modal

Rework comment modal
This commit is contained in:
rteusner
2017-09-20 16:51:47 +02:00
committed by GitHub
27 changed files with 679 additions and 226 deletions

View File

@@ -1,7 +1,7 @@
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
attr_accessor :username, :date, :updated
attr_accessor :username, :date, :updated, :editable
belongs_to :file, class_name: 'CodeOcean::File'
belongs_to :user, polymorphic: true

View File

@@ -5,6 +5,7 @@ class RequestForComment < ActiveRecord::Base
belongs_to :file, class_name: 'CodeOcean::File'
has_many :comments, through: :submission
has_many :subscriptions
scope :unsolved, -> { where(solved: [false, nil]) }
@@ -37,6 +38,14 @@ class RequestForComment < ActiveRecord::Base
submission.files.map { |file| file.comments.size}.sum
end
def commenters
commenters = []
comments.distinct.to_a.each {|comment|
commenters.append comment.user
}
commenters.uniq {|user| user.id}
end
def to_s
"RFC-" + self.id.to_s
end

View File

@@ -0,0 +1,4 @@
class Subscription < ActiveRecord::Base
belongs_to :user, polymorphic: true
belongs_to :request_for_comment
end