diff --git a/CHANGELOG.md b/CHANGELOG.md index 99e54cb..f406cfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 0.3.2 (2019-02-21) + +* Disable duplicate questionnaire functionality for questionnaires which are already a result of a duplication. + ### 0.3.0 (2018-12-12) * Bugfixing diff --git a/app/controllers/questionnaires_controller.rb b/app/controllers/questionnaires_controller.rb index b04ddc2..92aeb9f 100644 --- a/app/controllers/questionnaires_controller.rb +++ b/app/controllers/questionnaires_controller.rb @@ -324,7 +324,9 @@ def respondents end def duplicate - @questionnaires = Questionnaire.find(:all, :include => [:questionnaire_fields, :user, :questionnaire_parts ]) + # Temporarily disable questionnaire duplication for + # questionnaires which have already been created from another one. + @questionnaires = Questionnaire.includes(:questionnaire_fields, :user, :questionnaire_parts).where(original_id: nil) @questionnaire = Questionnaire.new respond_to do |format| format.html diff --git a/app/views/questionnaires/duplicate.html.erb b/app/views/questionnaires/duplicate.html.erb index 410a73b..868155f 100644 --- a/app/views/questionnaires/duplicate.html.erb +++ b/app/views/questionnaires/duplicate.html.erb @@ -8,6 +8,9 @@
<% info_tip_text = "

This page allows you to create new questionnaires from existing questionnaires. There is an option to copy not only the structure of the questionnaire, but its answers as well.

"-%>
+

+ <%= fa_icon('info-circle', class: 'info-icon--blue') %> ORS does not currently support duplication of questionnaires that have already been duplicated. Please contact ORS_team@unep-wcmc.org for more information. +

<%= form_for( @questionnaire, :html => { :class => "formtastic normal", :id => "generator_form" }) do |f| -%>
diff --git a/app/workers/clone_questionnaire.rb b/app/workers/clone_questionnaire.rb index 790385c..27d7b9b 100644 --- a/app/workers/clone_questionnaire.rb +++ b/app/workers/clone_questionnaire.rb @@ -6,7 +6,11 @@ def perform(user_id, questionnaire_id, url, copy_answers=false) user = User.find(user_id) questionnaire = Questionnaire.find(questionnaire_id) - return if !user || !questionnaire + # Temporarily disable questionnaire duplication for + # questionnaires which have already been created from another one. + has_source_questionnaire = questionnaire.original_id.present? + + return if !user || !questionnaire || has_source_questionnaire logger = Logger.new("#{Rails.root}/log/sidekiq.log") logger.info("#{Time.now}: Started duplication of questionnaire with#{if !copy_answers || copy_answers != "1" then "out" end} answers: #{questionnaire.title}")