Browse Source

[FIX]几处bug修复

pull/278/head
viletyy 5 years ago
parent
commit
aaa6483958
4 changed files with 8 additions and 2 deletions
  1. +4
    -1
      app/controllers/apply_signatures_controller.rb
  2. +2
    -0
      app/models/apply_signature.rb
  3. +1
    -1
      app/views/admins/apply_signatures/shared/_list.html.erb
  4. +1
    -0
      public/react/build

+ 4
- 1
app/controllers/apply_signatures_controller.rb View File

@@ -11,9 +11,12 @@ class ApplySignaturesController < ApplicationController
def create def create
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin 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 = Attachment.find_by_id(params[:attachment_id])
@attachment.container = @signature @attachment.container = @signature
@signature.save!
@attachment.save! @attachment.save!
rescue Exception => e rescue Exception => e
tip_exception("#{e}") tip_exception("#{e}")


+ 2
- 0
app/models/apply_signature.rb View File

@@ -23,5 +23,7 @@ class ApplySignature < ApplicationRecord


scope :with_user_id, -> (user_id) {where(user_id: user_id)} 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} enum status: {unpassed: -1, waiting: 0, passed: 1}
end end

+ 1
- 1
app/views/admins/apply_signatures/shared/_list.html.erb View File

@@ -22,7 +22,7 @@
<td> <td>
<% if signature.attachments.present? %> <% if signature.attachments.present? %>
<% signature.attachments.each do |attachment|%> <% 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 %>
<% end %> <% end %>


+ 1
- 0
public/react/build

@@ -0,0 +1 @@
Subproject commit 6348a15cdb954862dc1b7b5f045a432bcfde7dc4

Loading…
Cancel
Save