diff --git a/app/models/user.rb b/app/models/user.rb index 02a4eba85..2a1eb7195 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -649,6 +649,10 @@ class User < ApplicationRecord Educoder::Utils.random_hex(16) end + def is_collect? container + collections.where(container: container).exists? + end + # 全部已认证 def all_certified? authentication? && professional_certification? diff --git a/app/views/shixuns/show.json.jbuilder b/app/views/shixuns/show.json.jbuilder index 4a0c3ebd6..eeddd9149 100644 --- a/app/views/shixuns/show.json.jbuilder +++ b/app/views/shixuns/show.json.jbuilder @@ -1,5 +1,7 @@ json.fork_from @fork_from json.identity User.current.shixun_identity(@shixun) +json.is_collect @user.is_collect?(@shixun) + json.power @power json.partial! 'shixuns/top', locals: { shixun: @shixun, current_myshixun: @current_myshixun } json.secret_repository @shixun.shixun_secret_repository.present? diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index d25437f0a..6a7954d0b 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -5,6 +5,8 @@ json.challenges_count @subject.subject_challenge_count json.subject_score @subject.all_score json.member_count @subject.member_count +json.is_collect @user.is_collect?(@subject) + json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? json.publish_status publish_status(@subject, @is_manager) json.public_status public_status(@subject, @is_manager, @user)