ADD recommend organizations api
This commit is contained in:
parent
3c61848a77
commit
2cca2c756e
|
@ -1,5 +1,5 @@
|
||||||
class Organizations::OrganizationsController < Organizations::BaseController
|
class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
before_action :require_login, except: [:index, :show]
|
before_action :require_login, except: [:index, :show, :recommend]
|
||||||
before_action :convert_image!, only: [:create, :update]
|
before_action :convert_image!, only: [:create, :update]
|
||||||
before_action :load_organization, only: [:show, :update, :destroy]
|
before_action :load_organization, only: [:show, :update, :destroy]
|
||||||
before_action :check_user_can_edit_org, only: [:update, :destroy]
|
before_action :check_user_can_edit_org, only: [:update, :destroy]
|
||||||
|
@ -62,6 +62,13 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
tip_exception(e.message)
|
tip_exception(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recommend
|
||||||
|
recommend = %W(xuos Huawei_Technology openatom_foundation pkecosystem TensorLayer)
|
||||||
|
|
||||||
|
@organizations = Organization.with_visibility(%w(common)
|
||||||
|
.where(nickname: recommend).select(:id, :nickname)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def convert_image!
|
def convert_image!
|
||||||
return unless params[:image].present?
|
return unless params[:image].present?
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# gitea_token :string(255)
|
# gitea_token :string(255)
|
||||||
|
# platform :string(255)
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
json.organizations @organizations do |organization|
|
||||||
|
json.id organization.id
|
||||||
|
json.name organization.login
|
||||||
|
json.nickname organization.nickname.blank? ? organization.name : organization.nickname
|
||||||
|
json.avatar_url url_to_avatar(organization)
|
||||||
|
end
|
|
@ -130,6 +130,7 @@ Rails.application.routes.draw do
|
||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
get :recommend, on: :collection
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue