mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
Merge branch 'standalone_develop' into pre_trustie_server
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
# == 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 :string(255)
|
||||
# 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")
|
||||
# link :string(255)
|
||||
# clone_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# index_attachments_on_clone_id (clone_id)
|
||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||
# index_attachments_on_created_on (created_on)
|
||||
#
|
||||
|
||||
# == 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 :string(255)
|
||||
# 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")
|
||||
# link :string(255)
|
||||
# clone_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# index_attachments_on_clone_id (clone_id)
|
||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||
# index_attachments_on_created_on (created_on)
|
||||
#
|
||||
|
||||
|
||||
|
||||
class Attachment < ApplicationRecord
|
||||
@@ -184,4 +184,14 @@ class Attachment < ApplicationRecord
|
||||
is_pdf
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |attachment|
|
||||
attachment.id self.id
|
||||
attachment.title self.title
|
||||
attachment.filesize self.filesize
|
||||
attachment.is_pdf self.is_pdf?
|
||||
attachment.created_on self.created_on.strftime("%Y-%m-%d %H:%M")
|
||||
attachment.content_type self.content_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Gitea::WebhookTask < Gitea::Base
|
||||
serialize :payload_content, JSON
|
||||
serialize :request_content, JSON
|
||||
serialize :response_content, JSON
|
||||
|
||||
self.inheritance_column = nil
|
||||
|
||||
@@ -10,9 +11,4 @@ class Gitea::WebhookTask < Gitea::Base
|
||||
|
||||
enum type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}
|
||||
|
||||
def response_content_json
|
||||
JSON.parse(response_content)
|
||||
rescue
|
||||
{}
|
||||
end
|
||||
end
|
||||
@@ -219,4 +219,30 @@ class Issue < ApplicationRecord
|
||||
SendTemplateMessageJob.perform_later('IssueExpire', self.id) if Site.has_notice_menu? && self.due_date == Date.today + 1.days
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |issue|
|
||||
issue.(self, :id, :project_issues_index, :subject, :description, :branch_name, :start_date, :due_date)
|
||||
issue.created_at self.created_on.strftime("%Y-%m-%d %H:%M")
|
||||
issue.updated_at self.updated_on.strftime("%Y-%m-%d %H:%M")
|
||||
issue.tags self.show_issue_tags.map{|t| JSON.parse(t.to_builder.target!)}
|
||||
issue.status self.issue_status.to_builder
|
||||
if self.priority.present?
|
||||
issue.priority self.priority.to_builder
|
||||
else
|
||||
issue.priority nil
|
||||
end
|
||||
if self.version.present?
|
||||
issue.milestone self.version.to_builder
|
||||
else
|
||||
issue.milestone nil
|
||||
end
|
||||
issue.author self.user.to_builder
|
||||
issue.assigners self.show_assigners.map{|t| JSON.parse(t.to_builder.target!)}
|
||||
issue.participants self.participants.distinct.map{|t| JSON.parse(t.to_builder.target!)}
|
||||
issue.comment_journals_count self.comment_journals.size
|
||||
issue.operate_journals_count self.operate_journals.size
|
||||
issue.attachments self.attachments.map{|t| JSON.parse(t.to_builder.target!)}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,4 +32,10 @@ class IssuePriority < ApplicationRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |priority|
|
||||
priority.(self, :id, :name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,4 +44,10 @@ class IssueStatus < ApplicationRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |status|
|
||||
status.(self, :id, :name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,4 +53,11 @@ class IssueTag < ApplicationRecord
|
||||
self.update_column(:pull_requests_count, pull_request_issues.size)
|
||||
end
|
||||
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |tag|
|
||||
tag.(self, :id, :name, :description)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -272,5 +272,15 @@ class Journal < ApplicationRecord
|
||||
send_details
|
||||
end
|
||||
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |journal|
|
||||
journal.(self, :id, :notes, :comments_count)
|
||||
if self.parent_journal.present?
|
||||
journal.parent_journal self.parent_journal.to_builder
|
||||
end
|
||||
if self.reply_journal.present?
|
||||
journal.reply_journal self.reply_journal.to_builder
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,15 +39,18 @@
|
||||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
# sponsor_certification :integer default("0")
|
||||
# sponsor_num :integer default("0")
|
||||
# sponsored_num :integer default("0")
|
||||
# sponsor_description :text(65535)
|
||||
# award_time :datetime
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
@@ -55,9 +58,8 @@
|
||||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
@@ -71,13 +73,16 @@ class Organization < Owner
|
||||
has_many :teams, dependent: :destroy
|
||||
has_many :organization_users, dependent: :destroy
|
||||
has_many :team_users, 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
|
||||
|
||||
validates :login, presence: true
|
||||
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, case_sensitive: false
|
||||
validates :login, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
||||
|
||||
delegate :description, :website, :location, :repo_admin_change_team_access, :recommend,
|
||||
:visibility, :max_repo_creation, :num_projects, :num_users, :num_teams, to: :organization_extension, allow_nil: true
|
||||
:visibility, :max_repo_creation, :num_projects, :num_users, :num_teams,
|
||||
:news_banner_id, :news_content, :memo, :news_title, :news_url, to: :organization_extension, allow_nil: true
|
||||
|
||||
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# num_users :integer default("0")
|
||||
# num_teams :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# news_banner_id :integer
|
||||
# news_content :text(65535)
|
||||
# memo :text(65535)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
||||
@@ -67,6 +67,7 @@ class Owner < ApplicationRecord
|
||||
has_many :projects, foreign_key: :user_id, dependent: :destroy
|
||||
has_many :repositories, foreign_key: :user_id, dependent: :destroy
|
||||
has_many :applied_transfer_projects, dependent: :destroy
|
||||
has_many :pinned_projects, foreign_key: :user_id, dependent: :destroy
|
||||
|
||||
scope :like, lambda { |keywords|
|
||||
# 表情处理
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
class PinnedProject < ApplicationRecord
|
||||
|
||||
belongs_to :user
|
||||
# belongs_to :user
|
||||
belongs_to :owner, class_name: 'Owner', foreign_key: :user_id, optional: true
|
||||
belongs_to :project
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# name :string(255)
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
@@ -122,7 +122,7 @@ class Project < ApplicationRecord
|
||||
has_many :project_units, dependent: :destroy
|
||||
has_one :applied_transfer_project,-> { order created_at: :desc }, dependent: :destroy
|
||||
has_many :pinned_projects, dependent: :destroy
|
||||
has_many :has_pinned_users, through: :pinned_projects, source: :user
|
||||
has_many :has_pinned_users, through: :pinned_projects, source: :owner
|
||||
has_many :webhooks, class_name: "Gitea::Webhook", primary_key: :gpid, foreign_key: :repo_id
|
||||
has_many :user_trace_tasks, dependent: :destroy
|
||||
has_many :project_invite_links, dependent: :destroy
|
||||
@@ -446,4 +446,59 @@ class Project < ApplicationRecord
|
||||
def del_project_issue_cache_delete_count
|
||||
$redis_cache.hdel("issue_cache_delete_count", self.id)
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |project|
|
||||
project.id self.id
|
||||
project.identifier self.identifier
|
||||
project.name self.name
|
||||
project.description Nokogiri::HTML(self.description).text
|
||||
project.visits self.visits
|
||||
project.praises_count self.praises_count.to_i
|
||||
project.watchers_count self.watchers_count.to_i
|
||||
project.issues_count self.issues_count.to_i
|
||||
project.pull_requests_count self.pull_requests_count.to_i
|
||||
project.forked_count self.forked_count.to_i
|
||||
project.is_public self.is_public
|
||||
project.mirror_url self.repository&.mirror_url
|
||||
project.type self&.project_type
|
||||
project.created_at self.created_on.strftime("%Y-%m-%d %H:%M")
|
||||
project.updated_at self.updated_on.strftime("%Y-%m-%d %H:%M")
|
||||
project.forked_from_project_id self.forked_from_project_id
|
||||
project.platform self.platform
|
||||
project.author do
|
||||
if self.educoder?
|
||||
project_educoder = self.project_educoder
|
||||
project.name project_educoder&.owner
|
||||
project.type 'Educoder'
|
||||
project.login project_educoder&.repo_name.split('/')[0]
|
||||
project.image_url render_educoder_avatar_url(self.project_educoder)
|
||||
else
|
||||
user = self.owner
|
||||
project.name user.try(:show_real_name)
|
||||
project.type user&.type
|
||||
project.login user.login
|
||||
project.image_url user.get_letter_avatar_url
|
||||
end
|
||||
end
|
||||
|
||||
project.category do
|
||||
if self.project_category.blank?
|
||||
project.nil!
|
||||
else
|
||||
project.id self.project_category.id
|
||||
project.name self.project_category.name
|
||||
end
|
||||
end
|
||||
project.language do
|
||||
if self.project_language.blank?
|
||||
project.nil!
|
||||
else
|
||||
project.id self.project_language.id
|
||||
project.name self.project_language.name
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -119,4 +119,37 @@ class PullRequest < ApplicationRecord
|
||||
|
||||
JSON.parse file_names
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |pull|
|
||||
pull.(self, :id, :gitea_number, :title, :body, :base, :head, :is_original, :comments_count)
|
||||
pull.user self.user.to_builder
|
||||
if self.fork_project.present?
|
||||
pull.fork_project self.fork_project.to_builder
|
||||
else
|
||||
pull.fork_project nil
|
||||
end
|
||||
pull.created_at self.created_at.strftime("%Y-%m-%d %H:%M")
|
||||
pull.updated_at self.updated_at.strftime("%Y-%m-%d %H:%M")
|
||||
pull.status self.pr_status
|
||||
pull.url self.pr_url
|
||||
end
|
||||
end
|
||||
|
||||
def pr_url
|
||||
return nil if self.project.nil?
|
||||
"#{Rails.application.config_for(:configuration)['platform_url']}/#{self.project.owner.login}/#{self.project.name}/pulls/#{self.id}"
|
||||
end
|
||||
|
||||
def pr_status
|
||||
case status
|
||||
when 0
|
||||
"OPEN"
|
||||
when 1
|
||||
"MERGED"
|
||||
when 2
|
||||
"CLOSED"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -868,6 +868,16 @@ class User < Owner
|
||||
end
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |user|
|
||||
user.(self, :id, :login)
|
||||
user.name self.real_name
|
||||
user.email self.mail
|
||||
user.image_url self.get_letter_avatar_url
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
def validate_password_length
|
||||
# 管理员的初始密码是5位
|
||||
|
||||
@@ -55,6 +55,12 @@ class Version < ApplicationRecord
|
||||
User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.user_id)
|
||||
end
|
||||
|
||||
def to_builder
|
||||
Jbuilder.new do |version|
|
||||
version.(self, :id, :name, :description, :effective_date)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def send_create_message_to_notice_system
|
||||
SendTemplateMessageJob.perform_later('ProjectMilestone', self.id, self.user_id) if Site.has_notice_menu?
|
||||
|
||||
Reference in New Issue
Block a user