Browse Source

cla show add response

pull/343/head
chenjing 3 years ago
parent
commit
fed604989f
3 changed files with 9 additions and 0 deletions
  1. +3
    -0
      app/controllers/organizations/clas_controller.rb
  2. +5
    -0
      app/models/organization.rb
  3. +1
    -0
      app/views/organizations/clas/show.json.jbuilder

+ 3
- 0
app/controllers/organizations/clas_controller.rb View File

@@ -11,6 +11,9 @@ class Organizations::ClasController < Organizations::BaseController
@is_admin = can_edit_org?
@is_member = @organization.is_member?(current_user.id)
@is_sign = @organization.is_sign?(current_user.id)
@cla_sign_email = if @is_sign
@organization.cla_sign_email(current_user.id)
end
end

def create


+ 5
- 0
app/models/organization.rb View File

@@ -112,6 +112,11 @@ class Organization < Owner
cla.user_clas.where(user_id: user_id).present?
end

def cla_sign_email(user_id)
cla.user_clas.find_by(user_id: user_id)&.email
end


def is_owner?(user_id)
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(owner)}).present?
end


+ 1
- 0
app/views/organizations/clas/show.json.jbuilder View File

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

Loading…
Cancel
Save