From 47cc70f2c520dbdd799810c0a24f40a0318e4d6b Mon Sep 17 00:00:00 2001 From: viletyy Date: Mon, 28 Dec 2020 12:31:05 +0800 Subject: [PATCH] =?UTF-8?q?[ADD]=E5=A2=9E=E5=8A=A0=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/apply_signatures_controller.rb | 9 +++++++++ app/controllers/projects_controller.rb | 2 +- app/views/admins/projects/shared/_list.html.erb | 2 +- config/routes.rb | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/apply_signatures_controller.rb b/app/controllers/apply_signatures_controller.rb index 652e59896..cabcb56d6 100644 --- a/app/controllers/apply_signatures_controller.rb +++ b/app/controllers/apply_signatures_controller.rb @@ -1,4 +1,13 @@ class ApplySignaturesController < ApplicationController + include ApplicationHelper + + def template_file + license = License.find_by_name("PHengLET") + 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 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e5680c4a5..c2486949d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -153,7 +153,7 @@ class ProjectsController < ApplicationController private def project_params 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 def mirror_params diff --git a/app/views/admins/projects/shared/_list.html.erb b/app/views/admins/projects/shared/_list.html.erb index fc2cd52cb..d4fa5a423 100644 --- a/app/views/admins/projects/shared/_list.html.erb +++ b/app/views/admins/projects/shared/_list.html.erb @@ -24,7 +24,7 @@ <%= list_index_no((params[:page] || 1).to_i, index) %> <%= project.id %> - <%= link_to(project.name, "/projects/#{project.owner.login}/#{project.identifier}", target: '_blank') %> + <%= link_to(project.name, "/projects/#{project.owner&.login}/#{project.identifier}", target: '_blank') %> <%= project.is_public ? '√' : '' %> <%= project.is_secret ? '√' : '' %> diff --git a/config/routes.rb b/config/routes.rb index 4234d2e04..0bca7da2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -59,7 +59,11 @@ Rails.application.routes.draw do delete :destroy_files end end - resources :apply_signatures, only: [:create] + resources :apply_signatures, only: [:create] do + collection do + get :template_file + end + end get 'home/index' get 'home/search' get 'main/first_stamp'