Merge branch 'standalone_develop' into pm_project_develop

# Conflicts:
#	app/models/attachment.rb
#	app/views/api/v1/attachments/_simple_detail.json.jbuilder
This commit is contained in:
2024-04-29 09:11:08 +08:00
45 changed files with 344 additions and 52 deletions

View File

@@ -73,7 +73,7 @@ class Attachment < ApplicationRecord
scope :unified_setting, -> {where("unified_setting = ? ", 1)}
scope :where_id_or_uuid, -> (id) { (Float(id) rescue nil).present? ? where(id: id) : where(uuid: id) }
validates_length_of :description, maximum: 100, message: "不能超过100个字符"
validates_length_of :description, maximum: 255, message: "不能超过255个字符"
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)

View File

@@ -0,0 +1,27 @@
# == Schema Information
#
# Table name: open_users
#
# id :integer not null, primary key
# user_id :integer
# type :string(255)
# uid :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# extra :text(65535)
#
# Indexes
#
# index_open_users_on_type_and_uid (type,uid) UNIQUE
# index_open_users_on_user_id (user_id)
#
class OpenUsers::Acge < OpenUser
def nickname
extra&.[]('nickname')
end
def en_type
'acge'
end
end

View File

@@ -28,7 +28,7 @@ class Page < ApplicationRecord
belongs_to :project
# language_frame 前端语言框架
enum language_frame: { hugo: 0, jekyll: 1, hexo: 2}
enum language_frame: { hugo: 0, jekyll: 1, hexo: 2, files: 3}
after_create do
PageService.genernate_user(user_id)

View File

@@ -13,7 +13,7 @@
#
class PageTheme < ApplicationRecord
enum language_frame: { hugo: 0, jeklly: 1, hexo: 2}
enum language_frame: { hugo: 0, jeklly: 1, hexo: 2, files:3}
validates :name, presence: {message: "主题名不能为空"}, uniqueness: {message: "主题名已存在",scope: :language_frame},length: {maximum: 255}
def image

View File

@@ -90,6 +90,8 @@ class Project < ApplicationRecord
include ProjectOperable
include Dcodes
default_scope {where.not(id: 0)}
# common:开源托管项目
# mirror:普通镜像项目,没有定时同步功能
# sync_mirror:同步镜像项目,有系统定时同步功能,且用户可手动同步操作
@@ -137,6 +139,7 @@ class Project < ApplicationRecord
has_many :project_topics, through: :project_topic_ralates
has_many :commit_logs, dependent: :destroy
has_many :daily_project_statistics, dependent: :destroy
has_one :project_dataset, dependent: :destroy
after_create :incre_user_statistic, :incre_platform_statistic
after_save :check_project_members
before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned, :reset_cache_data

View File

@@ -0,0 +1,26 @@
# == Schema Information
#
# Table name: project_datasets
#
# id :integer not null, primary key
# title :string(255)
# description :text(65535)
# project_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# license_id :integer
# paper_content :text(65535)
#
# Indexes
#
# index_project_datasets_on_license_id (license_id)
# index_project_datasets_on_project_id (project_id)
#
class ProjectDataset < ApplicationRecord
belongs_to :project
belongs_to :license, optional: true
has_many :attachments, as: :container, dependent: :destroy
end

View File

@@ -17,7 +17,7 @@ class ProjectUnit < ApplicationRecord
belongs_to :project
enum unit_type: {code: 1, issues: 2, pulls: 3, wiki:4, devops: 5, versions: 6, resources: 7, services: 8}
enum unit_type: {code: 1, issues: 2, pulls: 3, wiki:4, devops: 5, versions: 6, resources: 7, services: 8, dataset: 9}
validates :unit_type, uniqueness: { scope: :project_id}

View File

@@ -115,7 +115,7 @@ class User < Owner
# trustie: 来自Trustie平台
# forge: 平台本身注册的用户
# military: 军科的用户
enumerize :platform, in: [:forge, :educoder, :trustie, :military, :github, :gitee, :qq, :wechat, :bot], default: :forge, scope: :shallow
enumerize :platform, in: [:forge, :educoder, :trustie, :military, :github, :gitee, :qq, :wechat, :bot, :acge], default: :forge, scope: :shallow
belongs_to :laboratory, optional: true
has_one :user_extension, dependent: :destroy