app/controllers/concepts/versions_controller.rb in iqvoc-4.13.2 vs app/controllers/concepts/versions_controller.rb in iqvoc-4.14.4
- old
+ new
@@ -31,11 +31,11 @@
authorize! :merge, new_version
ActiveRecord::Base.transaction do
new_version.rdf_updated_at = nil
new_version.publish
- new_version.unlock
+
if new_version.publishable?
new_version.save
if current_concept && !current_concept.destroy
flash[:error] = t('txt.controllers.versioning.merged_delete_error')
@@ -66,11 +66,11 @@
else
authorize! :branch, current_concept
new_version = nil
ActiveRecord::Base.transaction do
- new_version = current_concept.branch(current_user)
+ new_version = current_concept.branch
new_version.save!
Iqvoc.change_note_class.create! do |note|
note.owner = new_version
note.language = I18n.locale.to_s
note.position = (current_concept.send(Iqvoc.change_note_class_name.to_relation_name).maximum(:position) || 0).succ
@@ -83,49 +83,10 @@
flash[:success] = t('txt.controllers.versioning.branched')
redirect_to edit_concept_path(published: 0, id: new_version)
end
end
- def lock
- new_version = Iqvoc::Concept.base_class.
- by_origin(params[:origin]).
- unpublished.
- last!
-
- if new_version.locked?
- raise "Concept with origin '#{new_version.origin}' is already locked."
- end
-
- authorize! :lock, new_version
-
- new_version.lock_by_user(current_user.id)
- new_version.save validate: false
-
- flash[:success] = t('txt.controllers.versioning.locked')
- redirect_to edit_concept_path(published: 0, id: new_version)
- end
-
- def unlock
- new_version = Iqvoc::Concept.base_class.
- by_origin(params[:origin]).
- unpublished.
- last!
-
- unless new_version.locked?
- raise "Concept with origin '#{new_version.origin}' is not locked."
- end
-
- authorize! :unlock, new_version
-
- new_version.unlock
- new_version.save validate: false
-
- flash[:success] = t('txt.controllers.versioning.unlocked')
-
- redirect_to concept_path(published: 0, id: new_version)
- end
-
def consistency_check
concept = Iqvoc::Concept.base_class.
by_origin(params[:origin]).
unpublished.
last!
@@ -135,26 +96,30 @@
if concept.publishable?
flash[:success] = t('txt.controllers.versioning.consistency_check_success')
redirect_to concept_path(published: 0, id: concept)
else
flash[:error] = t('txt.controllers.versioning.consistency_check_error')
- redirect_to edit_concept_path(published: 0, id: concept, full_consistency_check: '1')
+ redirect_to concept_path(published: 0, id: concept, full_consistency_check: '1')
end
end
def to_review
concept = Iqvoc::Concept.base_class.
by_origin(params[:origin]).
unpublished.
last!
authorize! :send_to_review, concept
- concept.to_review
- authorize! :unlock, concept
- concept.unlock
+ # Only send the concept to review if it is publishable (e.g. consistency check is OK)
+ if concept.publishable?
+ concept.to_review
+ concept.save!
- concept.save!
- flash[:success] = t('txt.controllers.versioning.to_review_success')
- redirect_to concept_path(published: 0, id: concept)
+ flash[:success] = t('txt.controllers.versioning.to_review_success')
+ redirect_to concept_path(published: 0, id: concept)
+ else
+ flash[:error] = t('txt.controllers.versioning.consistency_check_error')
+ redirect_to concept_path(published: 0, id: concept, full_consistency_check: '1')
+ end
end
end