@ -11,14 +11,45 @@ class RequestForCommentsController < ApplicationController
|
|||||||
# GET /request_for_comments
|
# GET /request_for_comments
|
||||||
# GET /request_for_comments.json
|
# GET /request_for_comments.json
|
||||||
def index
|
def index
|
||||||
@search = RequestForComment.last_per_user(2).search(params[:q])
|
@search = RequestForComment
|
||||||
|
.last_per_user(2)
|
||||||
|
.joins('join "submissions" s on s.id = request_for_comments.submission_id
|
||||||
|
left outer join "files" f on f.context_id = s.id
|
||||||
|
left outer join "comments" on comments.file_id = f.id')
|
||||||
|
.group('request_for_comments.id, request_for_comments.user_id, request_for_comments.exercise_id,
|
||||||
|
request_for_comments.file_id, request_for_comments.question, request_for_comments.created_at,
|
||||||
|
request_for_comments.updated_at, request_for_comments.user_type, request_for_comments.solved,
|
||||||
|
request_for_comments.submission_id, request_for_comments.row_number') # ugly, but rails wants it this way
|
||||||
|
.select('request_for_comments.*, max(comments.updated_at) as last_comment')
|
||||||
|
.search(params[:q])
|
||||||
@request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page])
|
@request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_my_comment_requests
|
def get_my_comment_requests
|
||||||
@search = RequestForComment.where(user_id: current_user.id).order('created_at DESC').search(params[:q])
|
@search = RequestForComment
|
||||||
@request_for_comments = @search.result.paginate(page: params[:page])
|
.where(user_id: current_user.id)
|
||||||
|
.joins('join "submissions" s on s.id = request_for_comments.submission_id
|
||||||
|
left outer join "files" f on f.context_id = s.id
|
||||||
|
left outer join "comments" on comments.file_id = f.id')
|
||||||
|
.group('request_for_comments.id')
|
||||||
|
.select('request_for_comments.*, max(comments.updated_at) as last_comment')
|
||||||
|
.search(params[:q])
|
||||||
|
@request_for_comments = @search.result.order('created_at DESC').paginate(page: params[:page])
|
||||||
|
render 'index'
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_rfcs_with_my_comments
|
||||||
|
@search = RequestForComment
|
||||||
|
.joins(:comments) # we don't need to outer join here, because we know the user has commented on these
|
||||||
|
.where(comments: {user_id: current_user.id})
|
||||||
|
.joins('join "submissions" s on s.id = request_for_comments.submission_id
|
||||||
|
left outer join "files" f on f.context_id = s.id
|
||||||
|
left outer join "comments" as c on c.file_id = f.id')
|
||||||
|
.group('request_for_comments.id')
|
||||||
|
.select('request_for_comments.*, max(c.updated_at) as last_comment')
|
||||||
|
.search(params[:q])
|
||||||
|
@request_for_comments = @search.result.order('last_comment DESC').paginate(page: params[:page])
|
||||||
render 'index'
|
render 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
li = link_to(t('internal_users.show.link'), current_user)
|
li = link_to(t('internal_users.show.link'), current_user)
|
||||||
li = link_to(t('request_for_comments.index.all'), request_for_comments_path)
|
li = link_to(t('request_for_comments.index.all'), request_for_comments_path)
|
||||||
li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
|
li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
|
||||||
|
li = link_to(t('request_for_comments.index.get_my_rfc_activity'), my_rfc_activity_path)
|
||||||
- if current_user.internal_user?
|
- if current_user.internal_user?
|
||||||
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
|
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
|
||||||
- else
|
- else
|
||||||
|
@ -20,6 +20,7 @@ h1 = RequestForComment.model_name.human(count: 2)
|
|||||||
i class="fa fa-comment" aria-hidden="true" title = t('request_for_comments.comments') align="center"
|
i class="fa fa-comment" aria-hidden="true" title = t('request_for_comments.comments') align="center"
|
||||||
th = t('activerecord.attributes.request_for_comments.username')
|
th = t('activerecord.attributes.request_for_comments.username')
|
||||||
th = t('activerecord.attributes.request_for_comments.requested_at')
|
th = t('activerecord.attributes.request_for_comments.requested_at')
|
||||||
|
th = t('activerecord.attributes.request_for_comments.last_update')
|
||||||
tbody
|
tbody
|
||||||
- @request_for_comments.each do |request_for_comment|
|
- @request_for_comments.each do |request_for_comment|
|
||||||
tr data-id=request_for_comment.id
|
tr data-id=request_for_comment.id
|
||||||
@ -36,5 +37,6 @@ h1 = RequestForComment.model_name.human(count: 2)
|
|||||||
td = request_for_comment.comments_count
|
td = request_for_comment.comments_count
|
||||||
td = request_for_comment.user.displayname
|
td = request_for_comment.user.displayname
|
||||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
|
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
|
||||||
|
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.last_comment.nil? ? request_for_comment.updated_at : request_for_comment.last_comment))
|
||||||
|
|
||||||
= render('shared/pagination', collection: @request_for_comments)
|
= render('shared/pagination', collection: @request_for_comments)
|
@ -94,6 +94,7 @@ de:
|
|||||||
requested_at: Angefragezeitpunkt
|
requested_at: Angefragezeitpunkt
|
||||||
question: "Frage"
|
question: "Frage"
|
||||||
close: "Fenster schließen"
|
close: "Fenster schließen"
|
||||||
|
last_update: "Letzte Aktivität"
|
||||||
submission:
|
submission:
|
||||||
cause: Anlass
|
cause: Anlass
|
||||||
code: Code
|
code: Code
|
||||||
@ -456,6 +457,8 @@ de:
|
|||||||
index:
|
index:
|
||||||
get_my_comment_requests: Meine Kommentaranfragen
|
get_my_comment_requests: Meine Kommentaranfragen
|
||||||
all: "Alle Kommentaranfragen"
|
all: "Alle Kommentaranfragen"
|
||||||
|
get_rfcs_with_my_comments: Kommentaranfragen die ich kommentiert habe
|
||||||
|
get_my_rfc_activity: "Meine Kommentaraktivität"
|
||||||
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
||||||
mark_as_solved: "Diese Frage als beantwortet markieren"
|
mark_as_solved: "Diese Frage als beantwortet markieren"
|
||||||
show_all: "Alle Anfragen anzeigen"
|
show_all: "Alle Anfragen anzeigen"
|
||||||
|
@ -115,6 +115,7 @@ en:
|
|||||||
requested_at: Request Date
|
requested_at: Request Date
|
||||||
question: "Question"
|
question: "Question"
|
||||||
close: Close window
|
close: Close window
|
||||||
|
last_update: "Last Update"
|
||||||
submission:
|
submission:
|
||||||
cause: Cause
|
cause: Cause
|
||||||
code: Code
|
code: Code
|
||||||
@ -477,6 +478,8 @@ en:
|
|||||||
index:
|
index:
|
||||||
all: All Requests for Comments
|
all: All Requests for Comments
|
||||||
get_my_comment_requests: My Requests for Comments
|
get_my_comment_requests: My Requests for Comments
|
||||||
|
get_rfcs_with_my_comments: Requests for Comments I have commented on
|
||||||
|
get_my_rfc_activity: "My Comment Activity"
|
||||||
no_question: "The author did not enter a question for this request."
|
no_question: "The author did not enter a question for this request."
|
||||||
mark_as_solved: "Mark this question as answered"
|
mark_as_solved: "Mark this question as answered"
|
||||||
show_all: "All requests"
|
show_all: "All requests"
|
||||||
|
@ -20,6 +20,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
||||||
|
get '/my_rfc_activity', as: 'my_rfc_activity', to: 'request_for_comments#get_rfcs_with_my_comments'
|
||||||
|
|
||||||
delete '/comment_by_id', to: 'comments#destroy_by_id'
|
delete '/comment_by_id', to: 'comments#destroy_by_id'
|
||||||
put '/comments', to: 'comments#update'
|
put '/comments', to: 'comments#update'
|
||||||
|
Reference in New Issue
Block a user