diff --git a/app/controllers/organizations/organizations_controller.rb b/app/controllers/organizations/organizations_controller.rb index c8f4f4aa0..042d9a9fe 100644 --- a/app/controllers/organizations/organizations_controller.rb +++ b/app/controllers/organizations/organizations_controller.rb @@ -1,5 +1,5 @@ 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 :load_organization, only: [:show, :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) 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 def convert_image! return unless params[:image].present? diff --git a/app/models/organization.rb b/app/models/organization.rb index f12c8b0a6..444938e72 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -47,6 +47,7 @@ # watchers_count :integer default("0") # devops_step :integer default("0") # gitea_token :string(255) +# platform :string(255) # # Indexes # diff --git a/app/views/organizations/organizations/recommend.json.jbuilder b/app/views/organizations/organizations/recommend.json.jbuilder new file mode 100644 index 000000000..262cc23dd --- /dev/null +++ b/app/views/organizations/organizations/recommend.json.jbuilder @@ -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 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2901e0f56..63c7520ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -130,6 +130,7 @@ Rails.application.routes.draw do get :search end end + get :recommend, on: :collection end end