mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Merge pull request #1178 from okriuchykhin/ok_SCI_2462
Add user id tracking when discarding repository [SCI-2462]
This commit is contained in:
commit
3253cac86f
3 changed files with 12 additions and 13 deletions
|
@ -74,7 +74,7 @@ class RepositoriesController < ApplicationController
|
|||
flash[:success] = t('repositories.index.delete_flash',
|
||||
name: @repository.name)
|
||||
@repository.discard
|
||||
ClearDiscardedRepositoriesJob.perform_later
|
||||
@repository.destroy_discarded(current_user.id)
|
||||
redirect_to team_repositories_path
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
class ClearDiscardedRepositoriesJob
|
||||
class << self
|
||||
def perform_later
|
||||
Repository.with_discarded.discarded.destroy_all
|
||||
end
|
||||
|
||||
handle_asynchronously :perform_later,
|
||||
queue: :clear_discarded_repositories,
|
||||
priority: 20
|
||||
end
|
||||
end
|
|
@ -2,7 +2,9 @@ class Repository < ApplicationRecord
|
|||
include SearchableModel
|
||||
include RepositoryImportParser
|
||||
include Discard::Model
|
||||
|
||||
|
||||
attribute :discarded_by_id, :integer
|
||||
|
||||
belongs_to :team, optional: true
|
||||
belongs_to :created_by,
|
||||
foreign_key: :created_by_id,
|
||||
|
@ -107,4 +109,12 @@ class Repository < ApplicationRecord
|
|||
importer = RepositoryImportParser::Importer.new(sheet, mappings, user, self)
|
||||
importer.run
|
||||
end
|
||||
|
||||
def destroy_discarded(discarded_by_id = nil)
|
||||
self.discarded_by_id = discarded_by_id
|
||||
destroy
|
||||
end
|
||||
handle_asynchronously :destroy_discarded,
|
||||
queue: :clear_discarded_repository,
|
||||
priority: 20
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue