diff --git a/app/models/hack.rb b/app/models/hack.rb index 9b7241bda..506cd4942 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -41,4 +41,9 @@ class Hack < ApplicationRecord hack_sets.first&.input end + # 管理员 + def manager?(user) + user_id == user.id || user.admin_or_business? + end + end diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder index 692c49d95..2d7ffd2bf 100644 --- a/app/views/hack_user_lastest_codes/show.json.jbuilder +++ b/app/views/hack_user_lastest_codes/show.json.jbuilder @@ -14,4 +14,6 @@ end json.user do json.partial! 'users/user', user: current_user + json.hack_manager @hack.manager?(current_user) + end \ No newline at end of file diff --git a/app/views/hacks/edit.json.jbuilder b/app/views/hacks/edit.json.jbuilder index bb005410f..e6fee65b8 100644 --- a/app/views/hacks/edit.json.jbuilder +++ b/app/views/hacks/edit.json.jbuilder @@ -1,5 +1,5 @@ # 编程内容 -json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not) +json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not, :status) # 代码 json.language @hack.language diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 52f7407fd..260436807 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -242,7 +242,7 @@ class ShixunsHome extends Component { 更多 -