Merge remote-tracking branch 'origin/trustie_server' into trustie_server
This commit is contained in:
commit
2b55bfacf8
2
Gemfile
2
Gemfile
|
@ -141,4 +141,4 @@ gem 'doorkeeper'
|
||||||
|
|
||||||
gem 'doorkeeper-jwt'
|
gem 'doorkeeper-jwt'
|
||||||
|
|
||||||
gem 'gitea-client', '~> 1.5.7'
|
gem 'gitea-client', '~> 1.5.8'
|
||||||
|
|
|
@ -23,10 +23,23 @@ class Admins::BaseController < ApplicationController
|
||||||
def require_admin!
|
def require_admin!
|
||||||
return if current_user.blank? || !current_user.logged?
|
return if current_user.blank? || !current_user.logged?
|
||||||
return if current_user.admin_or_business?
|
return if current_user.admin_or_business?
|
||||||
|
return if current_user.admin_or_glcc_admin?
|
||||||
|
|
||||||
render_forbidden
|
render_forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def require_admin
|
||||||
|
render_forbidden unless User.current.admin?
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_business
|
||||||
|
render_forbidden unless admin_or_business?
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_glcc_admin
|
||||||
|
render_forbidden unless admin_or_glcc_admin?
|
||||||
|
end
|
||||||
|
|
||||||
# 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件
|
# 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件
|
||||||
def rebind_event_if_ajax_render_partial
|
def rebind_event_if_ajax_render_partial
|
||||||
return if request.format.symbol != :js
|
return if request.format.symbol != :js
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::EduSettingsController < Admins::BaseController
|
class Admins::EduSettingsController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :find_setting, only: [:edit,:update, :destroy]
|
before_action :find_setting, only: [:edit,:update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::FaqsController < Admins::BaseController
|
class Admins::FaqsController < Admins::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_faq, only: [:edit,:update, :destroy]
|
before_action :find_faq, only: [:edit,:update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::FeedbacksController < Admins::BaseController
|
class Admins::FeedbacksController < Admins::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :get_feedback, only: [:new_history, :create_history, :destroy]
|
before_action :get_feedback, only: [:new_history, :create_history, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Admins::GlccPrCheckController < Admins::BaseController
|
class Admins::GlccPrCheckController < Admins::BaseController
|
||||||
|
before_action :require_glcc_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::IdentityVerificationsController < Admins::BaseController
|
class Admins::IdentityVerificationsController < Admins::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :finder_identity_verification, except: [:index]
|
before_action :finder_identity_verification, except: [:index]
|
||||||
def index
|
def index
|
||||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::IssuesRankController < Admins::BaseController
|
class Admins::IssuesRankController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)
|
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::LaboratoriesController < Admins::BaseController
|
class Admins::LaboratoriesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
def index
|
def index
|
||||||
default_sort('id', 'desc')
|
default_sort('id', 'desc')
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::MessageTemplatesController < Admins::BaseController
|
class Admins::MessageTemplatesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :get_template, only: [:edit, :update, :destroy]
|
before_action :get_template, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::NpsController < Admins::BaseController
|
class Admins::NpsController < Admins::BaseController
|
||||||
|
before_action :require_business
|
||||||
def index
|
def index
|
||||||
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
|
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
|
||||||
@user_nps = UserNp.joins(:user).order(created_at: :desc)
|
@user_nps = UserNp.joins(:user).order(created_at: :desc)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::OrganizationsController < Admins::BaseController
|
class Admins::OrganizationsController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :finder_org, except: [:index]
|
before_action :finder_org, except: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::PageThemesController < Admins::BaseController
|
class Admins::PageThemesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :finder_page_theme, only: [:edit, :update, :destroy]
|
before_action :finder_page_theme, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ProjectCategoriesController < Admins::BaseController
|
class Admins::ProjectCategoriesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :get_category, only: [:edit,:update, :destroy]
|
before_action :get_category, only: [:edit,:update, :destroy]
|
||||||
before_action :validate_names, only: [:create, :update]
|
before_action :validate_names, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ProjectIgnoresController < Admins::BaseController
|
class Admins::ProjectIgnoresController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
|
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
|
||||||
# before_action :validate_params, only: [:create, :update]
|
# before_action :validate_params, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ProjectLanguagesController < Admins::BaseController
|
class Admins::ProjectLanguagesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :get_language, only: [:edit,:update, :destroy]
|
before_action :get_language, only: [:edit,:update, :destroy]
|
||||||
before_action :validate_names, only: [:create, :update]
|
before_action :validate_names, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ProjectLicensesController < Admins::BaseController
|
class Admins::ProjectLicensesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :set_license, only: [:edit,:update, :destroy,:show]
|
before_action :set_license, only: [:edit,:update, :destroy,:show]
|
||||||
# before_action :validate_params, only: [:create, :update]
|
# before_action :validate_params, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ProjectsController < Admins::BaseController
|
class Admins::ProjectsController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :find_project, only: [:edit, :update]
|
before_action :find_project, only: [:edit, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -6,6 +7,16 @@ class Admins::ProjectsController < Admins::BaseController
|
||||||
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
||||||
search = params[:search].to_s.strip
|
search = params[:search].to_s.strip
|
||||||
projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}")
|
projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}")
|
||||||
|
case params[:category]
|
||||||
|
when 'public'
|
||||||
|
projects = projects.where(is_public: true)
|
||||||
|
when 'private'
|
||||||
|
projects = projects.where(is_public: false)
|
||||||
|
when 'fork'
|
||||||
|
projects = projects.where.not(forked_from_project_id: nil)
|
||||||
|
when 'original'
|
||||||
|
projects = projects.where(forked_from_project_id: nil, project_type: 'common')
|
||||||
|
end
|
||||||
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)
|
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,8 +43,12 @@ class Admins::ProjectsController < Admins::BaseController
|
||||||
def destroy
|
def destroy
|
||||||
project = Project.find_by!(id: params[:id])
|
project = Project.find_by!(id: params[:id])
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
close_fork_pull_requests_by(project)
|
||||||
Gitea::Repository::DeleteService.new(project.owner, project.identifier, current_user.gitea_token).call
|
Gitea::Repository::DeleteService.new(project.owner, project.identifier, current_user.gitea_token).call
|
||||||
project.destroy!
|
project.destroy!
|
||||||
|
project.forked_projects.update_all(forked_from_project_id: nil)
|
||||||
|
# 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
|
||||||
|
project.project_category.decrement!(:private_projects_count, 1) if project.project_category.present? && !project.is_public
|
||||||
# render_delete_success
|
# render_delete_success
|
||||||
UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json)
|
UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json)
|
||||||
redirect_to admins_projects_path
|
redirect_to admins_projects_path
|
||||||
|
@ -52,4 +67,19 @@ class Admins::ProjectsController < Admins::BaseController
|
||||||
def project_update_params
|
def project_update_params
|
||||||
params.require(:project).permit(:is_pinned, :recommend, :recommend_index)
|
params.require(:project).permit(:is_pinned, :recommend, :recommend_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def close_fork_pull_requests_by(project)
|
||||||
|
open_pull_requests = PullRequest.where(fork_project_id: project.id)
|
||||||
|
if open_pull_requests.present?
|
||||||
|
open_pull_requests.each do |pull_request|
|
||||||
|
closed = PullRequests::CloseService.call(pull_request&.project.owner, pull_request&.project.repository, pull_request, current_user)
|
||||||
|
if closed === true
|
||||||
|
pull_request.project_trends.create!(user: current_user, project: pull_request&.project,action_type: ProjectTrend::CLOSE)
|
||||||
|
# 合并请求下issue处理为关闭
|
||||||
|
pull_request.issue&.update_attributes!({status_id:5})
|
||||||
|
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, pull_request.id) if Site.has_notice_menu?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
class Admins::ProjectsRankController < Admins::BaseController
|
class Admins::ProjectsRankController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
|
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
|
||||||
@statistics = @statistics.group(:project_id).select("project_id,
|
@statistics = @statistics.group(:project_id).select("project_id,
|
||||||
|
@ -10,7 +12,7 @@ class Admins::ProjectsRankController < Admins::BaseController
|
||||||
sum(issues) as issues,
|
sum(issues) as issues,
|
||||||
sum(pullrequests) as pullrequests,
|
sum(pullrequests) as pullrequests,
|
||||||
sum(commits) as commits").includes(:project)
|
sum(commits) as commits").includes(:project)
|
||||||
@statistics = @statistics.order("#{sort_by} #{sort_direction}")
|
@statistics = paginate @statistics.order("#{sort_by} #{sort_direction}")
|
||||||
export_excel(@statistics.limit(50))
|
export_excel(@statistics.limit(50))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::ReversedKeywordsController < Admins::BaseController
|
class Admins::ReversedKeywordsController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :get_keyword, only: [:edit,:update, :destroy]
|
before_action :get_keyword, only: [:edit,:update, :destroy]
|
||||||
# before_action :validate_identifer, only: [:create, :update]
|
# before_action :validate_identifer, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::SitePagesController < Admins::BaseController
|
class Admins::SitePagesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :finder_site_page, except: [:index]
|
before_action :finder_site_page, except: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::SitesController < Admins::BaseController
|
class Admins::SitesController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :find_site, only: [:edit,:update, :destroy]
|
before_action :find_site, only: [:edit,:update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::SystemNotificationsController < Admins::BaseController
|
class Admins::SystemNotificationsController < Admins::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :get_notification, only: [:history, :edit,:update, :destroy]
|
before_action :get_notification, only: [:history, :edit,:update, :destroy]
|
||||||
# before_action :validate_identifer, only: [:create, :update]
|
# before_action :validate_identifer, only: [:create, :update]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
|
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_activity_forum, only: [:edit, :update, :destroy]
|
before_action :find_activity_forum, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::BannersController < Admins::Topic::BaseController
|
class Admins::Topic::BannersController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::CardsController < Admins::Topic::BaseController
|
class Admins::Topic::CardsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_card, only: [:edit, :update, :destroy]
|
before_action :find_card, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
|
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_cooperator, only: [:edit, :update, :destroy]
|
before_action :find_cooperator, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
|
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_excellent_project, only: [:edit, :update, :destroy]
|
before_action :find_excellent_project, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
|
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_experience_forum, only: [:edit, :update, :destroy]
|
before_action :find_experience_forum, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
|
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_glcc_admin
|
||||||
before_action :find_glcc, only: [:edit, :update, :destroy]
|
before_action :find_glcc, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
|
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
|
||||||
|
before_action :require_business
|
||||||
before_action :find_pinned_forum, only: [:edit, :update, :destroy]
|
before_action :find_pinned_forum, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::UsersController < Admins::BaseController
|
class Admins::UsersController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
before_action :finder_user, except: [:index]
|
before_action :finder_user, except: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -73,6 +74,6 @@ class Admins::UsersController < Admins::BaseController
|
||||||
def update_params
|
def update_params
|
||||||
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
|
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
|
||||||
mail phone location location_city school_id department_id admin
|
mail phone location location_city school_id department_id admin
|
||||||
password login website_permission])
|
password login website_permission business glcc_admin])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Admins::UsersRankController < Admins::BaseController
|
class Admins::UsersRankController < Admins::BaseController
|
||||||
|
before_action :require_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@rank_date = rank_date
|
@rank_date = rank_date
|
||||||
|
|
|
@ -5,6 +5,17 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::B
|
||||||
puts @result_object
|
puts @result_object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
return render_error("请输入正确的流水线文件!") if params[:workflow].blank?
|
||||||
|
return render_error("请输入正确的分支!") if params[:ref].blank?
|
||||||
|
gitea_result = $gitea_hat_client.post_repos_actions_runs_by_owner_repo(@project&.owner&.login, @project&.identifier, {query: {workflow: params[:workflow], ref: params[:ref]}})
|
||||||
|
if gitea_result
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
ender_error("启动流水线任务失败")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def rerun
|
def rerun
|
||||||
return render_error("请输入正确的流水线记录ID!") if params[:run_id].blank?
|
return render_error("请输入正确的流水线记录ID!") if params[:run_id].blank?
|
||||||
gitea_result = $gitea_hat_client.post_repos_actions_runs_rerun_by_owner_repo_run(@project&.owner&.login, @project&.identifier, params[:run_id]) rescue nil
|
gitea_result = $gitea_hat_client.post_repos_actions_runs_rerun_by_owner_repo_run(@project&.owner&.login, @project&.identifier, params[:run_id]) rescue nil
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
class Api::V1::Users::HomeTopSettingsController < Api::V1::BaseController
|
||||||
|
|
||||||
|
before_action :load_observe_user
|
||||||
|
before_action :check_auth_for_observe_user
|
||||||
|
|
||||||
|
def create
|
||||||
|
@result = Api::V1::Users::HomeTopSettings::CreateService.call(@observe_user, home_top_setting_params)
|
||||||
|
return render_error("置顶失败.") if @result.nil?
|
||||||
|
return render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def cancel
|
||||||
|
@result = Api::V1::Users::HomeTopSettings::DeleteService.call(@observe_user, home_top_setting_params)
|
||||||
|
return render_error("取消置顶失败.") if @result.nil?
|
||||||
|
return render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def home_top_setting_params
|
||||||
|
params.permit(:top_type, :top_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -78,6 +78,10 @@ class ApplicationController < ActionController::Base
|
||||||
User.current.admin? || User.current.business?
|
User.current.admin? || User.current.business?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin_or_glcc_admin?
|
||||||
|
User.current.admin? || User.current.glcc_admin?
|
||||||
|
end
|
||||||
|
|
||||||
# 判断用户的邮箱或者手机是否可用
|
# 判断用户的邮箱或者手机是否可用
|
||||||
# params[:type] 1: 注册;2:忘记密码;3:绑定
|
# params[:type] 1: 注册;2:忘记密码;3:绑定
|
||||||
def check_mail_and_phone_valid login, type
|
def check_mail_and_phone_valid login, type
|
||||||
|
@ -195,6 +199,10 @@ class ApplicationController < ActionController::Base
|
||||||
normal_status(403, "") unless admin_or_business?
|
normal_status(403, "") unless admin_or_business?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def require_glcc_admin
|
||||||
|
normal_status(403, "") unless admin_or_glcc_admin?
|
||||||
|
end
|
||||||
|
|
||||||
# 前端会捕捉401,弹登录弹框
|
# 前端会捕捉401,弹登录弹框
|
||||||
# 未授权的捕捉407,弹试用申请弹框
|
# 未授权的捕捉407,弹试用申请弹框
|
||||||
def require_login
|
def require_login
|
||||||
|
|
|
@ -64,7 +64,8 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
rescue Gitea::Api::ServerError => ex
|
rescue Gitea::Api::ServerError => ex
|
||||||
uid_logger_error(ex.message)
|
uid_logger_error(ex.message)
|
||||||
tip_exception(ex.http_code, ex.message)
|
# tip_exception(ex.http_code, ex.message)
|
||||||
|
tip_exception(ex.message)
|
||||||
rescue ApplicationService::Error => e
|
rescue ApplicationService::Error => e
|
||||||
uid_logger_error(e.message)
|
uid_logger_error(e.message)
|
||||||
tip_exception(e.message)
|
tip_exception(e.message)
|
||||||
|
@ -216,6 +217,10 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
new_project_params = project_params.except(:private).merge(is_public: !private)
|
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||||
@project.update_attributes!(new_project_params)
|
@project.update_attributes!(new_project_params)
|
||||||
|
fork_pull_requests = PullRequest.where(fork_project_id: @project.id)
|
||||||
|
if fork_pull_requests.present?
|
||||||
|
fork_pull_requests.update_all(fork_project_identifier: @project.identifier)
|
||||||
|
end
|
||||||
@project.forked_projects.map{|p| p.update!(is_public: @project.is_public)}
|
@project.forked_projects.map{|p| p.update!(is_public: @project.is_public)}
|
||||||
gitea_params = {
|
gitea_params = {
|
||||||
private: private,
|
private: private,
|
||||||
|
@ -257,6 +262,7 @@ class ProjectsController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
if current_user.admin? || @project.manager?(current_user)
|
if current_user.admin? || @project.manager?(current_user)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
close_fork_pull_requests_by(@project)
|
||||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
|
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
|
||||||
@project.destroy!
|
@project.destroy!
|
||||||
@project.forked_projects.update_all(forked_from_project_id: nil)
|
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||||
|
@ -407,4 +413,19 @@ class ProjectsController < ApplicationController
|
||||||
render_unauthorized('你还未登录.')
|
render_unauthorized('你还未登录.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def close_fork_pull_requests_by(project)
|
||||||
|
open_pull_requests = PullRequest.where(fork_project_id: project.id)
|
||||||
|
if open_pull_requests.present?
|
||||||
|
open_pull_requests.each do |pull_request|
|
||||||
|
closed = PullRequests::CloseService.call(pull_request&.project.owner, pull_request&.project.repository, pull_request, current_user)
|
||||||
|
if closed === true
|
||||||
|
pull_request.project_trends.create!(user: current_user, project: pull_request&.project,action_type: ProjectTrend::CLOSE)
|
||||||
|
# 合并请求下issue处理为关闭
|
||||||
|
pull_request.issue&.update_attributes!({status_id:5})
|
||||||
|
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, pull_request.id) if Site.has_notice_menu?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ class RepositoriesController < ApplicationController
|
||||||
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
||||||
before_action :require_profile_completed, only: [:create_file]
|
before_action :require_profile_completed, only: [:create_file]
|
||||||
before_action :load_repository
|
before_action :load_repository
|
||||||
|
before_action :require_operate_above, only: %i[create_file update_file replace_file delete_file]
|
||||||
before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive]
|
before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive]
|
||||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||||
before_action :get_ref, only: %i[entries sub_entries top_counts files archive]
|
before_action :get_ref, only: %i[entries sub_entries top_counts files archive]
|
||||||
|
@ -437,4 +438,8 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def require_operate_above
|
||||||
|
return render_forbidden if !current_user.admin? && !@project.operator?(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,15 @@ class Users::OrganizationsController < Users::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
||||||
@organizations = @organizations.includes(:organization_extension).order("organization_extensions.#{sort_by} #{sort_direction}")
|
|
||||||
|
@home_top_ids = @organizations.joins(:home_top_settings).where(home_top_settings: {user_id: observed_user.id}).order("home_top_settings.created_at asc").pluck(:id)
|
||||||
|
|
||||||
|
if @home_top_ids.present?
|
||||||
|
@organizations = @organizations.joins(:organization_extension).order("FIELD(users.id, #{@home_top_ids.join(",")}) desc, organization_extensions.#{sort_by} #{sort_direction}")
|
||||||
|
else
|
||||||
|
@organizations = @organizations.joins(:organization_extension).order("organization_extensions.#{sort_by} #{sort_direction}")
|
||||||
|
end
|
||||||
|
|
||||||
@organizations = kaminari_paginate(@organizations)
|
@organizations = kaminari_paginate(@organizations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
is_current_admin_user = User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
|
is_current_admin_user = User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
|
||||||
scope = Projects::ListMyQuery.call(params, @user,is_current_admin_user)
|
scope, @home_top_ids = Projects::ListMyQuery.call(params, @user,is_current_admin_user)
|
||||||
@total_count = scope.size
|
@total_count = scope.size
|
||||||
@projects = kaminari_unlimit_paginate(scope)
|
@projects = kaminari_unlimit_paginate(scope)
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,16 @@ class BaseForm
|
||||||
raise "项目标识已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists?
|
raise "项目标识已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_gitea_repository_name(user_id, repository_name)
|
||||||
|
user_login = User.find_by_id(user_id)&.login
|
||||||
|
begin
|
||||||
|
gitea_result = $gitea_client.get_repos_by_owner_repo(user_login, repository_name)
|
||||||
|
raise "项目标识已被使用." if gitea_result["id"].present?
|
||||||
|
rescue Gitea::Api::ServerError => e
|
||||||
|
raise "服务器错误,请联系系统管理员!" unless e.http_code.to_i == 404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def check_project_name(user_id, project_name)
|
def check_project_name(user_id, project_name)
|
||||||
raise "项目名称已被使用." if Project.where(user_id: user_id, name: project_name.strip).exists?
|
raise "项目名称已被使用." if Project.where(user_id: user_id, name: project_name.strip).exists?
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Projects::CreateForm < BaseForm
|
||||||
check_project_language(project_language_id)
|
check_project_language(project_language_id)
|
||||||
check_project_name(user_id, name) unless name.blank?
|
check_project_name(user_id, name) unless name.blank?
|
||||||
check_repository_name(user_id, repository_name) unless repository_name.blank?
|
check_repository_name(user_id, repository_name) unless repository_name.blank?
|
||||||
|
# check_gitea_repository_name(user_id, repository_name) unless repository_name.blank?
|
||||||
check_blockchain_token_all(blockchain_token_all) unless blockchain_token_all.blank?
|
check_blockchain_token_all(blockchain_token_all) unless blockchain_token_all.blank?
|
||||||
check_blockchain_init_token(blockchain_init_token) unless blockchain_init_token.blank?
|
check_blockchain_init_token(blockchain_init_token) unless blockchain_init_token.blank?
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Projects::MigrateForm < BaseForm
|
||||||
validate do
|
validate do
|
||||||
check_project_name(user_id, name) unless name.blank?
|
check_project_name(user_id, name) unless name.blank?
|
||||||
check_repository_name(user_id, repository_name) unless repository_name.blank?
|
check_repository_name(user_id, repository_name) unless repository_name.blank?
|
||||||
|
# check_gitea_repository_name(user_id, repository_name) unless repository_name.blank?
|
||||||
check_project_category(project_category_id)
|
check_project_category(project_category_id)
|
||||||
check_project_language(project_language_id)
|
check_project_language(project_language_id)
|
||||||
check_owner
|
check_owner
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Projects::UpdateForm < BaseForm
|
||||||
check_project_language(project_language_id)
|
check_project_language(project_language_id)
|
||||||
|
|
||||||
check_repository_name(user_id, identifier) unless identifier.blank? || identifier == project_identifier
|
check_repository_name(user_id, identifier) unless identifier.blank? || identifier == project_identifier
|
||||||
|
# check_gitea_repository_name(user_id, identifier) unless identifier.blank? || identifier == project_identifier
|
||||||
check_project_name(user_id, name) unless name.blank? || name == project_name
|
check_project_name(user_id, name) unless name.blank? || name == project_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -479,7 +479,7 @@ module ApplicationHelper
|
||||||
|
|
||||||
return if url.blank?
|
return if url.blank?
|
||||||
content_tag(:li) do
|
content_tag(:li) do
|
||||||
sidebar_item(url, "数据统计", icon: 'bar-chart', controller: 'root')
|
sidebar_item(url, "数据统计", icon: 'bar-chart', controller: 'root', has_permission: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ module ManageBackHelper
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def sidebar_item_group(url, text, **opts)
|
def sidebar_item_group(url, text, **opts)
|
||||||
|
if opts[:has_permission]
|
||||||
link_opts = url.start_with?('/') ? {} : { 'data-toggle': 'collapse', 'aria-expanded': false }
|
link_opts = url.start_with?('/') ? {} : { 'data-toggle': 'collapse', 'aria-expanded': false }
|
||||||
content =
|
content =
|
||||||
link_to url, link_opts do
|
link_to url, link_opts do
|
||||||
|
@ -16,8 +17,10 @@ module ManageBackHelper
|
||||||
|
|
||||||
raw content
|
raw content
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def sidebar_item(url, text, **opts)
|
def sidebar_item(url, text, **opts)
|
||||||
|
if opts[:has_permission]
|
||||||
content =
|
content =
|
||||||
link_to url, 'data-controller': opts[:controller] do
|
link_to url, 'data-controller': opts[:controller] do
|
||||||
content_tag(:i, '', class: "fa fa-#{opts[:icon]} fa-fw", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
|
content_tag(:i, '', class: "fa fa-#{opts[:icon]} fa-fw", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
|
||||||
|
@ -26,6 +29,7 @@ module ManageBackHelper
|
||||||
|
|
||||||
raw content
|
raw content
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def admin_sidebar_controller
|
def admin_sidebar_controller
|
||||||
key = params[:controller].to_s.gsub(/\//, '-')
|
key = params[:controller].to_s.gsub(/\//, '-')
|
||||||
|
|
|
@ -2,6 +2,7 @@ class CacheAsyncClearJob < ApplicationJob
|
||||||
queue_as :cache
|
queue_as :cache
|
||||||
|
|
||||||
def perform(type, id=nil)
|
def perform(type, id=nil)
|
||||||
|
return if id.nil?
|
||||||
case type
|
case type
|
||||||
when "project_common_service"
|
when "project_common_service"
|
||||||
Cache::V2::ProjectCommonService.new(id).clear
|
Cache::V2::ProjectCommonService.new(id).clear
|
||||||
|
|
|
@ -10,7 +10,7 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
||||||
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
|
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
|
||||||
puts "#gitea_repository#{gitea_repository}"
|
puts "#gitea_repository#{gitea_repository}"
|
||||||
if gitea_repository[0]==201
|
if gitea_repository[0]==201
|
||||||
repo&.project&.update_columns(gpid: gitea_repository[2]["id"])
|
repo&.project&.update_columns(gpid: gitea_repository[2]["id"], default_branch: gitea_repository[2]["default_branch"])
|
||||||
repo&.mirror&.succeeded!
|
repo&.mirror&.succeeded!
|
||||||
## open jianmu devops
|
## open jianmu devops
|
||||||
project_id = repo&.project&.id
|
project_id = repo&.project&.id
|
||||||
|
@ -24,7 +24,7 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
||||||
repo&.mirror&.failed!
|
repo&.mirror&.failed!
|
||||||
repo&.project&.update_columns(status: 0)
|
repo&.project&.update_columns(status: 0)
|
||||||
else
|
else
|
||||||
repo&.project&.update_columns(gpid: gitea_result["id"])
|
repo&.project&.update_columns(gpid: gitea_repository[2]["id"], default_branch: gitea_repository[2]["default_branch"])
|
||||||
repo&.mirror&.succeeded!
|
repo&.mirror&.succeeded!
|
||||||
project_id = repo&.project&.id
|
project_id = repo&.project&.id
|
||||||
puts "############ mirror project_id,user_id: #{project_id},#{user_id} ############"
|
puts "############ mirror project_id,user_id: #{project_id},#{user_id} ############"
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: home_top_settings
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# user_id :integer
|
||||||
|
# top_type :string(255)
|
||||||
|
# top_id :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_home_top_settings_on_top_type_and_top_id (top_type,top_id)
|
||||||
|
# index_home_top_settings_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
|
||||||
|
class HomeTopSetting < ApplicationRecord
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
belongs_to :top, polymorphic: true
|
||||||
|
end
|
|
@ -76,6 +76,7 @@ class Organization < Owner
|
||||||
has_many :team_users, dependent: :destroy
|
has_many :team_users, dependent: :destroy
|
||||||
has_many :pinned_projects, class_name: 'PinnedProject', foreign_key: :user_id, dependent: :destroy
|
has_many :pinned_projects, class_name: 'PinnedProject', foreign_key: :user_id, dependent: :destroy
|
||||||
has_many :is_pinned_projects, through: :pinned_projects, source: :project, validate: false
|
has_many :is_pinned_projects, through: :pinned_projects, source: :project, validate: false
|
||||||
|
has_many :home_top_settings, as: :top, dependent: :destroy
|
||||||
|
|
||||||
validates :login, presence: true
|
validates :login, presence: true
|
||||||
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, case_sensitive: false
|
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, case_sensitive: false
|
||||||
|
|
|
@ -138,6 +138,7 @@ class Project < ApplicationRecord
|
||||||
has_many :daily_project_statistics, dependent: :destroy
|
has_many :daily_project_statistics, dependent: :destroy
|
||||||
has_one :project_dataset, dependent: :destroy
|
has_one :project_dataset, dependent: :destroy
|
||||||
has_many :sync_repositories, dependent: :destroy
|
has_many :sync_repositories, dependent: :destroy
|
||||||
|
has_many :home_top_settings, as: :top, dependent: :destroy
|
||||||
after_create :incre_user_statistic, :incre_platform_statistic
|
after_create :incre_user_statistic, :incre_platform_statistic
|
||||||
after_save :check_project_members
|
after_save :check_project_members
|
||||||
before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned, :reset_cache_data
|
before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned, :reset_cache_data
|
||||||
|
@ -181,14 +182,14 @@ class Project < ApplicationRecord
|
||||||
end
|
end
|
||||||
if changes[:is_public].present?
|
if changes[:is_public].present?
|
||||||
if changes[:is_public][0] && !changes[:is_public][1]
|
if changes[:is_public][0] && !changes[:is_public][1]
|
||||||
CacheAsyncClearJob.perform_later('project_rank_service', self.id)
|
CacheAsyncClearJob.set(wait: 5.seconds).perform_later('project_rank_service', self.id)
|
||||||
end
|
end
|
||||||
if !changes[:is_public][0] && changes[:is_public][1]
|
if !changes[:is_public][0] && changes[:is_public][1]
|
||||||
$redis_cache.srem("v2-project-rank-deleted", self.id)
|
$redis_cache.srem("v2-project-rank-deleted", self.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !self.common?
|
if !self.common?
|
||||||
CacheAsyncClearJob.perform_later('project_rank_service', self.id)
|
CacheAsyncClearJob.set(wait: 5.seconds).perform_later('project_rank_service', self.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -461,6 +462,15 @@ class Project < ApplicationRecord
|
||||||
EduSetting.get("open_portrait_projects").present? ? EduSetting.get("open_portrait_projects").split(",").include?(self.id.to_s) : false
|
EduSetting.get("open_portrait_projects").present? ? EduSetting.get("open_portrait_projects").split(",").include?(self.id.to_s) : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_pull_request(branch_name)
|
||||||
|
return true if self.pull_requests.opening.where(head: branch_name).present? || self.pull_requests.opening.where(base: branch_name).present?
|
||||||
|
if self.forked_from_project_id.present?
|
||||||
|
return true if self.fork_project.pull_requests.opening.where(head: branch_name).present? || self.fork_project.pull_requests.opening.where(base: branch_name).present?
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def self.mindspore_contributors
|
def self.mindspore_contributors
|
||||||
cache_result = $redis_cache.get("ProjectMindsporeContributors")
|
cache_result = $redis_cache.get("ProjectMindsporeContributors")
|
||||||
if cache_result.nil?
|
if cache_result.nil?
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
# comments_count :integer default("0")
|
# comments_count :integer default("0")
|
||||||
# commits_count :integer default("0")
|
# commits_count :integer default("0")
|
||||||
# files_count :integer default("0")
|
# files_count :integer default("0")
|
||||||
|
# fork_project_owner :string(255)
|
||||||
|
# fork_project_identifier :string(255)
|
||||||
#
|
#
|
||||||
|
|
||||||
class PullRequest < ApplicationRecord
|
class PullRequest < ApplicationRecord
|
||||||
|
|
|
@ -190,6 +190,7 @@ class User < Owner
|
||||||
has_many :clas, through: :user_clas
|
has_many :clas, through: :user_clas
|
||||||
|
|
||||||
has_one :page, :dependent => :destroy
|
has_one :page, :dependent => :destroy
|
||||||
|
has_many :home_top_settings, dependent: :destroy
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||||
|
@ -836,6 +837,10 @@ class User < Owner
|
||||||
admin? || business?
|
admin? || business?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin_or_glcc_admin?
|
||||||
|
admin? || glcc_admin?
|
||||||
|
end
|
||||||
|
|
||||||
def self.generate_login(prefix)
|
def self.generate_login(prefix)
|
||||||
login = prefix + LOGIN_CHARS.sample(8).join('')
|
login = prefix + LOGIN_CHARS.sample(8).join('')
|
||||||
while User.exists?(login: login)
|
while User.exists?(login: login)
|
||||||
|
|
|
@ -20,11 +20,11 @@ class Projects::ListMyQuery < ApplicationQuery
|
||||||
if params[:category].blank?
|
if params[:category].blank?
|
||||||
normal_projects = projects.members_projects(user.id).to_sql
|
normal_projects = projects.members_projects(user.id).to_sql
|
||||||
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
|
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
|
||||||
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
|
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects")#.distinct
|
||||||
elsif params[:category].to_s == "join"
|
elsif params[:category].to_s == "join"
|
||||||
normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql
|
normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql
|
||||||
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
|
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
|
||||||
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
|
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects")#.distinct
|
||||||
elsif params[:category].to_s == "manage"
|
elsif params[:category].to_s == "manage"
|
||||||
projects = projects.where(user_id: user.id)
|
projects = projects.where(user_id: user.id)
|
||||||
elsif params[:category].to_s == "watched" #我关注的
|
elsif params[:category].to_s == "watched" #我关注的
|
||||||
|
@ -37,7 +37,7 @@ class Projects::ListMyQuery < ApplicationQuery
|
||||||
elsif params[:category].to_s == "admin"
|
elsif params[:category].to_s == "admin"
|
||||||
normal_projects = projects.joins(members: :roles).where(members: {user_id: user.id}, roles: {name: %w(Manager)}).to_sql
|
normal_projects = projects.joins(members: :roles).where(members: {user_id: user.id}, roles: {name: %w(Manager)}).to_sql
|
||||||
org_projects = projects.joins(team_projects: [team: :team_users]).where(teams: {authorize: %w(owner admin)},team_users: {user_id: user.id}).to_sql
|
org_projects = projects.joins(team_projects: [team: :team_users]).where(teams: {authorize: %w(owner admin)},team_users: {user_id: user.id}).to_sql
|
||||||
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
|
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects")#.distinct
|
||||||
# elsif params[:category].to_s == "public"
|
# elsif params[:category].to_s == "public"
|
||||||
# projects = projects.visible.joins(:members).where(members: { user_id: user.id })
|
# projects = projects.visible.joins(:members).where(members: { user_id: user.id })
|
||||||
# elsif params[:category].to_s == "private"
|
# elsif params[:category].to_s == "private"
|
||||||
|
@ -72,10 +72,18 @@ class Projects::ListMyQuery < ApplicationQuery
|
||||||
sort = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : "updated_on"
|
sort = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : "updated_on"
|
||||||
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : "desc"
|
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : "desc"
|
||||||
|
|
||||||
|
@home_top_ids = scope.joins(:home_top_settings).where(home_top_settings: {user_id: user.id}).order("home_top_settings.created_at asc").pluck(:id)
|
||||||
|
|
||||||
if params[:choosed].present? && params[:choosed].is_a?(Array)
|
if params[:choosed].present? && params[:choosed].is_a?(Array)
|
||||||
scope.order("FIELD(id, #{params[:choosed].reverse.join(",")}) desc")
|
scope = scope.distinct.order("FIELD(projects.id, #{params[:choosed].reverse.join(",")}) desc")
|
||||||
else
|
else
|
||||||
scope.order("projects.#{sort} #{sort_direction}")
|
if @home_top_ids.present?
|
||||||
|
scope = scope.distinct.order("FIELD(projects.id, #{@home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}")
|
||||||
|
else
|
||||||
|
scope = scope.distinct.order("projects.#{sort} #{sort_direction}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return scope, @home_top_ids
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Admins::UpdateUserService < ApplicationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def user_attributes
|
def user_attributes
|
||||||
params.slice(*%i[lastname nickname mail phone admin business is_test login
|
params.slice(*%i[lastname nickname mail phone admin business glcc_admin is_test login
|
||||||
professional_certification authentication is_shixun_marker website_permission])
|
professional_certification authentication is_shixun_marker website_permission])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
class Api::V1::Users::HomeTopSettings::CreateService < ApplicationService
|
||||||
|
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_reader :user, :top_type, :top_id
|
||||||
|
attr_accessor :home_top_setting, :home_top
|
||||||
|
|
||||||
|
validates :user, :top_type, :top_id, presence: true
|
||||||
|
validates :top_type, inclusion: {in: %w(Organization Project), message: '请输入正确的TopType'}
|
||||||
|
|
||||||
|
def initialize(user, params)
|
||||||
|
@user = user
|
||||||
|
@top_type = params[:top_type]
|
||||||
|
@top_id = params[:top_id]
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
raise Error, errors.full_messages.join(",") unless valid?
|
||||||
|
raise Error, "置顶对象不存在!" unless find_home_top
|
||||||
|
raise Error, "置顶对象已置顶!" if check_home_top_setting
|
||||||
|
|
||||||
|
begin
|
||||||
|
@home_top_setting = HomeTopSetting.new(user:user, top: @home_top)
|
||||||
|
@home_top_setting.save!
|
||||||
|
|
||||||
|
return @home_top_setting.valid? ? @home_top_setting : nil
|
||||||
|
rescue
|
||||||
|
raise Error, "服务器错误,请联系系统管理员!"
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_home_top
|
||||||
|
@home_top = @top_type.constantize.find_by_id(@top_id).presence
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_home_top_setting
|
||||||
|
HomeTopSetting.exists?(user: @user, top: @home_top)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,40 @@
|
||||||
|
class Api::V1::Users::HomeTopSettings::DeleteService < ApplicationService
|
||||||
|
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_reader :user, :top_type, :top_id
|
||||||
|
attr_accessor :home_top_setting, :home_top
|
||||||
|
|
||||||
|
validates :user, :top_type, :top_id, presence: true
|
||||||
|
validates :top_type, inclusion: {in: %w(Organization Project), message: '请输入正确的TopType'}
|
||||||
|
|
||||||
|
def initialize(user, params)
|
||||||
|
@user = user
|
||||||
|
@top_type = params[:top_type]
|
||||||
|
@top_id = params[:top_id]
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
raise Error, errors.full_messages.join(",") unless valid?
|
||||||
|
raise Error, "置顶对象不存在!" unless find_home_top
|
||||||
|
raise Error, "置顶对象未置顶!" unless check_home_top_setting
|
||||||
|
|
||||||
|
begin
|
||||||
|
@home_top_setting = HomeTopSetting.find_by(user:user, top: @home_top)
|
||||||
|
@home_top_setting.destroy!
|
||||||
|
|
||||||
|
return true
|
||||||
|
rescue
|
||||||
|
raise Error, "服务器错误,请联系系统管理员!"
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_home_top
|
||||||
|
@home_top = @top_type.constantize.find_by_id(@top_id).presence
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_home_top_setting
|
||||||
|
HomeTopSetting.exists?(user: @user, top: @home_top)
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,6 +15,7 @@ class Projects::TransferService < ApplicationService
|
||||||
update_repo_url
|
update_repo_url
|
||||||
update_visit_teams
|
update_visit_teams
|
||||||
update_fork_info
|
update_fork_info
|
||||||
|
update_fork_pull_request_info
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.info("##### Project transfer_service end ######")
|
Rails.logger.info("##### Project transfer_service end ######")
|
||||||
|
@ -49,6 +50,11 @@ class Projects::TransferService < ApplicationService
|
||||||
fork_user.update(user_id: @new_owner.id) if fork_user.present?
|
fork_user.update(user_id: @new_owner.id) if fork_user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_fork_pull_request_info
|
||||||
|
fork_pull_requests = PullRequest.where(fork_project_id: @project.id)
|
||||||
|
fork_pull_requests.update_all(fork_project_owner: @new_owner&.login) if fork_pull_requests.present?
|
||||||
|
end
|
||||||
|
|
||||||
def gitea_update_owner
|
def gitea_update_owner
|
||||||
begin
|
begin
|
||||||
@gitea_repo = $gitea_hat_client.post_repos_transfer_by_owner_repo(owner&.login, project.identifier, {body: {new_owner: new_owner&.login}.to_json})
|
@gitea_repo = $gitea_hat_client.post_repos_transfer_by_owner_repo(owner&.login, project.identifier, {body: {new_owner: new_owner&.login}.to_json})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class PullRequests::CreateService < ApplicationService
|
class PullRequests::CreateService < ApplicationService
|
||||||
|
|
||||||
attr_reader :current_user, :owner, :project, :params
|
attr_reader :current_user, :owner, :project, :params, :fork_project
|
||||||
attr_accessor :pull_issue, :pull_request
|
attr_accessor :pull_issue, :pull_request
|
||||||
|
|
||||||
def initialize(current_user, owner, project, params)
|
def initialize(current_user, owner, project, params)
|
||||||
|
@ -8,6 +8,7 @@ class PullRequests::CreateService < ApplicationService
|
||||||
@project = project
|
@project = project
|
||||||
@params = params
|
@params = params
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
|
@fork_project = Project.find_by_id(params[:fork_project_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
@ -102,7 +103,9 @@ class PullRequests::CreateService < ApplicationService
|
||||||
fork_project_id: @params[:fork_project_id],
|
fork_project_id: @params[:fork_project_id],
|
||||||
is_original: is_original,
|
is_original: is_original,
|
||||||
files_count: @params[:files_count] || 0,
|
files_count: @params[:files_count] || 0,
|
||||||
commits_count: @params[:commits_count] || 0
|
commits_count: @params[:commits_count] || 0,
|
||||||
|
fork_project_owner: @fork_project&.owner&.login,
|
||||||
|
fork_project_identifier: @fork_project&.identifier
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ class Repositories::CreateService < ApplicationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_gitea_repository
|
def create_gitea_repository
|
||||||
|
begin
|
||||||
|
@gitea_repository = $gitea_client.get_repos_by_owner_repo(project.owner.login, params[:identifier])
|
||||||
|
rescue Gitea::Api::ServerError => e
|
||||||
|
if e.http_code.to_i == 404
|
||||||
if project.owner.is_a?(User)
|
if project.owner.is_a?(User)
|
||||||
# @gitea_repository = Gitea::Repository::CreateService.new(user.gitea_token, gitea_repository_params).call
|
# @gitea_repository = Gitea::Repository::CreateService.new(user.gitea_token, gitea_repository_params).call
|
||||||
@gitea_repository = $gitea_client.post_user_repos({query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
|
@gitea_repository = $gitea_client.post_user_repos({query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
|
||||||
|
@ -45,11 +49,16 @@ class Repositories::CreateService < ApplicationService
|
||||||
# @gitea_repository = Gitea::Organization::Repository::CreateService.call(user.gitea_token, project.owner.login, gitea_repository_params)
|
# @gitea_repository = Gitea::Organization::Repository::CreateService.call(user.gitea_token, project.owner.login, gitea_repository_params)
|
||||||
@gitea_repository = $gitea_client.post_orgs_repos_by_org(project.owner.login, {query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
|
@gitea_repository = $gitea_client.post_orgs_repos_by_org(project.owner.login, {query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
raise "服务器错误,请联系系统管理员!"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_project
|
def sync_project
|
||||||
if gitea_repository
|
if gitea_repository
|
||||||
project.update_columns(
|
project.update_columns(
|
||||||
|
is_public: !gitea_repository["private"],
|
||||||
gpid: gitea_repository["id"],
|
gpid: gitea_repository["id"],
|
||||||
identifier: repository.identifier,
|
identifier: repository.identifier,
|
||||||
default_branch: gitea_repository["default_branch"],
|
default_branch: gitea_repository["default_branch"],
|
||||||
|
@ -58,7 +67,7 @@ class Repositories::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_repository
|
def sync_repository
|
||||||
repository.update_columns(url: remote_repository_url,) if gitea_repository
|
repository.update_columns(url: remote_repository_url, hidden: gitea_repository["private"]) if gitea_repository
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_repository_url
|
def remote_repository_url
|
||||||
|
|
|
@ -3,10 +3,15 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="box search-form-container project-list-form">
|
<div class="box search-form-container project-list-form">
|
||||||
<%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
<%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', id: 'project-list-form', remote: true) do %>
|
||||||
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目名称/标识检索') %>
|
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目名称/标识检索') %>
|
||||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||||
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
|
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
|
||||||
|
<div class="form-group mr-2 pull-right" style='margin-left:auto'>
|
||||||
|
<label for="status">项目类别:</label>
|
||||||
|
<% type_options = [['全部项目', ''], ['公开项目', 'public'], ['私有项目', 'private'], ['Fork项目', 'fork'], ['原创项目', 'original']] %>
|
||||||
|
<%= select_tag(:category, options_for_select(type_options, params[:category]), class: 'form-control', id: 'project-category') %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -16,3 +21,9 @@
|
||||||
|
|
||||||
<div id="projects-modals">
|
<div id="projects-modals">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$("#project-category").on('change', function() {
|
||||||
|
$("#project-list-form").submit()
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -16,7 +16,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% statistics.each_with_index do |item, index| %>
|
<% statistics.each_with_index do |item, index| %>
|
||||||
<tr class="">
|
<tr class="">
|
||||||
<td><%= index + 1%></td>
|
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||||
<td>
|
<td>
|
||||||
<a target="_blank" href="<%= "/#{item&.project&.owner&.login}/#{item&.project&.identifier}"%>">
|
<a target="_blank" href="<%= "/#{item&.project&.owner&.login}/#{item&.project&.identifier}"%>">
|
||||||
<%= "#{item&.project&.owner&.real_name}/#{item&.project&.name}" %>
|
<%= "#{item&.project&.owner&.real_name}/#{item&.project&.name}" %>
|
||||||
|
@ -35,3 +35,5 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/shared/paginate', locals: { objects: statistics } %>
|
|
@ -13,85 +13,85 @@
|
||||||
|
|
||||||
<!-- Sidebar Links -->
|
<!-- Sidebar Links -->
|
||||||
<ul class="list-unstyled components">
|
<ul class="list-unstyled components">
|
||||||
<li><%= sidebar_item(admins_path, '数据概览', icon: 'dashboard', controller: 'admins-dashboards') %></li>
|
<li><%= sidebar_item(admins_path, '数据概览', icon: 'dashboard', controller: 'admins-dashboards', has_permission: current_user.admin?) %></li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user') do %>
|
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user', has_permission: current_user.admin?) do %>
|
||||||
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users') %></li>
|
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations') %></li>
|
<li><%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations', has_permission: current_user.admin?) %></li>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-submenu', '用户支持', icon: 'cogs') do %>
|
<%= sidebar_item_group('#setting-submenu', '用户支持', icon: 'cogs', has_permission: current_user.admin? || current_user.business?) do %>
|
||||||
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %></li>
|
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_nps_path, 'NPS用户调研', icon: 'question-circle', controller: 'admins-nps') %></li>
|
<li><%= sidebar_item(admins_nps_path, 'NPS用户调研', icon: 'question-circle', controller: 'admins-nps', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_feedbacks_path, '用户反馈', icon: 'question-circle', controller: 'admins-feedbacks') %></li>
|
<li><%= sidebar_item(admins_feedbacks_path, '用户反馈', icon: 'question-circle', controller: 'admins-feedbacks', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_system_notifications_path, '系统公告配置', icon: 'bell', controller: 'admins-system_notifications') %></li>
|
<li><%= sidebar_item(admins_system_notifications_path, '系统公告配置', icon: 'bell', controller: 'admins-system_notifications', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li><%= sidebar_item(admins_laboratories_path, '导航栏配置', icon: 'cloud', controller: 'admins-laboratories') %></li>
|
<li><%= sidebar_item(admins_laboratories_path, '导航栏配置', icon: 'cloud', controller: 'admins-laboratories', has_permission: current_user.admin?) %></li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-system', '开发者配置', icon: 'wrench') do %>
|
<%= sidebar_item_group('#setting-system', '开发者配置', icon: 'wrench', has_permission: current_user.admin?) do %>
|
||||||
<li><%= sidebar_item(admins_sites_path, 'setting接口配置', icon: 'deaf', controller: 'admins-sites') %></li>
|
<li><%= sidebar_item(admins_sites_path, 'setting接口配置', icon: 'deaf', controller: 'admins-sites', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_edu_settings_path, '全局变量配置', icon: 'pencil-square', controller: 'admins-edu_settings') %></li>
|
<li><%= sidebar_item(admins_edu_settings_path, '全局变量配置', icon: 'pencil-square', controller: 'admins-edu_settings', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_message_templates_path, '消息模版配置', icon: 'folder', controller: 'admins-message_templates') %></li>
|
<li><%= sidebar_item(admins_message_templates_path, '消息模版配置', icon: 'folder', controller: 'admins-message_templates', has_permission: current_user.admin?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li><%= sidebar_item(admins_reversed_keywords_path, '禁用词管理', icon: 'key', controller: 'admins-reversed_keywords') %></li>
|
<li><%= sidebar_item(admins_reversed_keywords_path, '禁用词管理', icon: 'key', controller: 'admins-reversed_keywords', has_permission: current_user.admin?) %></li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#projects-submenu', '开源项目', icon: 'database') do %>
|
<%= sidebar_item_group('#projects-submenu', '开源项目', icon: 'database', has_permission: current_user.admin?) do %>
|
||||||
<li><%= sidebar_item(admins_projects_path, '项目列表', icon: 'database', controller: 'admins-projects') %></li>
|
<li><%= sidebar_item(admins_projects_path, '项目列表', icon: 'database', controller: 'admins-projects', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_project_languages_path, '项目语言', icon: 'language', controller: 'admins-project_languages') %></li>
|
<li><%= sidebar_item(admins_project_languages_path, '项目语言', icon: 'language', controller: 'admins-project_languages', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %></li>
|
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %></li>
|
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %></li>
|
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores', has_permission: current_user.admin?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-index', '首页配置', icon: 'file') do %>
|
<%= sidebar_item_group('#setting-index', '首页配置', icon: 'file', has_permission: current_user.admin? || current_user.business?) do %>
|
||||||
<li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners') %></li>
|
<li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards') %></li>
|
<!--<li><%#= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %></li>-->
|
||||||
<li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums') %></li>
|
<li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects') %></li>
|
<li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums') %></li>
|
<li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_topic_experience_forums_path, '经验分享管理', icon: 'edit', controller: 'admins-topic-experience_forums') %></li>
|
<li><%= sidebar_item(admins_topic_experience_forums_path, '经验分享管理', icon: 'edit', controller: 'admins-topic-experience_forums', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators') %></li>
|
<li><%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire') do %>
|
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire', has_permission: current_user.admin? || current_user.glcc_admin?) do %>
|
||||||
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news') %></li>
|
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news', has_permission: current_user.admin? || current_user.glcc_admin?) %></li>
|
||||||
<li>
|
<li>
|
||||||
<% if EduSetting.get("glcc_apply_informations_admin_url")%>
|
<% if EduSetting.get("glcc_apply_informations_admin_url")%>
|
||||||
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root') %>
|
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root', has_permission: current_user.admin? || current_user.glcc_admin?) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li><%= sidebar_item(admins_glcc_pr_check_index_path, '考核PR检测', icon: 'edit', controller: 'admins-glcc_pr_check') %></li>
|
<li><%= sidebar_item(admins_glcc_pr_check_index_path, '考核PR检测', icon: 'edit', controller: 'admins-glcc_pr_check', has_permission: current_user.admin? || current_user.glcc_admin?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#pages-submenu', '个人站点管理', icon: 'cogs') do %>
|
<%= sidebar_item_group('#pages-submenu', '个人站点管理', icon: 'cogs', has_permission: current_user.admin? || current_user.business?) do %>
|
||||||
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications') %></li>
|
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications', has_permission: current_user.admin? || current_user.business?) %></li>
|
||||||
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'sitemap', controller: 'admins-site_pages') %></li>
|
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'sitemap', controller: 'admins-site_pages', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_page_themes_path, '站点主题配置', icon: 'cogs', controller: 'admins-page_themes') %></li>
|
<li><%= sidebar_item(admins_page_themes_path, '站点主题配置', icon: 'cogs', controller: 'admins-page_themes', has_permission: current_user.admin?) %></li>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#rank-submenu', '活跃度排行', icon: 'calendar') do %>
|
<%= sidebar_item_group('#rank-submenu', '活跃度排行', icon: 'calendar', has_permission: current_user.admin?) do %>
|
||||||
<li><%= sidebar_item(admins_users_rank_index_path, '用户活跃度排行', icon: 'user', controller: 'admins-users_rank') %></li>
|
<li><%= sidebar_item(admins_users_rank_index_path, '用户活跃度排行', icon: 'user', controller: 'admins-users_rank', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_projects_rank_index_path, '项目活跃度排行', icon: 'database', controller: 'admins-projects_rank') %></li>
|
<li><%= sidebar_item(admins_projects_rank_index_path, '项目活跃度排行', icon: 'database', controller: 'admins-projects_rank', has_permission: current_user.admin?) %></li>
|
||||||
<li><%= sidebar_item(admins_issues_rank_index_path, '疑修活跃度排行', icon: 'calendar', controller: 'admins-issues_rank') %></li>
|
<li><%= sidebar_item(admins_issues_rank_index_path, '疑修活跃度排行', icon: 'calendar', controller: 'admins-issues_rank', has_permission: current_user.admin?) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<%= render_admin_statistics_item %>
|
<%= render_admin_statistics_item if current_user.admin? || current_user.business? %>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root') %>
|
<%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root', has_permission: current_user.admin?) %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>
|
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root', has_permission: current_user.admin?) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -89,6 +89,8 @@
|
||||||
<%= f.label :role, label: '角色' %>
|
<%= f.label :role, label: '角色' %>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<%= f.input :admin, as: :boolean, label: '管理员', checked_value: 1, unchecked_value: 0 %>
|
<%= f.input :admin, as: :boolean, label: '管理员', checked_value: 1, unchecked_value: 0 %>
|
||||||
|
<%= f.input :business, as: :boolean, label: '运营人员', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
|
||||||
|
<%= f.input :glcc_admin, as: :boolean, label: 'GLCC管理员', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
json.total_count @result_object[:total_data].to_i
|
json.total_count @result_object[:total_data].to_i
|
||||||
json.branches @result_object[:data].each do |branch|
|
json.branches @result_object[:data].each do |branch|
|
||||||
json.partial! "api/v1/projects/branches/simple_gitea_detail", branch: branch, default_branch: @result_object[:default_branch]
|
json.partial! "api/v1/projects/branches/simple_gitea_detail", branch: branch, default_branch: @result_object[:default_branch]
|
||||||
|
json.has_pull_request @project.has_pull_request(branch['name'])
|
||||||
end
|
end
|
|
@ -12,6 +12,7 @@ if tag.present? && tag.is_a?(Hash)
|
||||||
end
|
end
|
||||||
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
||||||
json.created_at_unix tag['tagger']['date'].to_time.to_i
|
json.created_at_unix tag['tagger']['date'].to_time.to_i
|
||||||
|
json.created_time tag['tagger']['date'].to_time
|
||||||
json.message tag['message']
|
json.message tag['message']
|
||||||
json.commit do
|
json.commit do
|
||||||
json.sha tag['commit']['sha']
|
json.sha tag['commit']['sha']
|
||||||
|
|
|
@ -5,5 +5,6 @@ json.projects @projects.each do |project|
|
||||||
json.type project.numerical_for_project_type
|
json.type project.numerical_for_project_type
|
||||||
json.praised project.praised_by?(current_user)
|
json.praised project.praised_by?(current_user)
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
json.full_last_update_time project.updated_on
|
||||||
json.time_ago time_from_now(project.updated_on)
|
json.time_ago time_from_now(project.updated_on)
|
||||||
end
|
end
|
|
@ -13,6 +13,7 @@ json.is_public project.is_public
|
||||||
json.mirror_url project.repository&.mirror_url
|
json.mirror_url project.repository&.mirror_url
|
||||||
json.type project&.numerical_for_project_type
|
json.type project&.numerical_for_project_type
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
json.full_last_update_time project.updated_on
|
||||||
json.time_ago time_from_now(project.updated_on)
|
json.time_ago time_from_now(project.updated_on)
|
||||||
json.forked_from_project_id project.forked_from_project_id
|
json.forked_from_project_id project.forked_from_project_id
|
||||||
json.open_devops project.open_devops?
|
json.open_devops project.open_devops?
|
||||||
|
|
|
@ -13,6 +13,7 @@ json.projects @projects do |project|
|
||||||
json.mirror_url project.repository&.mirror_url
|
json.mirror_url project.repository&.mirror_url
|
||||||
json.type project&.numerical_for_project_type
|
json.type project&.numerical_for_project_type
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
json.full_last_update_time project.updated_on
|
||||||
json.time_ago time_from_now(project.updated_on)
|
json.time_ago time_from_now(project.updated_on)
|
||||||
json.forked_from_project_id project.forked_from_project_id
|
json.forked_from_project_id project.forked_from_project_id
|
||||||
json.open_devops project.open_devops?
|
json.open_devops project.open_devops?
|
||||||
|
|
|
@ -23,15 +23,16 @@ json.issues do
|
||||||
json.pull_request_base pr.base
|
json.pull_request_base pr.base
|
||||||
json.pull_request_staus pr.status == 1 ? "merged" : (pr.status == 2 ? "closed" : "open")
|
json.pull_request_staus pr.status == 1 ? "merged" : (pr.status == 2 ? "closed" : "open")
|
||||||
json.is_original pr.is_original
|
json.is_original pr.is_original
|
||||||
json.fork_project_id pr.fork_project_id.present? ? pr.fork_project_id : pr.project_id
|
json.fork_project_id pr.fork_project_id
|
||||||
json.fork_project_identifier pr.fork_project_id.present? ? pr&.fork_project&.identifier : pr.project&.identifier
|
json.fork_project_identifier pr.fork_project.present? ? pr&.fork_project&.identifier : pr.fork_project_identifier
|
||||||
json.fork_project_user pr.fork_project_id.present? ? pr&.fork_project&.owner.try(:login) : pr.project&.owner.try(:login)
|
json.fork_project_user pr.fork_project.present? ? pr&.fork_project&.owner.try(:login) : pr.fork_project_owner
|
||||||
json.fork_project_user_name pr.fork_project_id.present? ? pr&.fork_project&.owner.try(:show_real_name) : pr.project&.owner.try(:show_real_name)
|
json.fork_project_user_name pr.fork_project.present? ? pr&.fork_project&.owner.try(:show_real_name) : User.find_by(login: pr.fork_project_owner).try(:show_real_name)
|
||||||
json.reviewers pr.reviewers.pluck(:login)
|
json.reviewers pr.reviewers.pluck(:login)
|
||||||
|
|
||||||
json.id issue.id
|
json.id issue.id
|
||||||
json.name issue.subject
|
json.name issue.subject
|
||||||
json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on)
|
json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on)
|
||||||
|
json.pr_full_time pr.status == 1 ? pr.updated_at : issue.updated_on
|
||||||
json.assign_user_name issue.get_assign_user.try(:show_real_name)
|
json.assign_user_name issue.get_assign_user.try(:show_real_name)
|
||||||
json.assign_user_login issue.get_assign_user.try(:login)
|
json.assign_user_login issue.get_assign_user.try(:login)
|
||||||
json.author_name issue.user.try(:show_real_name)
|
json.author_name issue.user.try(:show_real_name)
|
||||||
|
|
|
@ -25,9 +25,10 @@ end
|
||||||
json.pull_request do
|
json.pull_request do
|
||||||
json.extract! @pull_request, :id,:base, :head, :status, :is_original
|
json.extract! @pull_request, :id,:base, :head, :status, :is_original
|
||||||
json.pull_request_staus @pull_request.status == 1 ? "merged" : (@pull_request.status == 2 ? "closed" : "open")
|
json.pull_request_staus @pull_request.status == 1 ? "merged" : (@pull_request.status == 2 ? "closed" : "open")
|
||||||
json.fork_project_id @pull_request.fork_project_id.present? ? @pull_request.fork_project_id : @pull_request.project_id
|
json.fork_project_id @pull_request.fork_project_id
|
||||||
json.fork_project_user @pull_request.fork_project_id.present? ? @pull_request&.fork_project&.owner.try(:login) : @pull_request.project&.owner.try(:login)
|
json.fork_project_identifier @pull_request.fork_project.present? ? @pull_request&.fork_project&.identifier : @pull_request.fork_project_identifier
|
||||||
json.fork_project_user_name @pull_request.fork_project_id.present? ? @pull_request&.fork_project&.owner.try(:show_real_name) : @pull_request.project&.owner.try(:show_real_name)
|
json.fork_project_user @pull_request.fork_project.present? ? @pull_request&.fork_project&.owner.try(:login) : @pull_request.fork_project_owner
|
||||||
|
json.fork_project_user_name @pull_request.fork_project.present? ? @pull_request&.fork_project&.owner.try(:show_real_name) : User.find_by(login: @pull_request.fork_project_owner).try(:show_real_name)
|
||||||
json.create_user @pull_request&.user&.login
|
json.create_user @pull_request&.user&.login
|
||||||
json.mergeable @gitea_pull["mergeable"]
|
json.mergeable @gitea_pull["mergeable"]
|
||||||
json.state @gitea_pull["state"]
|
json.state @gitea_pull["state"]
|
||||||
|
|
|
@ -10,6 +10,7 @@ json.tags @tags do |tag|
|
||||||
end
|
end
|
||||||
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
json.time_ago time_from_now(tag['tagger']['date'].to_time)
|
||||||
json.created_at_unix tag['tagger']['date'].to_time.to_i
|
json.created_at_unix tag['tagger']['date'].to_time.to_i
|
||||||
|
json.created_time tag['tagger']['date'].to_time
|
||||||
json.message tag['message']
|
json.message tag['message']
|
||||||
json.commit do
|
json.commit do
|
||||||
json.sha tag['commit']['sha']
|
json.sha tag['commit']['sha']
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
json.total_count @organizations.total_count
|
json.total_count @organizations.total_count
|
||||||
json.organizations @organizations do |organization|
|
json.organizations @organizations do |organization|
|
||||||
json.partial! "/organizations/organizations/detail", organization: organization
|
json.partial! "/organizations/organizations/detail", organization: organization
|
||||||
|
json.is_home_top @home_top_ids.include?(organization.id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
json.count @total_count
|
json.count @total_count
|
||||||
json.projects do
|
json.projects @projects do |project|
|
||||||
json.partial! '/projects/project_detail', collection: @projects, as: :project
|
json.partial! '/projects/project_detail', project: project
|
||||||
|
json.is_home_top @home_top_ids.include?(project.id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,11 @@ defaults format: :json do
|
||||||
scope module: :users do
|
scope module: :users do
|
||||||
resources :projects, only: [:index]
|
resources :projects, only: [:index]
|
||||||
resources :feedbacks, only: [:create]
|
resources :feedbacks, only: [:create]
|
||||||
|
resources :home_top_settings, only: [:create] do
|
||||||
|
collection do
|
||||||
|
delete :cancel
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :openkylin_sign, only: [:create] do
|
resources :openkylin_sign, only: [:create] do
|
||||||
collection do
|
collection do
|
||||||
get :competitions
|
get :competitions
|
||||||
|
@ -95,7 +100,7 @@ defaults format: :json do
|
||||||
collection do
|
collection do
|
||||||
post :disable
|
post :disable
|
||||||
post :enable
|
post :enable
|
||||||
resources :runs, only: [:index] do
|
resources :runs, only: [:index, :create] do
|
||||||
post '/jobs/:job', to: 'runs#job_show'
|
post '/jobs/:job', to: 'runs#job_show'
|
||||||
post '/rerun', to: 'runs#rerun'
|
post '/rerun', to: 'runs#rerun'
|
||||||
post '/jobs/:job/rerun', to: 'runs#job_rerun'
|
post '/jobs/:job/rerun', to: 'runs#job_rerun'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddGlccAdminFieldToUsers < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :users, :glcc_admin, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateHomeTopSettings < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :home_top_settings do |t|
|
||||||
|
t.references :user
|
||||||
|
t.references :top, polymorphic: true, index: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddForkProjectOwnerIdentifierToPullRequests < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :pull_requests, :fork_project_owner, :string
|
||||||
|
add_column :pull_requests, :fork_project_identifier, :string
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue