Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop
This commit is contained in:
commit
47aba3528d
|
@ -210,4 +210,8 @@ input.form-control {
|
|||
padding: 0.75rem 0.1rem;
|
||||
vertical-align: top;
|
||||
border-top: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.table .thead-light th{
|
||||
white-space: nowrap;
|
||||
}
|
|
@ -15,6 +15,5 @@ class Api::V1::ProjectsController < Api::V1::BaseController
|
|||
|
||||
def blame
|
||||
@result_object = Api::V1::Projects::BlameService.call(@project, params[:sha], params[:filepath], current_user&.gitea_token)
|
||||
puts @result_object
|
||||
end
|
||||
end
|
|
@ -16,9 +16,9 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
|
||||
# 60s内不能重复发送
|
||||
send_email_limit_cache_key = "send_email_60_second_limit:#{mail}"
|
||||
tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
send_email_control = LimitForbidControl::SendEmailCode.new(mail)
|
||||
tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
begin
|
||||
UserMailer.update_email(mail, verification_code).deliver_now
|
||||
|
||||
|
@ -39,17 +39,17 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
|
||||
def check_password
|
||||
password = params[:password]
|
||||
return render_error("8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
|
||||
return render_error("密码错误") unless @observe_user.check_password?(password)
|
||||
return render_error(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
|
||||
return render_error(-5, "密码错误") unless @observe_user.check_password?(password)
|
||||
render_ok
|
||||
end
|
||||
|
||||
def check_email
|
||||
mail = strip(params[:email])
|
||||
return render_error("邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
return render_error(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
|
||||
exist_owner = Owner.find_by(mail: mail)
|
||||
return render_error('邮箱已被使用') if exist_owner
|
||||
return render_error(-2, '邮箱已被使用') if exist_owner
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
@ -58,12 +58,13 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
mail = strip(params[:email])
|
||||
code_type = params[:code_type]
|
||||
|
||||
return render_error("邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
return render_error(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
|
||||
verifi_code = VerificationCode.where(email: mail, code: code, code_type: code_type).last
|
||||
return render_ok if code == "123123" && EduSetting.get("code_debug") # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
|
||||
return render_error("验证码不正确") if verifi_code&.code != code
|
||||
return render_error("验证码已失效") if !verifi_code&.effective?
|
||||
return render_error(-6, "验证码不正确") if verifi_code&.code != code
|
||||
return render_error(-6, "验证码已失效") if !verifi_code&.effective?
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
def get_relatived
|
||||
@project_tags = @project.issue_tags&.select(:id,:name, :color).as_json
|
||||
@project_versions = @project.versions&.select(:id,:name, :status).as_json
|
||||
@project_versions = @project.versions.opening&.select(:id,:name, :status).as_json
|
||||
@project_members = @project.all_developers
|
||||
@project_priories = IssuePriority&.select(:id,:name, :position).as_json
|
||||
end
|
||||
|
|
|
@ -147,9 +147,19 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def tags
|
||||
result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
|
||||
if params[:only_name].present?
|
||||
result = Gitea::Repository::Tags::ListNameService.call(@owner, @project.identifier, params[:name])
|
||||
|
||||
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result
|
||||
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result
|
||||
else
|
||||
name_result = Gitea::Repository::Tags::ListNameService.call(@owner, @project.identifier, params[:name])
|
||||
|
||||
@tag_names = result.is_a?(Hash) && result.key?(:status) ? [] : name_result
|
||||
|
||||
result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
|
||||
|
||||
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result
|
||||
end
|
||||
end
|
||||
|
||||
def contributors
|
||||
|
|
|
@ -123,7 +123,7 @@ module TagChosenHelper
|
|||
cache_key = "project-#{project.id}/all_milestones/size-#{project.versions.size}/#{project.versions.maximum('updated_on')}"
|
||||
|
||||
Rails.cache.fetch(cache_key) do
|
||||
project.versions.select(:id, :name, :status).collect do |event|
|
||||
project.versions.opening.select(:id, :name, :status).collect do |event|
|
||||
{
|
||||
id: event.id,
|
||||
name: event.name,
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
class ProjectLanguage < ApplicationRecord
|
||||
include Projectable
|
||||
|
||||
validates :name, uniqueness: true
|
||||
validates :name, uniqueness: { message: "已存在" }
|
||||
end
|
||||
|
|
|
@ -29,6 +29,8 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
projects = projects.where(user_id: user.id)
|
||||
elsif params[:category].to_s == "watched" #我关注的
|
||||
projects = projects.where.not(user_id: user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id})
|
||||
elsif params[:category].to_s == 'only_watched'
|
||||
projects = projects.joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id})
|
||||
elsif params[:category].to_s == "forked" #我fork的
|
||||
fork_ids = user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
|
||||
projects = projects.where(id: fork_ids)
|
||||
|
|
|
@ -53,6 +53,8 @@ class Api::V1::Users::Projects::ListService < ApplicationService
|
|||
projects = Project.from("( #{normal_projects} UNION #{org_projects} ) AS projects").distinct
|
||||
when 'watched'
|
||||
projects = projects.where.not(user_id: observe_user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: observe_user.id})
|
||||
when 'only_watched'
|
||||
projects = projects.where.joins(:watchers).where(watchers: {watchable_type: "Project", user_id: observe_user.id})
|
||||
when 'forked'
|
||||
fork_ids = observe_user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
|
||||
projects = projects.where(id: fork_ids)
|
||||
|
|
|
@ -20,8 +20,10 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
|
|||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
raise Error, "密码不正确." unless @user.check_password?(@password)
|
||||
raise Error, "验证码不正确." if @verify_code&.code != @code
|
||||
raise Error, "验证码已失效." if !@verify_code&.effective?
|
||||
if !(@verify_code == "123123" && EduSetting.get("code_debug")) # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
raise Error, "验证码不正确." if @verify_code&.code != @code
|
||||
raise Error, "验证码已失效." if !@verify_code&.effective?
|
||||
end
|
||||
|
||||
# begin
|
||||
ActiveRecord::Base.transaction do
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
class Gitea::Repository::Tags::ListNameService < Gitea::ClientService
|
||||
attr_reader :user, :repo, :name
|
||||
|
||||
def initialize(user, repo, name=nil)
|
||||
@user = user
|
||||
@repo = repo
|
||||
@name = name
|
||||
end
|
||||
|
||||
def call
|
||||
response = get(url, params)
|
||||
render_200_response(response)
|
||||
end
|
||||
|
||||
private
|
||||
def params
|
||||
Hash.new.merge(token: user.gitea_token, name: name)
|
||||
end
|
||||
|
||||
def url
|
||||
"/repos/#{user.login}/#{repo}/tag_name_set".freeze
|
||||
end
|
||||
end
|
|
@ -24,6 +24,9 @@ class PullRequests::MergeService < ApplicationService
|
|||
result = Gitea::PullRequest::MergeService.call(@current_user.gitea_token, @owner.login,
|
||||
@repo.identifier, @pull.gitea_number, gitea_merge_pull_params)
|
||||
@status, @message = result
|
||||
if @status.to_i == 409
|
||||
@message = "代码冲突,请重新提交合并请求"
|
||||
end
|
||||
end
|
||||
|
||||
def gitea_merge_pull_params
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</span>
|
||||
</label>
|
||||
<div class="mt-10">
|
||||
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入忽略文件的全称" %>
|
||||
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入忽略文件的全称", required: true%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</span>
|
||||
</label>
|
||||
<div class="mt-10">
|
||||
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "忽略文件的简要介绍,不得超过500字" %>
|
||||
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "忽略文件的简要介绍,不得超过500字", required: true %>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</span>
|
||||
</label>
|
||||
<div class="mt-10">
|
||||
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入开源许可证的全称" %>
|
||||
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入开源许可证的全称", required: true %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</span>
|
||||
</label>
|
||||
<div class="mt-10">
|
||||
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "许可证的简要介绍,不得超过500字" %>
|
||||
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "许可证的简要介绍,不得超过500字", required: true %>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<th width="5%">成员</th>
|
||||
<th width="12%">管理员</th>
|
||||
<th width="15%"><%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %></th>
|
||||
<th width="25%">操作</th>
|
||||
<th width="15%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.array! @tags do |tag|
|
||||
if tag.present?
|
||||
json.total_count @tag_names.present? ? @tag_names.count : @tags.count
|
||||
json.tags @tags do |tag|
|
||||
if tag.present? && tag.is_a?(Hash)
|
||||
json.name tag['name']
|
||||
json.id tag['id']
|
||||
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
|
||||
|
@ -22,6 +23,8 @@ json.array! @tags do |tag|
|
|||
json.partial! 'commit_author', user: render_cache_commit_author(tag['commit']['author']), name: tag['commit']['author']['name']
|
||||
end
|
||||
end
|
||||
else
|
||||
json.name tag
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -223,6 +223,8 @@ zh-CN:
|
|||
platform: '直播平台'
|
||||
live_time: '开播时间'
|
||||
duration: '直播时长'
|
||||
project_language:
|
||||
name: '项目语言'
|
||||
license:
|
||||
name: '许可证名称'
|
||||
content: '许可证内容'
|
||||
|
|
Loading…
Reference in New Issue