website update
This commit is contained in:
parent
761021d191
commit
d590e1165e
|
@ -17,23 +17,31 @@ class SitePagesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
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?(project: @project)
|
||||
return normal_status(-1, '你还未开通Page服务,无法进行部署') unless current_user.website_permission
|
||||
return normal_status(-1, '你已开通Page服务') if Page.exists?(user: current_user)
|
||||
return normal_status(-1, '该仓库已开通Page服务') if Page.exists?(project: @project)
|
||||
@page = Page.new(create_params)
|
||||
@page.user = current_user
|
||||
@page.project = @project
|
||||
@page.save
|
||||
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
|
||||
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 current_user.website_permission
|
||||
return normal_status(-1, '该仓库还未开通Page服务,无法进行部署') unless Page.exists?(project: @project)
|
||||
@page = Page.find params[:id]
|
||||
return normal_status(-1, @page.state_description) unless @page.state
|
||||
response_str = @page.deploy_page(params[:branch])
|
||||
data = JSON.parse(response_str)["result"] || data = JSON.parse(response_str)["error"]
|
||||
if data.to_s.include?("部署成功")
|
||||
data = JSON.parse(response_str)['result'] || (data = JSON.parse(response_str)['error'])
|
||||
if data.to_s.include?('部署成功')
|
||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||
else
|
||||
@page.update(build_state:false, last_build_info: data)
|
||||
|
@ -42,22 +50,22 @@ class SitePagesController < ApplicationController
|
|||
end
|
||||
|
||||
def softbot_build
|
||||
branch = params[:ref].split("/").last
|
||||
branch = params[:ref].split('/').last
|
||||
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)
|
||||
return normal_status(-1, "你没有权限操作") if project.owner?(user)
|
||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
||||
return normal_status(-1, '你没有权限操作') if project.owner?(user)
|
||||
return normal_status(-1, '该仓库还未开通Page服务,无法进行部署') if Page.exists?(user: user, project: project)
|
||||
|
||||
@page = Page.find_by(user: user, project: project)
|
||||
response_str = @page.deploy_page(branch)
|
||||
data = JSON.parse(response_str)["result"]
|
||||
data = JSON.parse(response_str)['result']
|
||||
if data.nil?
|
||||
data = JSON.parse(response_str)["error"]
|
||||
data = JSON.parse(response_str)['error']
|
||||
end
|
||||
|
||||
if data.include?("部署成功")
|
||||
if data.include?('部署成功')
|
||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||
else
|
||||
@page.update(build_state:false, last_build_info: data)
|
||||
|
@ -85,7 +93,7 @@ class SitePagesController < ApplicationController
|
|||
end
|
||||
|
||||
def theme_params
|
||||
params[:language_frame] || "hugo"
|
||||
params[:language_frame] || 'hugo'
|
||||
end
|
||||
|
||||
def create_params
|
||||
|
|
|
@ -1,44 +1,45 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: attachments
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# container_id :integer
|
||||
# container_type :string(30)
|
||||
# filename :string(255) default(""), not null
|
||||
# disk_filename :string(255) default(""), not null
|
||||
# filesize :integer default("0"), not null
|
||||
# content_type :string(255) default("")
|
||||
# digest :string(60) default(""), not null
|
||||
# downloads :integer default("0"), not null
|
||||
# author_id :integer default("0"), not null
|
||||
# created_on :datetime
|
||||
# description :text(65535)
|
||||
# disk_directory :string(255)
|
||||
# attachtype :integer default("1")
|
||||
# is_public :integer default("1")
|
||||
# copy_from :integer
|
||||
# quotes :integer default("0")
|
||||
# is_publish :integer default("1")
|
||||
# publish_time :datetime
|
||||
# resource_bank_id :integer
|
||||
# unified_setting :boolean default("1")
|
||||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
# memo_image :boolean default("0")
|
||||
# extra_type :integer default("0")
|
||||
# uuid :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# 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_created_on (created_on)
|
||||
# index_attachments_on_is_public (is_public)
|
||||
# index_attachments_on_quotes (quotes)
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: attachments
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# container_id :integer
|
||||
# container_type :string(30)
|
||||
# filename :string(255) default(""), not null
|
||||
# disk_filename :string(255) default(""), not null
|
||||
# filesize :integer default("0"), not null
|
||||
# content_type :string(255) default("")
|
||||
# digest :string(60) default(""), not null
|
||||
# downloads :integer default("0"), not null
|
||||
# author_id :integer default("0"), not null
|
||||
# created_on :datetime
|
||||
# description :text(65535)
|
||||
# disk_directory :string(255)
|
||||
# attachtype :integer default("1")
|
||||
# is_public :integer default("1")
|
||||
# copy_from :integer
|
||||
# quotes :integer default("0")
|
||||
# is_publish :integer default("1")
|
||||
# publish_time :datetime
|
||||
# resource_bank_id :integer
|
||||
# unified_setting :boolean default("1")
|
||||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
# memo_image :boolean default("0")
|
||||
# extra_type :integer default("0")
|
||||
# uuid :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# 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_created_on (created_on)
|
||||
# index_attachments_on_is_public (is_public)
|
||||
# index_attachments_on_quotes (quotes)
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,12 +36,17 @@
|
|||
# blockchain_token_num :integer
|
||||
# pm_project_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
|
||||
#
|
||||
# index_issues_on_assigned_to_id (assigned_to_id)
|
||||
# index_issues_on_author_id (author_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_fixed_version_id (fixed_version_id)
|
||||
# index_issues_on_priority_id (priority_id)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# gid :integer
|
||||
# gitea_url :string(255)
|
||||
# pull_requests_count :integer default("0")
|
||||
# pm_project_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#
|
||||
# index_journals_on_created_on (created_on)
|
||||
# index_journals_on_journalized_id (journalized_id)
|
||||
# index_journals_on_parent_id (parent_id)
|
||||
# index_journals_on_review_id (review_id)
|
||||
# index_journals_on_user_id (user_id)
|
||||
# journals_journalized_id (journalized_id,journalized_type)
|
||||
|
|
|
@ -189,7 +189,7 @@ class User < Owner
|
|||
has_many :user_clas, :dependent => :destroy
|
||||
has_many :clas, through: :user_clas
|
||||
|
||||
has_many :pages, :dependent => :destroy
|
||||
has_one :page, :dependent => :destroy
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||
|
@ -773,7 +773,7 @@ class User < Owner
|
|||
|
||||
def check_website_permission
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue