add: template setting model

This commit is contained in:
yystopf 2021-10-13 17:04:28 +08:00
parent d58d4136ad
commit 8252cb7e71
8 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# == Schema Information
#
# Table name: template_message_settings
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# key :string(255)
# openning :boolean
# notification_disabled :boolean
# email_disabled :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
class TemplateMessageSetting < ApplicationRecord
def self.build_init_data
end
end

View File

@ -0,0 +1,25 @@
# == Schema Information
#
# Table name: template_message_settings
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# key :string(255)
# openning :boolean
# notification_disabled :boolean
# email_disabled :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
#我创建的或负责的
class TemplateMessageSetting::CreateOrAssign < TemplateMessageSetting
def self.build_init_data
self.find_or_create_by(name: "易修状态变更", key: "IssueChanged")
self.find_or_create_by(name: "易修被指派", key: "IssueAssigned")
self.find_or_create_by(name: "合并请求被指派", key: "PullRequestAssigned")
self.find_or_create_by(name: "合并请求状态变更", key: "PullRequestAssigned")
end
end

View File

@ -0,0 +1,25 @@
# == Schema Information
#
# Table name: template_message_settings
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# key :string(255)
# openning :boolean
# notification_disabled :boolean
# email_disabled :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
#我管理的
class TemplateMessageSetting::Manage < TemplateMessageSetting
def self.build_init_data
self.find_or_create_by(name: "有新的易修", key: "ProjectIssue")
self.find_or_create_by(name: "有新的合并请求", key: "ProjectPullRequest")
self.find_or_create_by(name: "有成员变动", key: "ProjectMember")
self.find_or_create_by(name: "设置更改", key: "ProjectSettingChanged")
end
end

View File

@ -0,0 +1,23 @@
# == Schema Information
#
# Table name: template_message_settings
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# key :string(255)
# openning :boolean
# notification_disabled :boolean
# email_disabled :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
class TemplateMessageSetting::Normal < TemplateMessageSetting
def self.build_init_data
self.find_or_create_by(name: "被拉入或移出组织", key: "Organization")
self.find_or_create_by(name: "被拉入或移出项目", key: "Project")
self.find_or_create_by(name: "有权限变更", key: "Permission")
end
end

View File

@ -0,0 +1,21 @@
# == Schema Information
#
# Table name: template_message_settings
#
# id :integer not null, primary key
# type :string(255)
# name :string(255)
# key :string(255)
# openning :boolean
# notification_disabled :boolean
# email_disabled :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
#我关注的
class TemplateMessageSetting::Watch < TemplateMessageSetting
def self.build_init_data
end
end

View File

@ -0,0 +1,18 @@
# == Schema Information
#
# Table name: user_template_message_settings
#
# id :integer not null, primary key
# user_id :integer
# notification_body :text(65535)
# email_body :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_user_template_message_settings_on_user_id (user_id)
#
class UserTemplateMessageSetting < ApplicationRecord
end

View File

@ -0,0 +1,15 @@
class CreateTemplateMessageSettings < ActiveRecord::Migration[5.2]
def change
# 平台的通知设置
create_table :template_message_settings do |t|
t.string :type
t.string :name
t.string :key
t.boolean :openning, default: true
t.boolean :notification_disabled, default: true
t.boolean :email_disabled, default: false
t.timestamps
end
end
end

View File

@ -0,0 +1,12 @@
class CreateUserTemplateMessageSettings < ActiveRecord::Migration[5.2]
def change
# 用户对系统通知的设置
create_table :user_template_message_settings do |t|
t.references :user
t.text :notification_body
t.text :email_body
t.timestamps
end
end
end