Merge branch 'dev_military_license' of http://git.trustie.net/jasder/forgeplus into dev_military_license
This commit is contained in:
commit
43b4907565
104
api_document.md
104
api_document.md
|
@ -286,6 +286,7 @@ http://localhost:3000/api/licenses/ | jq
|
||||||
|licenses|array |返回数据|
|
|licenses|array |返回数据|
|
||||||
|-- id |int |id |
|
|-- id |int |id |
|
||||||
|-- name |string|开源许可证名称|
|
|-- name |string|开源许可证名称|
|
||||||
|
|-- is_secret |string|是否为特殊许可证|
|
||||||
|
|
||||||
|
|
||||||
返回值
|
返回值
|
||||||
|
@ -294,23 +295,33 @@ http://localhost:3000/api/licenses/ | jq
|
||||||
"licenses": [
|
"licenses": [
|
||||||
{
|
{
|
||||||
"id": 57,
|
"id": 57,
|
||||||
"name": "AFL-1.2"
|
"name": "AFL-1.2",
|
||||||
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 76,
|
"id": 76,
|
||||||
"name": "AFL-3.0"
|
"name": "AFL-3.0",
|
||||||
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 214,
|
"id": 214,
|
||||||
"name": "AFL-1.1"
|
"name": "AFL-1.1",
|
||||||
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 326,
|
"id": 326,
|
||||||
"name": "AFL-2.1"
|
"name": "AFL-2.1",
|
||||||
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 350,
|
"id": 350,
|
||||||
"name": "AFL-2.0"
|
"name": "AFL-2.0",
|
||||||
|
"is_secret": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 359,
|
||||||
|
"name": "PHengLEI",
|
||||||
|
"is_secret": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -555,6 +566,8 @@ curl -X GET http://localhost:3000/api/repositories/:id/edit.json | jq
|
||||||
|project_category_id |int|项目类别id|
|
|project_category_id |int|项目类别id|
|
||||||
|project_language_id |int|项目语言id|
|
|project_language_id |int|项目语言id|
|
||||||
|private |boolean|项目是否私有, true:为私有,false: 公开 |
|
|private |boolean|项目是否私有, true:为私有,false: 公开 |
|
||||||
|
|is_secret |boolean|项目是否为特殊协议项目, true:是,false: 否 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
返回值
|
返回值
|
||||||
|
@ -567,7 +580,8 @@ curl -X GET http://localhost:3000/api/repositories/:id/edit.json | jq
|
||||||
"project_description": "my first project mirror_demo",
|
"project_description": "my first project mirror_demo",
|
||||||
"project_category_id": 1,
|
"project_category_id": 1,
|
||||||
"project_language_id": 2,
|
"project_language_id": 2,
|
||||||
"private": false
|
"private": false,
|
||||||
|
"is_secret": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
@ -1146,6 +1160,7 @@ http://localhost:3000/api/projects | jq
|
||||||
|forked_count |int|被fork的数量|
|
|forked_count |int|被fork的数量|
|
||||||
|praises_count |int|star数量|
|
|praises_count |int|star数量|
|
||||||
|is_public |boolean|是否公开, true:公开,false:未公开|
|
|is_public |boolean|是否公开, true:公开,false:未公开|
|
||||||
|
|is_secret |boolean|是否为特殊许可证项目, true:是,false:否|
|
||||||
|mirror_url |string|镜像url|
|
|mirror_url |string|镜像url|
|
||||||
|last_update_time|int|最后更新时间,为UNIX格式的时间戳|
|
|last_update_time|int|最后更新时间,为UNIX格式的时间戳|
|
||||||
|author |object|项目创建者|
|
|author |object|项目创建者|
|
||||||
|
@ -1156,6 +1171,10 @@ http://localhost:3000/api/projects | jq
|
||||||
|language |object|项目语言|
|
|language |object|项目语言|
|
||||||
|-- id |int|项目语言id|
|
|-- id |int|项目语言id|
|
||||||
|-- name |string|项目语言名称|
|
|-- name |string|项目语言名称|
|
||||||
|
|user_apply_signatures |object|用户创建的特殊许可申请|
|
||||||
|
|-- id |int|用户创建的特殊许可申请id|
|
||||||
|
|-- status |int|用户创建的特殊许可申请审核状态, 'unpassed': 审核未通过,'waiting': 等待审核 'passed':审核通过|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
返回值
|
返回值
|
||||||
|
@ -1171,6 +1190,7 @@ http://localhost:3000/api/projects | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": true,
|
"is_public": true,
|
||||||
|
"is_secret": true,
|
||||||
"mirror_url": null,
|
"mirror_url": null,
|
||||||
"last_update_time": 1577697461,
|
"last_update_time": 1577697461,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -1184,7 +1204,13 @@ http://localhost:3000/api/projects | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
|
},
|
||||||
|
"user_apply_signatures":[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"status": "waiting"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
|
@ -1194,6 +1220,7 @@ http://localhost:3000/api/projects | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": true,
|
"is_public": true,
|
||||||
|
"is_secret": false,
|
||||||
"mirror_url": null,
|
"mirror_url": null,
|
||||||
"last_update_time": 1577697403,
|
"last_update_time": 1577697403,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -1207,7 +1234,8 @@ http://localhost:3000/api/projects | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
}
|
},
|
||||||
|
"user_apply_signatures":[]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
|
@ -1217,6 +1245,7 @@ http://localhost:3000/api/projects | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": true,
|
"is_public": true,
|
||||||
|
"is_secret": true,
|
||||||
"mirror_url": null,
|
"mirror_url": null,
|
||||||
"last_update_time": 1577415173,
|
"last_update_time": 1577415173,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -1230,7 +1259,8 @@ http://localhost:3000/api/projects | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
}
|
},
|
||||||
|
"user_apply_signatures":[]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 5,
|
"id": 5,
|
||||||
|
@ -1240,6 +1270,7 @@ http://localhost:3000/api/projects | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": false,
|
"is_public": false,
|
||||||
|
"is_secret": true,
|
||||||
"mirror_url": "https://gitea.com/CasperVector/slew.git",
|
"mirror_url": "https://gitea.com/CasperVector/slew.git",
|
||||||
"last_update_time": 1577346228,
|
"last_update_time": 1577346228,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -1253,7 +1284,8 @@ http://localhost:3000/api/projects | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
}
|
},
|
||||||
|
"user_apply_signatures":[]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 7,
|
"id": 7,
|
||||||
|
@ -1263,6 +1295,7 @@ http://localhost:3000/api/projects | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": true,
|
"is_public": true,
|
||||||
|
"is_secret": true,
|
||||||
"mirror_url": null,
|
"mirror_url": null,
|
||||||
"last_update_time": 1577341572,
|
"last_update_time": 1577341572,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -1276,7 +1309,8 @@ http://localhost:3000/api/projects | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
}
|
},
|
||||||
|
"user_apply_signatures":[]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3970,6 +4004,7 @@ http://localhost:3000/api/users/Jason/projects.json | jq
|
||||||
|forked_count |int|被fork的数量|
|
|forked_count |int|被fork的数量|
|
||||||
|praises_count |int|star数量|
|
|praises_count |int|star数量|
|
||||||
|is_public |boolean|是否公开, true:公开,false:未公开|
|
|is_public |boolean|是否公开, true:公开,false:未公开|
|
||||||
|
|is_secret |boolean|是否为特殊许可证项目, true:是,false:否|
|
||||||
|mirror_url |string|镜像url|
|
|mirror_url |string|镜像url|
|
||||||
|last_update_time|int|最后更新时间,为UNIX格式的时间戳|
|
|last_update_time|int|最后更新时间,为UNIX格式的时间戳|
|
||||||
|author |object|项目创建者|
|
|author |object|项目创建者|
|
||||||
|
@ -3980,7 +4015,9 @@ http://localhost:3000/api/users/Jason/projects.json | jq
|
||||||
|language |object|项目语言|
|
|language |object|项目语言|
|
||||||
|-- id |int|项目语言id|
|
|-- id |int|项目语言id|
|
||||||
|-- name |string|项目语言名称|
|
|-- name |string|项目语言名称|
|
||||||
|
|user_apply_signatures |object|用户创建的特殊许可申请|
|
||||||
|
|-- id |int|用户创建的特殊许可申请id|
|
||||||
|
|-- status |int|用户创建的特殊许可申请审核状态, 'unpassed': 审核未通过,'waiting': 等待审核 'passed':审核通过|
|
||||||
|
|
||||||
返回值
|
返回值
|
||||||
```json
|
```json
|
||||||
|
@ -3995,6 +4032,7 @@ http://localhost:3000/api/users/Jason/projects.json | jq
|
||||||
"praises_count": 0,
|
"praises_count": 0,
|
||||||
"forked_count": 0,
|
"forked_count": 0,
|
||||||
"is_public": true,
|
"is_public": true,
|
||||||
|
"is_secret": false,
|
||||||
"mirror_url": null,
|
"mirror_url": null,
|
||||||
"last_update_time": 1577697461,
|
"last_update_time": 1577697461,
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -4008,9 +4046,53 @@ http://localhost:3000/api/users/Jason/projects.json | jq
|
||||||
"language": {
|
"language": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "C"
|
"name": "C"
|
||||||
|
},
|
||||||
|
"user_apply_signatures":[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"status": "waiting"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
#### 特殊许可证项目用户创建申请
|
||||||
|
```
|
||||||
|
POST /api/apply_signatures
|
||||||
|
```
|
||||||
|
|
||||||
|
*示例*
|
||||||
|
```bash
|
||||||
|
curl -X POST \
|
||||||
|
-d "project_id=8" \
|
||||||
|
-d "attachment_id=4" \
|
||||||
|
http://localhost:3000/api/apply_signatures.json | jq
|
||||||
|
```
|
||||||
|
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
|参数名|必选|类型|说明|
|
||||||
|
|-|-|-|-|
|
||||||
|
|project_id |是|int |项目id |
|
||||||
|
|attachment_id |是|int |上传的文件id |
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
|参数名|类型|说明|
|
||||||
|
|-|-|-|
|
||||||
|
|id |int|特殊许可证项目用户创建申请的id|
|
||||||
|
|attachment |object|上传的文件|
|
||||||
|
|--filename |string|上传的文件的文件名|
|
||||||
|
|
||||||
|
返回值
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"attachment": {
|
||||||
|
"filename": "timg.jpeg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
|
@ -0,0 +1,30 @@
|
||||||
|
class Admins::ApplySignaturesController < Admins::BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
sort_by = params[:sort_by] ||= 'created_on'
|
||||||
|
sort_direction = params[:sort_direction] ||= 'desc'
|
||||||
|
|
||||||
|
@apply_signatures = paginate ApplySignature.waiting.includes(:attachments)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
begin
|
||||||
|
apply_signature = ApplySignature.find_by!(id: params[:id])
|
||||||
|
apply_signature.update_attributes!(apply_signatures_params)
|
||||||
|
Projects::AddMemberInteractor.call(apply_signature.project.owner, apply_signature.project, apply_signature.user, "write", true)
|
||||||
|
redirect_to admins_apply_signatures_path
|
||||||
|
flash[:success] = "更新成功"
|
||||||
|
rescue => e
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
redirect_to admins_apply_signatures_path
|
||||||
|
flash[:danger] = "更新失败"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def apply_signatures_params
|
||||||
|
params.permit(:status)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,25 @@
|
||||||
|
class ApplySignaturesController < ApplicationController
|
||||||
|
include ApplicationHelper
|
||||||
|
|
||||||
|
def template_file
|
||||||
|
license = License.find_by_name("PHengLEI")
|
||||||
|
file = license.attachments.take
|
||||||
|
normal_status(-1, "文件不存在") if file.blank?
|
||||||
|
send_file(absolute_path(local_path(file)), filename: file.title,stream:false, type: file.content_type.presence || 'application/octet-stream')
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
begin
|
||||||
|
@signature = current_user.apply_signatures.create!(project_id: params[:project_id])
|
||||||
|
@attachment = Attachment.find_by_id(params[:attachment_id])
|
||||||
|
@attachment.container = @signature
|
||||||
|
@attachment.save!
|
||||||
|
rescue Exception => e
|
||||||
|
tip_exception("#{e}")
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
render_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@ class ProjectsController < ApplicationController
|
||||||
scope = Projects::ListQuery.call(params)
|
scope = Projects::ListQuery.call(params)
|
||||||
|
|
||||||
# @projects = kaminari_paginate(scope)
|
# @projects = kaminari_paginate(scope)
|
||||||
@projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, owner: :user_extension)
|
@projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :apply_signatures, owner: :user_extension)
|
||||||
|
|
||||||
category_id = params[:category_id]
|
category_id = params[:category_id]
|
||||||
@total_count =
|
@total_count =
|
||||||
|
@ -53,7 +53,7 @@ class ProjectsController < ApplicationController
|
||||||
# else
|
# else
|
||||||
# projects = Project.visible
|
# projects = Project.visible
|
||||||
# end
|
# end
|
||||||
projects = Project.no_anomory_projects.visible
|
projects = Project.no_anomory_projects.secret_and_visible
|
||||||
language_lists = projects.joins(:project_language).group("project_languages.name", "project_languages.id").size.keys.sort.to_h
|
language_lists = projects.joins(:project_language).group("project_languages.name", "project_languages.id").size.keys.sort.to_h
|
||||||
@project_group_list = language_lists.delete_if { |k, v| k.blank? }
|
@project_group_list = language_lists.delete_if { |k, v| k.blank? }
|
||||||
end
|
end
|
||||||
|
@ -153,7 +153,7 @@ class ProjectsController < ApplicationController
|
||||||
private
|
private
|
||||||
def project_params
|
def project_params
|
||||||
params.permit(:user_id, :name, :description, :repository_name,
|
params.permit(:user_id, :name, :description, :repository_name,
|
||||||
:project_category_id, :project_language_id, :license_id, :ignore_id)
|
:project_category_id, :project_language_id, :license_id, :ignore_id, :private)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mirror_params
|
def mirror_params
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
module Projects
|
module Projects
|
||||||
class AddMemberInteractor
|
class AddMemberInteractor
|
||||||
def self.call(owner, project, collaborator, permission="write")
|
def self.call(owner, project, collaborator, permission="write", is_apply_signature=false)
|
||||||
interactor = new(owner, project, collaborator, permission)
|
interactor = new(owner, project, collaborator, permission, is_apply_signature)
|
||||||
interactor.run
|
interactor.run
|
||||||
interactor
|
interactor
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :error, :result
|
attr_reader :error, :result
|
||||||
|
|
||||||
def initialize(owner, project, collaborator, permission)
|
def initialize(owner, project, collaborator, permission, is_apply_signature)
|
||||||
@owner = owner
|
@owner = owner
|
||||||
@project = project
|
@project = project
|
||||||
@collaborator = collaborator
|
@collaborator = collaborator
|
||||||
@permission = permission
|
@permission = permission
|
||||||
|
@is_apply_signature = is_apply_signature
|
||||||
end
|
end
|
||||||
|
|
||||||
def success?
|
def success?
|
||||||
|
@ -23,7 +24,7 @@ module Projects
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
gitea_result = Gitea::Repository::Members::AddService.new(owner, project.identifier, collaborator.login, permission).call
|
gitea_result = Gitea::Repository::Members::AddService.new(owner, project.identifier, collaborator.login, permission).call
|
||||||
if gitea_result.status == 204
|
if gitea_result.status == 204
|
||||||
project.add_member!(collaborator.id)
|
project.add_member!(collaborator.id, 'Developer', is_apply_signature)
|
||||||
end
|
end
|
||||||
fail!(nil)
|
fail!(nil)
|
||||||
end
|
end
|
||||||
|
@ -32,7 +33,7 @@ module Projects
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
attr_reader :owner, :project, :collaborator, :permission
|
attr_reader :owner, :project, :collaborator, :permission, :is_apply_signature
|
||||||
|
|
||||||
def fail!(error)
|
def fail!(error)
|
||||||
@error = error
|
@error = error
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class ApplySignature < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :project
|
||||||
|
|
||||||
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
|
||||||
|
scope :with_user_id, -> (user_id) {where(user_id: user_id)}
|
||||||
|
|
||||||
|
enum status: {unpassed: -1, waiting: 0, passed: 1}
|
||||||
|
end
|
|
@ -10,8 +10,8 @@ module ProjectOperable
|
||||||
has_many :writable_members, -> { joins(:roles).where.not(roles: {name: 'Reporter'}) }, class_name: 'Member'
|
has_many :writable_members, -> { joins(:roles).where.not(roles: {name: 'Reporter'}) }, class_name: 'Member'
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_member!(user_id, role_name='Developer')
|
def add_member!(user_id, role_name='Developer', is_apply_signature=false)
|
||||||
member = members.create!(user_id: user_id)
|
member = members.create!(user_id: user_id, is_apply_signature: is_apply_signature)
|
||||||
set_developer_role(member)
|
set_developer_role(member)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,6 @@
|
||||||
|
|
||||||
class License < ApplicationRecord
|
class License < ApplicationRecord
|
||||||
include Projectable
|
include Projectable
|
||||||
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,12 +106,16 @@ class Project < ApplicationRecord
|
||||||
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
|
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
|
||||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||||
has_one :project_detail, dependent: :destroy
|
has_one :project_detail, dependent: :destroy
|
||||||
|
has_many :apply_signatures, dependent: :destroy
|
||||||
|
|
||||||
after_save :check_project_members
|
after_save :check_project_members
|
||||||
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
||||||
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
||||||
scope :recommend, -> { visible.project_statics_select.where(recommend: true) }
|
scope :recommend, -> { visible.project_statics_select.where(recommend: true) }
|
||||||
|
|
||||||
|
scope :secret_and_visible, -> {joins(:license).where("licenses.is_secret = TRUE OR projects.is_public = TRUE")}
|
||||||
|
|
||||||
|
delegate :is_secret, to: :license, allow_nil: true
|
||||||
|
|
||||||
|
|
||||||
def self.search_project(search)
|
def self.search_project(search)
|
||||||
|
|
|
@ -161,6 +161,7 @@ class User < ApplicationRecord
|
||||||
# has_many :libraries, dependent: :destroy
|
# has_many :libraries, dependent: :destroy
|
||||||
has_many :project_trends, dependent: :destroy
|
has_many :project_trends, dependent: :destroy
|
||||||
has_many :oauths , dependent: :destroy
|
has_many :oauths , dependent: :destroy
|
||||||
|
has_many :apply_signatures, dependent: :destroy
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
q = Project.visible.by_name_or_identifier(params[:search])
|
q = Project.secret_and_visible.by_name_or_identifier(params[:search])
|
||||||
|
|
||||||
scope = q
|
scope = q
|
||||||
.with_project_type(params[:project_type])
|
.with_project_type(params[:project_type])
|
||||||
|
|
|
@ -53,6 +53,11 @@ class Projects::CreateService < ApplicationService
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def repo_is_public
|
def repo_is_public
|
||||||
|
license = License.find_by_id(params[:license_id])
|
||||||
|
if license.is_secret
|
||||||
|
false
|
||||||
|
else
|
||||||
params[:private].blank? ? true : !params[:private]
|
params[:private].blank? ? true : !params[:private]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<% define_admin_breadcrumbs do %>
|
||||||
|
<% add_admin_breadcrumb('特殊许可申请列表') %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="box admin-list-container apply_signatures-list-container">
|
||||||
|
<%= render partial: 'admins/apply_signatures/shared/list', locals: { apply_signatures: @apply_signatures } %>
|
||||||
|
</div>
|
|
@ -0,0 +1,42 @@
|
||||||
|
<table class="table table-hover text-center subject-list-table">
|
||||||
|
<thead class="thead-light">
|
||||||
|
<tr>
|
||||||
|
<th width="10%">序号</th>
|
||||||
|
<th width="20%" class="text-left">项目名称</th>
|
||||||
|
<th width="20%">申请人</th>
|
||||||
|
<th width="25%">申请材料</th>
|
||||||
|
<th width="25%">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% if apply_signatures.present? %>
|
||||||
|
<% apply_signatures.each_with_index do |signature, index| %>
|
||||||
|
<tr class="sinature-item-<%= signature.id %>">
|
||||||
|
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||||
|
<td class="text-left">
|
||||||
|
<%= link_to(signature&.project&.name, "/projects/#{signature&.project&.owner.login}/#{signature&.project&.identifier}", target: '_blank') %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to(signature&.user&.real_name, "/users/#{signature&.user&.login}", target: '_blank') %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if signature.attachments.present? %>
|
||||||
|
<% signature.attachments.each do |attachment|%>
|
||||||
|
<%= image_tag("/api/attachments/#{attachment.id}", width: 40, height: 40, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td class="action-container">
|
||||||
|
<%= link_to "同意", admins_apply_signature_path(signature.id, status: 1), method: :patch, class: "delete-project-action" %>
|
||||||
|
<%= link_to "拒绝", admins_apply_signature_path(signature.id, status: -1), method: :patch, class: "delete-project-action" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= render 'admins/shared/no_data_for_table' %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= render partial: 'admins/shared/paginate', locals: { objects: apply_signatures } %>
|
|
@ -5,6 +5,7 @@
|
||||||
<th width="4%">ID</th>
|
<th width="4%">ID</th>
|
||||||
<th width="15%" class="text-left">项目名称</th>
|
<th width="15%" class="text-left">项目名称</th>
|
||||||
<th width="6%">公开</th>
|
<th width="6%">公开</th>
|
||||||
|
<th width="6%">特殊协议</th>
|
||||||
<th width="5%">issue</th>
|
<th width="5%">issue</th>
|
||||||
<th width="5%">资源</th>
|
<th width="5%">资源</th>
|
||||||
<th width="6%">版本库</th>
|
<th width="6%">版本库</th>
|
||||||
|
@ -23,9 +24,10 @@
|
||||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||||
<td><%= project.id %></td>
|
<td><%= project.id %></td>
|
||||||
<td class="text-left">
|
<td class="text-left">
|
||||||
<%= link_to(project.name, "/projects/#{project.owner.login}/#{project.identifier}", target: '_blank') %>
|
<%= link_to(project.name, "/projects/#{project.owner&.login}/#{project.identifier}", target: '_blank') %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= project.is_public ? '√' : '' %></td>
|
<td><%= project.is_public ? '√' : '' %></td>
|
||||||
|
<td><%= project.is_secret ? '√' : '' %></td>
|
||||||
<td><%= project.issues.size %></td>
|
<td><%= project.issues.size %></td>
|
||||||
<td><%= project.attachments.size %></td>
|
<td><%= project.attachments.size %></td>
|
||||||
<td><%= project&.project_score.try(:changeset_num).to_i %></td>
|
<td><%= project&.project_score.try(:changeset_num).to_i %></td>
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %></li>
|
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %></li>
|
||||||
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %></li>
|
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %></li>
|
||||||
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %></li>
|
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %></li>
|
||||||
|
<li><%= sidebar_item(admins_apply_signatures_path, '特殊许可申请列表', icon: 'git', controller: 'admins-apply_signatures') %></li>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
json.id @signature.id
|
||||||
|
json.attachment do
|
||||||
|
json.filename @attachment.filename
|
||||||
|
end
|
|
@ -1 +1 @@
|
||||||
json.licenses @licenses, :id, :name
|
json.licenses @licenses, :id, :name, :is_secret
|
||||||
|
|
|
@ -5,5 +5,6 @@ json.members @members do |member|
|
||||||
json.is_owner @project.owner?(member.user)
|
json.is_owner @project.owner?(member.user)
|
||||||
json.role member.roles.last.name
|
json.role member.roles.last.name
|
||||||
json.role_name t("roles.#{member.roles.last.name}")
|
json.role_name t("roles.#{member.roles.last.name}")
|
||||||
|
json.is_apply_signature member.is_apply_signature
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
# json.array! @category_group_list do |category,v|
|
json.array! @project_categories do |category|
|
||||||
# json.id category[0]
|
json.id category.id
|
||||||
# json.name category[1]
|
json.name category.name
|
||||||
# json.projects_count v
|
json.projects_count category.projects_count
|
||||||
# end
|
|
||||||
|
|
||||||
json.array! @category_group_list do |k,v|
|
|
||||||
children_category = @project_children_categories.get_children(v)
|
|
||||||
json.children do
|
|
||||||
json.array! children_category do |cate|
|
|
||||||
json.id cate[0]
|
|
||||||
json.name cate[1]
|
|
||||||
json.parent_id v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
json.id v
|
|
||||||
json.name k.to_s
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ json.visits project.visits
|
||||||
json.praises_count project.praises_count.to_i
|
json.praises_count project.praises_count.to_i
|
||||||
json.forked_count project.forked_count.to_i
|
json.forked_count project.forked_count.to_i
|
||||||
json.is_public project.is_public
|
json.is_public project.is_public
|
||||||
|
json.is_secret project.is_secret
|
||||||
json.mirror_url project.repository&.mirror_url
|
json.mirror_url project.repository&.mirror_url
|
||||||
json.type project&.numerical_for_project_type
|
json.type project&.numerical_for_project_type
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
@ -28,6 +29,13 @@ json.author do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
json.category do
|
||||||
|
if project.project_category.blank?
|
||||||
|
json.nil!
|
||||||
|
else
|
||||||
|
json.id project.project_category.id
|
||||||
|
json.name project.project_category.name
|
||||||
|
end
|
||||||
json.category do
|
json.category do
|
||||||
if project.project_category.blank?
|
if project.project_category.blank?
|
||||||
json.nil!
|
json.nil!
|
||||||
|
@ -44,3 +52,10 @@ json.language do
|
||||||
json.name project.project_language.name
|
json.name project.project_language.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
user_apply_signatures = project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ json.projects @projects do |project|
|
||||||
json.praises_count project.praises_count.to_i
|
json.praises_count project.praises_count.to_i
|
||||||
json.forked_count project.forked_count.to_i
|
json.forked_count project.forked_count.to_i
|
||||||
json.is_public project.is_public
|
json.is_public project.is_public
|
||||||
|
json.is_secret project.is_secret
|
||||||
json.mirror_url project.repository&.mirror_url
|
json.mirror_url project.repository&.mirror_url
|
||||||
json.type project&.numerical_for_project_type
|
json.type project&.numerical_for_project_type
|
||||||
json.last_update_time render_unix_time(project.updated_on)
|
json.last_update_time render_unix_time(project.updated_on)
|
||||||
|
@ -47,4 +48,9 @@ json.projects @projects do |project|
|
||||||
json.name project.project_language.name
|
json.name project.project_language.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
user_apply_signatures = project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
json.name @project.name
|
json.name @project.name
|
||||||
json.identifier @project.identifier
|
json.identifier @project.identifier
|
||||||
json.is_public @project.is_public
|
json.is_public @project.is_public
|
||||||
|
json.is_secret @project.is_secret
|
||||||
json.description @project.description
|
json.description @project.description
|
||||||
json.repo_id @project.repository.id
|
json.repo_id @project.repository.id
|
||||||
json.repo_identifier @project.repository.identifier
|
json.repo_identifier @project.repository.identifier
|
||||||
|
user_apply_signatures = @project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
|
@ -5,3 +5,4 @@ json.project_description @project.description
|
||||||
json.project_category_id @project.project_category_id
|
json.project_category_id @project.project_category_id
|
||||||
json.project_language_id @project.project_language_id
|
json.project_language_id @project.project_language_id
|
||||||
json.private !@project.is_public
|
json.private !@project.is_public
|
||||||
|
json.is_secret @project.is_secret
|
||||||
|
|
|
@ -17,6 +17,12 @@ json.mirror_url @project&.repository.mirror_url
|
||||||
json.mirror @project&.repository.mirror_url.present?
|
json.mirror @project&.repository.mirror_url.present?
|
||||||
json.type @project.numerical_for_project_type
|
json.type @project.numerical_for_project_type
|
||||||
json.open_devops @project.open_devops?
|
json.open_devops @project.open_devops?
|
||||||
|
json.is_secret @project.is_secret
|
||||||
|
user_apply_signatures = @project.apply_signatures.with_user_id(current_user.id)
|
||||||
|
json.user_apply_signatures user_apply_signatures do |signature|
|
||||||
|
json.id signature.id
|
||||||
|
json.status signature.status
|
||||||
|
end
|
||||||
|
|
||||||
unless @project.common?
|
unless @project.common?
|
||||||
json.mirror_status @repo.mirror_status
|
json.mirror_status @repo.mirror_status
|
||||||
|
|
|
@ -59,6 +59,11 @@ Rails.application.routes.draw do
|
||||||
delete :destroy_files
|
delete :destroy_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :apply_signatures, only: [:create] do
|
||||||
|
collection do
|
||||||
|
get :template_file
|
||||||
|
end
|
||||||
|
end
|
||||||
get 'home/index'
|
get 'home/index'
|
||||||
get 'home/search'
|
get 'home/search'
|
||||||
get 'main/first_stamp'
|
get 'main/first_stamp'
|
||||||
|
@ -771,6 +776,7 @@ Rails.application.routes.draw do
|
||||||
resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do
|
resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do
|
||||||
post :batch_add, on: :collection
|
post :batch_add, on: :collection
|
||||||
end
|
end
|
||||||
|
resources :apply_signatures, only: [:index, :update]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
class ResetVersionsCount < ActiveRecord::Migration[5.2]
|
|
||||||
def change
|
|
||||||
execute "ALTER TABLE licenses MODIFY COLUMN id INT AUTO_INCREMENT;"
|
|
||||||
versions = Version.includes(:issues).select(:id, :closed_issues_count, :percent,:issues_count)
|
|
||||||
versions.each do |v|
|
|
||||||
Version.reset_counters v.id, :issues
|
|
||||||
closed_issues = Issue.select(:id, :fixed_version_id, :status_id).where(fixed_version_id: v.id, status_id: 5).size
|
|
||||||
unless v.closed_issues_count.to_i == closed_issues
|
|
||||||
percent = v.issues_count.to_i <=0 ? 0.0 : (closed_issues.to_f / v.issues_count.to_i)
|
|
||||||
v.closed_issues_count = closed_issues
|
|
||||||
v.percent = percent
|
|
||||||
v.save
|
|
||||||
end
|
|
||||||
puts v.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateApplySignatures < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :apply_signatures do |t|
|
||||||
|
t.references :user
|
||||||
|
t.references :project
|
||||||
|
t.integer :status, default: 0
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddSomeColumnsAboutApplySignatures < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :licenses, :is_secret, :boolean, default: false
|
||||||
|
add_column :members, :is_apply_signature, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe ApplySignature, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue