mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-20 11:45:57 +08:00
Merge branch 'develop' into dev_trustie_server
This commit is contained in:
58
app/controllers/admins/faqs_controller.rb
Normal file
58
app/controllers/admins/faqs_controller.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
class Admins::FaqsController < Admins::BaseController
|
||||
before_action :find_faq, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
sort_by = params[:sort_by] ||= 'updated_at'
|
||||
sort_direction = params[:sort_direction] ||= 'desc'
|
||||
|
||||
keyword = params[:keyword].to_s.strip
|
||||
collection = Faq.search_question(keyword).order("#{sort_by} #{sort_direction}")
|
||||
@faqs = paginate collection
|
||||
end
|
||||
|
||||
def new
|
||||
@faq = Faq.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
begin
|
||||
@faq.update!(faq_params)
|
||||
flash[:success] = '修改成功'
|
||||
rescue Exception
|
||||
flash[:danger] = @faq.errors.full_messages.to_sentence
|
||||
end
|
||||
|
||||
redirect_to admins_faqs_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@faq.destroy
|
||||
|
||||
redirect_to admins_faqs_path
|
||||
flash[:success] = "删除成功"
|
||||
end
|
||||
|
||||
def create
|
||||
@faq = Faq.new(faq_params)
|
||||
begin
|
||||
@faq.save!
|
||||
flash[:success] = '创建成功'
|
||||
rescue Exception
|
||||
flash[:danger] = @faq.errors.full_messages.to_sentence
|
||||
end
|
||||
redirect_to admins_faqs_path
|
||||
end
|
||||
|
||||
private
|
||||
def find_faq
|
||||
@faq = Faq.find params[:id]
|
||||
end
|
||||
|
||||
def faq_params
|
||||
params.require(:faq).permit(:question, :url)
|
||||
end
|
||||
|
||||
end
|
||||
8
app/controllers/helps/faqs_controller.rb
Normal file
8
app/controllers/helps/faqs_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Helps::FaqsController < ApplicationController
|
||||
skip_before_action :check_sign, :user_setup
|
||||
|
||||
def index
|
||||
faqs = Faq.select_without_id.order(updated_at: :desc)
|
||||
render json: faqs.as_json(:except => [:id])
|
||||
end
|
||||
end
|
||||
@@ -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(login: recommend).select(:id, :login, :firstname, :lastname, :nickname)
|
||||
end
|
||||
|
||||
private
|
||||
def convert_image!
|
||||
return unless params[:image].present?
|
||||
|
||||
@@ -167,7 +167,7 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
|
||||
def recommend
|
||||
@projects = Project.recommend.includes(:repository, :project_category, :owner).order(id: :desc).limit(5)
|
||||
@projects = Project.recommend.includes(:repository, :project_category, :owner).order(id: :desc)
|
||||
end
|
||||
|
||||
def about
|
||||
|
||||
Reference in New Issue
Block a user