Add consumer-based RfC Visibility settings

This setting will be useful to increase data protection, where users might not be allowed to see RfCs from other contexts.
This commit is contained in:
Sebastian Serth
2023-02-20 09:35:21 +01:00
parent abede713f9
commit 9c3392b324
14 changed files with 146 additions and 14 deletions

View File

@@ -1,6 +1,12 @@
# frozen_string_literal: true
class Consumer < ApplicationRecord
enum rfc_visibility: {
all: 0,
consumer: 1,
study_group: 2,
}, _default: :all, _prefix: true
has_many :users
has_many :study_groups, dependent: :destroy

View File

@@ -88,7 +88,20 @@ class RequestForComment < ApplicationRecord
private
def row_number_user_sql
select('id, user_id, user_type, exercise_id, file_id, question, created_at, updated_at, solved, full_score_reached, submission_id, row_number() OVER (PARTITION BY user_id, user_type ORDER BY created_at DESC) as row_number')
select('
request_for_comments.id,
request_for_comments.user_id,
request_for_comments.user_type,
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.solved,
request_for_comments.full_score_reached,
request_for_comments.submission_id,
row_number() OVER (PARTITION BY request_for_comments.user_id, request_for_comments.user_type ORDER BY request_for_comments.created_at DESC) as row_number
')
end
end
end