diff --git a/app/controllers/apply_signatures_controller.rb b/app/controllers/apply_signatures_controller.rb index 54f64aa6..19907b11 100644 --- a/app/controllers/apply_signatures_controller.rb +++ b/app/controllers/apply_signatures_controller.rb @@ -11,9 +11,12 @@ class ApplySignaturesController < ApplicationController def create ActiveRecord::Base.transaction do begin - @signature = current_user.apply_signatures.create!(project_id: params[:project_id]) + @signature = current_user.apply_signatures.find_or_create_by!(project_id: params[:project_id]) + @signature.status = 0 + @signature.attachments = Attachment.none @attachment = Attachment.find_by_id(params[:attachment_id]) @attachment.container = @signature + @signature.save! @attachment.save! rescue Exception => e tip_exception("#{e}") diff --git a/app/models/apply_signature.rb b/app/models/apply_signature.rb index f6f7bfc3..d14283f7 100644 --- a/app/models/apply_signature.rb +++ b/app/models/apply_signature.rb @@ -23,5 +23,7 @@ class ApplySignature < ApplicationRecord scope :with_user_id, -> (user_id) {where(user_id: user_id)} + validates :project_id, uniqueness: {scope: :user_id} + enum status: {unpassed: -1, waiting: 0, passed: 1} end diff --git a/app/views/admins/apply_signatures/shared/_list.html.erb b/app/views/admins/apply_signatures/shared/_list.html.erb index ec028b30..36984aa9 100644 --- a/app/views/admins/apply_signatures/shared/_list.html.erb +++ b/app/views/admins/apply_signatures/shared/_list.html.erb @@ -22,7 +22,7 @@ <% 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: '点击预览' }) %> + <%= link_to "#{attachment.try(:filename)}",attachment_path(attachment), target: "_blank" %> <% end %> <% end %> diff --git a/public/react/build b/public/react/build new file mode 160000 index 00000000..6348a15c --- /dev/null +++ b/public/react/build @@ -0,0 +1 @@ +Subproject commit 6348a15cdb954862dc1b7b5f045a432bcfde7dc4