Skip to content

Commit

Permalink
hide answer tota ai from guest
Browse files Browse the repository at this point in the history
  • Loading branch information
usernaimandrey committed Dec 28, 2023
1 parent 2ee5f25 commit 86e1214
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/models/guest.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class Guest
def id; end

def guest?
true
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/resume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def to_s
name
end

def author?(user)
user_id == user.id
end

def self.ransackable_attributes(_auth_object = nil)
%w[id answers_count created_at impressions_count name state]
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/resume/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def author?(user)
user_id == user.id
end

def tota_ai_author?
user.email == ENV.fetch('EMAIL_SPECIAL_USER')
end

def self.ransackable_attributes(_auth_object = nil)
%w[user_id]
end
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/shared/_last_answers.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.fs-4.mb-3 = t('.title')

- last_answers.each do |answer|
- next if answer.tota_ai_author? && !answer.author?(current_user_or_guest) && !answer.resume.author?(current_user_or_guest) && !current_user_or_guest.admin?
.mb-4
.fw-bolder = link_to answer.resume, resume_path(answer.resume, anchor: "answer-#{answer.id}")
.small
Expand Down
5 changes: 3 additions & 2 deletions app/views/web/resumes/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ h3.text-center = @resume
h3.mb-3 = t('.recomendations')

- @resume_answers.each do |answer|
= render partial: 'web/shared/answer', object: answer, locals: { current_user_likes_by_answer_id: @current_user_likes_by_answer_id }
- next if answer.tota_ai_author? && !answer.author?(current_user_or_guest) && [email protected]?(current_user_or_guest) && !current_user_or_guest.admin?
= render 'web/shared/answer', answer:, current_user_likes_by_answer_id: @current_user_likes_by_answer_id

- if user_signed_in?
- if @current_user_answer
.text-center.lead = t('.answer_exists')
- else
= render partial: 'web/shared/answer_form', locals: { answer: @answer, url: resume_answers_path(@resume) }
= render 'web/shared/answer_form', answer: @answer, url: resume_answers_path(@resume)
- else
= render 'answer_requires'

0 comments on commit 86e1214

Please sign in to comment.