update response for cla

This commit is contained in:
chenjing 2023-06-15 14:01:36 +08:00
parent 6b772ea889
commit fccf36e1eb
3 changed files with 11 additions and 1 deletions

View File

@ -1,11 +1,15 @@
class Organizations::ClasController < Organizations::BaseController
before_action :load_organization
before_action :load_cla, only: [:show, :update, :destroy]
def index
@cla = @organization.cla
end
def show
def show
@is_admin = can_edit_org?
@is_member = @organization.is_member?(current_user.id)
@is_sign = @organization.is_sign?(current_user.id)
end
def create

View File

@ -107,6 +107,11 @@ class Organization < Owner
organization_users.where(user_id: user_id).present?
end
def is_sign?(user_id)
return false if cla.nil?
cla.user_clas.where(user_id: user_id).present?
end
def is_owner?(user_id)
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(owner)}).present?
end

View File

@ -1,5 +1,6 @@
json.partial! "detail", cla: @cla, organization: @organization
json.is_admin @is_admin
json.is_sign @is_sign
json.is_member @is_member
json.organization do
json.partial! "organizations/organizations/simple", organization: @organization