mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Merge pull request #2590 from biosistemika/SCI-4628-schedule-snapshots-for-locked-tasks
[SCI-4628] moving snapshot provisioning logic into repository model, ma…
This commit is contained in:
commit
bc70ceb120
3 changed files with 15 additions and 10 deletions
|
@ -31,15 +31,7 @@ class MyModuleRepositorySnapshotsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
repository_snapshot = @repository.dup.becomes(RepositorySnapshot)
|
||||
repository_snapshot.assign_attributes(type: RepositorySnapshot.name,
|
||||
original_repository: @repository,
|
||||
my_module: @my_module,
|
||||
created_by: current_user)
|
||||
repository_snapshot.provisioning!
|
||||
repository_snapshot.reload
|
||||
|
||||
RepositorySnapshotProvisioningJob.perform_later(repository_snapshot)
|
||||
repository_snapshot = @repository.provision_snapshot(@my_module, current_user)
|
||||
|
||||
render json: {
|
||||
html: render_to_string(partial: 'my_modules/repositories/full_view_version',
|
||||
|
|
|
@ -191,4 +191,17 @@ class Repository < RepositoryBase
|
|||
importer = RepositoryImportParser::Importer.new(sheet, mappings, user, self)
|
||||
importer.run
|
||||
end
|
||||
|
||||
def provision_snapshot(my_module, created_by = nil)
|
||||
created_by ||= self.created_by
|
||||
repository_snapshot = dup.becomes(RepositorySnapshot)
|
||||
repository_snapshot.assign_attributes(type: RepositorySnapshot.name,
|
||||
original_repository: self,
|
||||
my_module: my_module,
|
||||
created_by: created_by)
|
||||
repository_snapshot.provisioning!
|
||||
repository_snapshot.reload
|
||||
RepositorySnapshotProvisioningJob.perform_later(repository_snapshot)
|
||||
repository_snapshot
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class RepositorySnapshot < RepositoryBase
|
|||
|
||||
validates :name, presence: true, length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
validates :status, presence: true
|
||||
validate :only_one_selected_for_my_module
|
||||
validate :only_one_selected_for_my_module, if: ->(obj) { obj.changed.include? :selected }
|
||||
|
||||
def default_columns_count
|
||||
Constants::REPOSITORY_SNAPSHOT_TABLE_DEFAULT_STATE['length']
|
||||
|
|
Loading…
Reference in a new issue