Skip to content

Commit

Permalink
Merge branch 'release-0.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Levia committed Feb 21, 2019
2 parents cfa498f + e194bbe commit 07167c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/questionnaires/duplicate.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<div id="content_header">
<% info_tip_text = "<p>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.</p>"-%>
</div>
<p>
<%= fa_icon('info-circle', class: 'info-icon--blue') %> ORS does not currently support duplication of questionnaires that have already been duplicated. Please contact <a href="mailto:ORS_team@unep-wcmc.org">ORS_team@unep-wcmc.org</a> for more information.
</p>
<div class="span-15 colborder" id="duplicate_questionnaire">
<%= form_for( @questionnaire, :html => { :class => "formtastic normal", :id => "generator_form" }) do |f| -%>
<fieldset>
Expand Down
6 changes: 5 additions & 1 deletion app/workers/clone_questionnaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 07167c2

Please sign in to comment.