Merge branch 'develop' into standalone

This commit is contained in:
jasder
2021-05-24 10:11:02 +08:00
34 changed files with 278 additions and 34 deletions

View File

@@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#

20
app/models/faq.rb Normal file
View File

@@ -0,0 +1,20 @@
# == Schema Information
#
# Table name: faqs
#
# id :integer not null, primary key
# question :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Faq < ApplicationRecord
validates :question, presence: true,length: { maximum: 100, too_long: "最多%{count}个字符" }
validates :url, format: { with: CustomRegexp::URL, multiline: true, message: "格式不正确" }
scope :select_without_id, -> { select(:question, :url) }
scope :search_question, ->(keyword) { where("question LIKE ?", "%#{keyword}%") unless keyword.blank?}
end

View File

@@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#

View File

@@ -47,6 +47,7 @@
# watchers_count :integer default("0")
# devops_step :integer default("0")
# gitea_token :string(255)
# platform :string(255)
#
# Indexes
#
@@ -167,7 +168,8 @@ class User < Owner
# Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) }
scope :like, lambda { |keywords|
where("LOWER(concat(lastname, firstname, login, mail)) LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
sql = "CONCAT(lastname, firstname) LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR nickname LIKE :keyword"
where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
scope :simple_select, -> {select(:id, :login, :lastname,:firstname, :nickname, :gitea_uid, :type)}