website update
This commit is contained in:
parent
761021d191
commit
d590e1165e
|
@ -17,23 +17,31 @@ class SitePagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
return normal_status(-1, "你还未开通Page服务,无法进行部署") unless current_user.website_permission
|
return normal_status(-1, '你还未开通Page服务,无法进行部署') unless current_user.website_permission
|
||||||
return normal_status(-1, "你已使用了 #{params[:identifier]} 作为page标识") if Page.exists?(identifier: params[:identifier], user: current_user)
|
return normal_status(-1, '你已开通Page服务') if Page.exists?(user: current_user)
|
||||||
return normal_status(-1, "该仓库已开通Page服务") if Page.exists?(project: @project)
|
return normal_status(-1, '该仓库已开通Page服务') if Page.exists?(project: @project)
|
||||||
@page = Page.new(create_params)
|
@page = Page.new(create_params)
|
||||||
@page.user = current_user
|
@page.user = current_user
|
||||||
@page.project = @project
|
@page.project = @project
|
||||||
@page.save
|
@page.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
return normal_status(-1, '你还未开通Page服务') unless current_user.website_permission
|
||||||
|
return normal_status(-1, '你还未开通Page站点') unless Page.exists?(user: current_user)
|
||||||
|
@page = Page.find_by(user: current_user)
|
||||||
|
@page.update(language_frame: params[:language_frame])
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
def build
|
def build
|
||||||
return normal_status(-1, "你还未开通Page服务,无法进行部署") unless current_user.website_permission
|
return normal_status(-1, '你还未开通Page服务,无法进行部署') unless current_user.website_permission
|
||||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") unless Page.exists?(project: @project)
|
return normal_status(-1, '该仓库还未开通Page服务,无法进行部署') unless Page.exists?(project: @project)
|
||||||
@page = Page.find params[:id]
|
@page = Page.find params[:id]
|
||||||
return normal_status(-1, @page.state_description) unless @page.state
|
return normal_status(-1, @page.state_description) unless @page.state
|
||||||
response_str = @page.deploy_page(params[:branch])
|
response_str = @page.deploy_page(params[:branch])
|
||||||
data = JSON.parse(response_str)["result"] || data = JSON.parse(response_str)["error"]
|
data = JSON.parse(response_str)['result'] || (data = JSON.parse(response_str)['error'])
|
||||||
if data.to_s.include?("部署成功")
|
if data.to_s.include?('部署成功')
|
||||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||||
else
|
else
|
||||||
@page.update(build_state:false, last_build_info: data)
|
@page.update(build_state:false, last_build_info: data)
|
||||||
|
@ -42,22 +50,22 @@ class SitePagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def softbot_build
|
def softbot_build
|
||||||
branch = params[:ref].split("/").last
|
branch = params[:ref].split('/').last
|
||||||
user = User.find_by_login params[:repository][:owner][:login]
|
user = User.find_by_login params[:repository][:owner][:login]
|
||||||
return normal_status(-1, "你还未开通Page服务,无法进行部署") unless user.website_permission
|
return normal_status(-1, '你还未开通Page服务,无法进行部署') unless user.website_permission
|
||||||
|
|
||||||
project = Project.where(identifier: params[:repository][:name],user_id: user.id)
|
project = Project.where(identifier: params[:repository][:name],user_id: user.id)
|
||||||
return normal_status(-1, "你没有权限操作") if project.owner?(user)
|
return normal_status(-1, '你没有权限操作') if project.owner?(user)
|
||||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
return normal_status(-1, '该仓库还未开通Page服务,无法进行部署') if Page.exists?(user: user, project: project)
|
||||||
|
|
||||||
@page = Page.find_by(user: user, project: project)
|
@page = Page.find_by(user: user, project: project)
|
||||||
response_str = @page.deploy_page(branch)
|
response_str = @page.deploy_page(branch)
|
||||||
data = JSON.parse(response_str)["result"]
|
data = JSON.parse(response_str)['result']
|
||||||
if data.nil?
|
if data.nil?
|
||||||
data = JSON.parse(response_str)["error"]
|
data = JSON.parse(response_str)['error']
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.include?("部署成功")
|
if data.include?('部署成功')
|
||||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||||
else
|
else
|
||||||
@page.update(build_state:false, last_build_info: data)
|
@page.update(build_state:false, last_build_info: data)
|
||||||
|
@ -85,7 +93,7 @@ class SitePagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def theme_params
|
def theme_params
|
||||||
params[:language_frame] || "hugo"
|
params[:language_frame] || 'hugo'
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_params
|
def create_params
|
||||||
|
|
|
@ -1,44 +1,45 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: attachments
|
# Table name: attachments
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# container_id :integer
|
# container_id :integer
|
||||||
# container_type :string(30)
|
# container_type :string(30)
|
||||||
# filename :string(255) default(""), not null
|
# filename :string(255) default(""), not null
|
||||||
# disk_filename :string(255) default(""), not null
|
# disk_filename :string(255) default(""), not null
|
||||||
# filesize :integer default("0"), not null
|
# filesize :integer default("0"), not null
|
||||||
# content_type :string(255) default("")
|
# content_type :string(255) default("")
|
||||||
# digest :string(60) default(""), not null
|
# digest :string(60) default(""), not null
|
||||||
# downloads :integer default("0"), not null
|
# downloads :integer default("0"), not null
|
||||||
# author_id :integer default("0"), not null
|
# author_id :integer default("0"), not null
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# description :text(65535)
|
# description :text(65535)
|
||||||
# disk_directory :string(255)
|
# disk_directory :string(255)
|
||||||
# attachtype :integer default("1")
|
# attachtype :integer default("1")
|
||||||
# is_public :integer default("1")
|
# is_public :integer default("1")
|
||||||
# copy_from :integer
|
# copy_from :integer
|
||||||
# quotes :integer default("0")
|
# quotes :integer default("0")
|
||||||
# is_publish :integer default("1")
|
# is_publish :integer default("1")
|
||||||
# publish_time :datetime
|
# publish_time :datetime
|
||||||
# resource_bank_id :integer
|
# resource_bank_id :integer
|
||||||
# unified_setting :boolean default("1")
|
# unified_setting :boolean default("1")
|
||||||
# cloud_url :string(255) default("")
|
# cloud_url :string(255) default("")
|
||||||
# course_second_category_id :integer default("0")
|
# course_second_category_id :integer default("0")
|
||||||
# delay_publish :boolean default("0")
|
# delay_publish :boolean default("0")
|
||||||
# memo_image :boolean default("0")
|
# memo_image :boolean default("0")
|
||||||
# extra_type :integer default("0")
|
# extra_type :integer default("0")
|
||||||
# uuid :string(255)
|
# uuid :string(255)
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_attachments_on_author_id (author_id)
|
# index_attachments_on_author_id (author_id)
|
||||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||||
# index_attachments_on_course_second_category_id (course_second_category_id)
|
# index_attachments_on_course_second_category_id (course_second_category_id)
|
||||||
# index_attachments_on_created_on (created_on)
|
# index_attachments_on_created_on (created_on)
|
||||||
# index_attachments_on_is_public (is_public)
|
# index_attachments_on_is_public (is_public)
|
||||||
# index_attachments_on_quotes (quotes)
|
# index_attachments_on_quotes (quotes)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,17 @@
|
||||||
# blockchain_token_num :integer
|
# blockchain_token_num :integer
|
||||||
# pm_project_id :integer
|
# pm_project_id :integer
|
||||||
# pm_sprint_id :integer
|
# pm_sprint_id :integer
|
||||||
|
# pm_issue_type :integer
|
||||||
|
# time_scale :decimal(10, 2) default("0.00")
|
||||||
|
# child_count :integer default("0")
|
||||||
|
# changer_id :integer
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_issues_on_assigned_to_id (assigned_to_id)
|
# index_issues_on_assigned_to_id (assigned_to_id)
|
||||||
# index_issues_on_author_id (author_id)
|
# index_issues_on_author_id (author_id)
|
||||||
# index_issues_on_category_id (category_id)
|
# index_issues_on_category_id (category_id)
|
||||||
|
# index_issues_on_changer_id (changer_id)
|
||||||
# index_issues_on_created_on (created_on)
|
# index_issues_on_created_on (created_on)
|
||||||
# index_issues_on_fixed_version_id (fixed_version_id)
|
# index_issues_on_fixed_version_id (fixed_version_id)
|
||||||
# index_issues_on_priority_id (priority_id)
|
# index_issues_on_priority_id (priority_id)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# gid :integer
|
# gid :integer
|
||||||
# gitea_url :string(255)
|
# gitea_url :string(255)
|
||||||
# pull_requests_count :integer default("0")
|
# pull_requests_count :integer default("0")
|
||||||
|
# pm_project_id :integer
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#
|
#
|
||||||
# index_journals_on_created_on (created_on)
|
# index_journals_on_created_on (created_on)
|
||||||
# index_journals_on_journalized_id (journalized_id)
|
# index_journals_on_journalized_id (journalized_id)
|
||||||
|
# index_journals_on_parent_id (parent_id)
|
||||||
# index_journals_on_review_id (review_id)
|
# index_journals_on_review_id (review_id)
|
||||||
# index_journals_on_user_id (user_id)
|
# index_journals_on_user_id (user_id)
|
||||||
# journals_journalized_id (journalized_id,journalized_type)
|
# journals_journalized_id (journalized_id,journalized_type)
|
||||||
|
|
|
@ -189,7 +189,7 @@ class User < Owner
|
||||||
has_many :user_clas, :dependent => :destroy
|
has_many :user_clas, :dependent => :destroy
|
||||||
has_many :clas, through: :user_clas
|
has_many :clas, through: :user_clas
|
||||||
|
|
||||||
has_many :pages, :dependent => :destroy
|
has_one :page, :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]) }
|
||||||
|
@ -773,7 +773,7 @@ class User < Owner
|
||||||
|
|
||||||
def check_website_permission
|
def check_website_permission
|
||||||
if website_permission_changed? && website_permission == false
|
if website_permission_changed? && website_permission == false
|
||||||
self.pages.update_all(state: false, state_description:"因违规使用,现关闭Page服务")
|
self.page.update(state: false, state_description:"因违规使用,现关闭Page服务")
|
||||||
PageService.close_site(self.id)
|
PageService.close_site(self.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue