- <%= render partial: 'annotations/show_annotation', locals: {annotation: example_answer, question: question} %>
+ <% if example_answer.present? || guidance.present? %>
+
+ <%= render partial: 'annotations/show_annotation', locals: {example_answer: example_answer, guidance: guidance, question: question} %>
- <%= render partial: 'annotations/edit_annotation', locals: {annotation: example_answer, question: question} %>
+
+ <%= render partial: 'annotations/edit_annotation', locals: {example_answer: example_answer, guidance: guidance, question: question} %>
<% end %>
-
+
<%= render partial: 'annotations/add_annotation', locals: {question: question} %>
<% end %>
@@ -125,13 +126,12 @@
<%= link_to _('Delete question'), admin_destroy_question_path(question_id: question.id),
confirm: _("You are about to delete '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%>
- <% elsif !@edit && question.modifiable %>
- <% example_answer = question.get_example_answer(current_user.org_id) %>
- <% if example_answer.nil? %>
-
diff --git a/app/views/templates/_show_template.html.erb b/app/views/templates/_show_template.html.erb
index 423dc5f..fed7740 100644
--- a/app/views/templates/_show_template.html.erb
+++ b/app/views/templates/_show_template.html.erb
@@ -2,9 +2,11 @@
<% if template == current then %>
+ <% if template.customization_of.nil? %>
<%= link_to _('Edit template details'), '# ', class: "btn btn-primary", id: "edit_template_button"%>
+ <% end %>
<% end %>
diff --git a/app/views/templates/admin_index.html.erb b/app/views/templates/admin_index.html.erb
index 71ee063..37e6b6a 100644
--- a/app/views/templates/admin_index.html.erb
+++ b/app/views/templates/admin_index.html.erb
@@ -139,7 +139,7 @@
<% if hash[:current].customization_of.nil? %>
<% b_label = _('Customise') %>
- <%= link_to b_label, admin_customize_template_path(hash[:current]), method: :put, class: "dmp_table_link" %>
+ <%= link_to b_label, admin_customize_template_path(hash[:current]), method: :get, class: "dmp_table_link" %>
<% else %>
<% b_label = _('Edit customisation') %>
<%= link_to b_label, admin_template_template_path(hash[:current]), class: "dmp_table_link" %>
diff --git a/app/views/templates/admin_template.html.erb b/app/views/templates/admin_template.html.erb
index 6303ed0..77b956a 100644
--- a/app/views/templates/admin_template.html.erb
+++ b/app/views/templates/admin_template.html.erb
@@ -19,7 +19,7 @@
- <% if @template == @current %>
+ <% if @template == @current && @template.customization_of.nil? %>
<%= render partial: "templates/edit_template", locals: {template: @template, hash: @hash}%>
diff --git a/config/locale/app.pot b/config/locale/app.pot
index 960a80d..f51cfec 100644
--- a/config/locale/app.pot
+++ b/config/locale/app.pot
@@ -8,8 +8,8 @@
msgstr ""
"Project-Id-Version: app 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-06-02 19:14+0100\n"
-"PO-Revision-Date: 2017-06-02 19:14+0100\n"
+"POT-Creation-Date: 2017-06-06 12:18+0100\n"
+"PO-Revision-Date: 2017-06-06 12:18+0100\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"Language: \n"
@@ -207,6 +207,9 @@
" Email %{organisation_email} "
msgstr ""
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr ""
+
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr ""
@@ -243,7 +246,7 @@
msgid "Actions"
msgstr ""
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
msgstr ""
msgid "Add collaborator"
diff --git a/config/locale/de/app.po b/config/locale/de/app.po
index bbc0715..82a56da 100644
--- a/config/locale/de/app.po
+++ b/config/locale/de/app.po
@@ -224,6 +224,10 @@
msgstr "DMPonline"
#, fuzzy
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr "DMPonline"
+
+#, fuzzy
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr "A colleague has invited you to contribute to their Data Management Plan at"
@@ -260,8 +264,9 @@
msgid "Actions"
msgstr "Aktionen"
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
-msgstr "Geben Sie einen geeigneten Namen für Ihre Hilfestellungsgruppe ein, wie z.B. 'CAU Hilfestellungen'. Dieser Name soll den Nutzern vermitteln, woher die Hilfestellung kommt, z.B. 'CAU Hilfestellung zu Metadaten'"
+#, fuzzy
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
+msgstr "Hilfestellungsgruppe"
msgid "Add collaborator"
msgstr "Mitarbeitende(n) hinzufügen"
diff --git a/config/locale/en_GB/app.po b/config/locale/en_GB/app.po
index f35d162..ce40929 100644
--- a/config/locale/en_GB/app.po
+++ b/config/locale/en_GB/app.po
@@ -216,6 +216,10 @@
" Email %{organisation_email} "
msgstr "%{application_name}"
+#, fuzzy
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr "%{application_name}"
+
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr "A colleague has invited you to contribute to their Data Management Plan at "
@@ -252,8 +256,9 @@
msgid "Actions"
msgstr "Actions"
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
-msgstr "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
+#, fuzzy
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
+msgstr "guidance group"
msgid "Add collaborator"
msgstr "Add collaborator"
diff --git a/config/locale/en_US/app.po b/config/locale/en_US/app.po
index 3bae78c..d582337 100644
--- a/config/locale/en_US/app.po
+++ b/config/locale/en_US/app.po
@@ -216,6 +216,10 @@
" Email %{organisation_email} "
msgstr "%{application_name}"
+#, fuzzy
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr "%{application_name}"
+
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr "A colleague has invited you to contribute to their Data Management Plan at "
@@ -252,8 +256,9 @@
msgid "Actions"
msgstr "Actions"
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
-msgstr "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
+#, fuzzy
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
+msgstr "guidance group"
msgid "Add collaborator"
msgstr "Add collaborator"
diff --git a/config/locale/es/app.po b/config/locale/es/app.po
index 55298f2a..ed322cb 100644
--- a/config/locale/es/app.po
+++ b/config/locale/es/app.po
@@ -220,6 +220,10 @@
" Email %{organisation_email} "
msgstr "DMPonline"
+#, fuzzy
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr "DMPonline"
+
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr ""
@@ -256,8 +260,9 @@
msgid "Actions"
msgstr "Acciones"
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
-msgstr "Añada un nombre adecuado para el grupo de su guía (Ej: Guía de Glasgow). Este nombre se usará para indicar a los usuarios finales la procedencia de la guía (Ej: 'Guía de metadatos de Glasgow')"
+#, fuzzy
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
+msgstr "Grupo de orientación"
msgid "Add collaborator"
msgstr "Añadir colaborador"
diff --git a/config/locale/fr/app.po b/config/locale/fr/app.po
index 5fb2580..98bad88 100644
--- a/config/locale/fr/app.po
+++ b/config/locale/fr/app.po
@@ -219,6 +219,10 @@
" Email %{organisation_email} "
msgstr "DMPonline"
+#, fuzzy
+msgid "A Data Management Plan in %{application_name} has been shared with you"
+msgstr "DMPonline"
+
msgid "A colleague has invited you to contribute to their Data Management Plan at "
msgstr ""
@@ -255,8 +259,9 @@
msgid "Actions"
msgstr "Actions"
-msgid "Add an appropriate name for your guidance group e.g. Glasgow guidance. This name will be used to tell the end user where the guidance has come from e.g. 'Glasgow Guidance on Metadata'"
-msgstr "Ajoutez un nom adéquat à votre groupe de conseils, par ex. : Conseils de Glasgow. Ce nom sera utilié pour indiquer à lutilisateur final lorigine des conseils, par ex. : Glasgow Guidance on Metadata"
+#, fuzzy
+msgid "Add an appropriate name for your guidance group. This name will be used to tell the end user where the guidance has come from. It will be appended to text identifying the theme e.g. \"[guidance group name]: guidance on data sharing\" so we suggest you just use the institution or department name."
+msgstr "Groupe de conseils"
msgid "Add collaborator"
msgstr "Ajouter le collaborateur"
diff --git a/config/routes.rb b/config/routes.rb
index 8fee9ee..4591fc9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -125,10 +125,10 @@
get 'admin_template'
get 'admin_new'
get 'admin_template_history'
+ get 'admin_customize'
delete 'admin_destroy'
post 'admin_create'
put 'admin_update'
- put 'admin_customize'
put 'admin_publish'
put 'admin_unpublish'
end
diff --git a/lib/assets/javascripts/admin.js b/lib/assets/javascripts/admin.js
index 5997e27..35a3a4c 100644
--- a/lib/assets/javascripts/admin.js
+++ b/lib/assets/javascripts/admin.js
@@ -255,33 +255,40 @@
e.preventDefault();
});
- //SUGGESTED ANSWERS
- //action for adding a new suggested answer
- $('.add_suggested_answer_button').click(function(e){
+ //ANNOTATIONS
+ //action for adding a new annotation
+ $('.add_annotations_button').click(function(e){
var q_id = $(this).prev(".question_id").val();
-
- $('#add_suggested_answer_block_'+ q_id).show();
- $('#add_suggested_answer_button_'+ q_id).hide();
+ $('#add_annotations_block_'+ q_id).show();
+ $('#add_annotations_button_'+ q_id).hide();
e.preventDefault();
});
- //cancelling edit of a suggested answer
- $(".cancel_edit_suggested_answer").click(function(e){
+ //cancelling edit of an annotation
+ $(".cancel_edit_annotations").click(function(e){
var q_id = $(this).prev(".question_id").val();
- $('#edit_suggested_answer_div_'+ q_id).hide();
- $('#show_suggested_answer_div_'+ q_id).show();
+ $('#edit_annotations_div_'+ q_id).hide();
+ $('#show_annotations_div_'+ q_id).show();
e.preventDefault();
});
- //edit a suggested answer
- $('.edit_form_for_suggested_answer').click(function(e){
+ //cancelling edit of an annotation
+ $(".cancel_add_annotations").click(function(e){
+ var q_id = $(this).prev(".question_id").val();
+ $('#add_annotations_block_'+ q_id).hide();
+ $('#add_annotations_button_'+ q_id).show();
+ e.preventDefault();
+ });
+
+ //edit an annotation
+ $('.edit_form_for_annotations').click(function(e){
var q_id = $(this).prev(".question_id").val();
- $('#edit_suggested_answer_div_'+ q_id).show();
- $('#show_suggested_answer_div_'+ q_id).hide();
+ $('#edit_annotations_div_'+ q_id).show();
+ $('#show_annotations_div_'+ q_id).hide();
e.preventDefault();
});
- //GUIDANCE
+ //GUIDANCE
//action for adding a new guidance next to the question
$('.add_guidance_button').click(function(e){
var q_id = $(this).prev(".question_id").val();
diff --git a/test/functional/annotations_controller_test.rb b/test/functional/annotations_controller_test.rb
index 8615d16..67c7756 100644
--- a/test/functional/annotations_controller_test.rb
+++ b/test/functional/annotations_controller_test.rb
@@ -36,59 +36,72 @@
# POST /org/admin/templates/suggested_answers/:id/admin_create (admin_create_annotation_path)
# ----------------------------------------------------------
test "create a new annotation" do
- params = {org_id: @user.org.id, question_id: @question.id, text: "Here's a suggestion"}
+ params_guid = {question_id: @question.id, guidance_text: "some guidance text"}
+ params_example = {question_id: @question.id, example_answer_text: "example answer text"}
+ params_both = {question_id: @question.id, example_answer_text: "example answer text", guidance_text: "some guidance text"}
# Should redirect user to the root path if they are not logged in!
- post admin_create_annotation_path(@question.id), {annotation: params}
+ post admin_create_annotation_path(id: Annotation.first.id), params_both
assert_unauthorized_redirect_to_root_path
sign_in @user
- post admin_create_annotation_path(@question.id), {annotation: params}
+ # both
+ post admin_create_annotation_path(id: Annotation.first.id), params_both
assert_response :redirect
assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
assert_equal _('Information was successfully created.'), flash[:notice]
- assert_equal "Here's a suggestion", Annotation.last.text, "expected the record to have been created!"
- assert assigns(:example_answer)
+ assert_equal "some guidance text", Annotation.last.text, "expected the guidance to have been created!"
+ assert_equal "example answer text", Annotation.all[-2].text, "expected the example answer to have been created"
+ # just an example answer
+ post admin_create_annotation_path(id: Annotation.first.id), params_example
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert_equal _('Information was successfully created.'), flash[:notice]
+ assert_equal "example answer text", Annotation.last.text, "expected the record to have been created!"
+ # just some guidance
+ post admin_create_annotation_path(id: Annotation.first.id), params_guid
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert_equal _('Information was successfully created.'), flash[:notice]
+ assert_equal "some guidance text", Annotation.last.text, "expected the record to have been created!"
- # Invalid object
- post admin_create_annotation_path(@question.id), {annotation: {question_id: @question.id}}
- assert flash[:notice].starts_with?(_('Could not create your'))
- assert_response :success
- assert assigns(:example_answer)
end
# PUT /org/admin/templates/suggested_answers/:id/admin_update (admin_update_suggested_answer_path)
# ----------------------------------------------------------
test "update the annotation" do
- params = {text: 'UPDATE'}
+ q = Annotation.first.question
+ params_guid = {question_id: q.id, guidance_id: Annotation.first.id ,guidance_text: 'UPDATE'}
+ params_example = {question_id: q.id, example_answer_id: Annotation.first.id, example_answer_text: 'UPDATE'}
+ params_both = {question_id: q.id, guidance_id: Annotation.first.id ,guidance_text: 'gUPDATE',example_answer_id: Annotation.last.id, example_answer_text: 'eUPDATE'}
# Should redirect user to the root path if they are not logged in!
- put admin_update_annotation_path(Annotation.first), {annotation: params}
+ put admin_update_annotation_path(id: Annotation.first.id), params_guid
assert_unauthorized_redirect_to_root_path
sign_in @user
- # Valid save
- put admin_update_annotation_path(Annotation.first), {annotation: params}
+ # Valid save for guidance only
+ put admin_update_annotation_path(id: Annotation.first.id), params_guid
assert_equal _('Information was successfully updated.'), flash[:notice]
assert_response :redirect
assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
- assert assigns(:example_answer)
- assert assigns(:question)
- assert assigns(:section)
- assert assigns(:phase)
assert_equal 'UPDATE', Annotation.first.text, "expected the record to have been updated"
+ # valid save for example only
+ put admin_update_annotation_path(id: Annotation.first.id), params_example
+ assert_equal _('Information was successfully updated.'), flash[:notice]
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert_equal 'UPDATE', Annotation.first.text, "expected the record to have been updated"
+ # valid save for both example answer and guidance
+ put admin_update_annotation_path(id: Annotation.first.id), params_both
+ assert_equal _('Information was successfully updated.'), flash[:notice]
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert_equal 'gUPDATE', Annotation.first.text, "expected the record to have been updated"
+ assert_equal 'eUPDATE', Annotation.last.text, "expected the record to have been updated"
-# TODO: We need to add in validation checks on the model and reactivate this test
- # Invalid save
-# put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: {text: nil}}
-# assert flash[:notice].starts_with?(_('Could not update your'))
-# assert_response :success
-# assert assigns(:suggested_answer)
-# assert assigns(:question)
-# assert assigns(:section)
-# assert assigns(:phase)
end
# DELETE /org/admin/templates/suggested_answers/:id/admin_destroy (admin_destroy_suggested_answer_path)
diff --git a/test/functional/templates_controller_test.rb b/test/functional/templates_controller_test.rb
index 70e6edd..0987259 100644
--- a/test/functional/templates_controller_test.rb
+++ b/test/functional/templates_controller_test.rb
@@ -211,7 +211,7 @@
# ----------------------------------------------------------
test "customize a funder template" do
# Make sure we are redirected if we're not logged in
- put admin_customize_template_path(@template)
+ get admin_customize_template_path(@template)
assert_unauthorized_redirect_to_root_path
funder_template = Template.create(org: Org.funders.first, title: 'Testing integration')
@@ -228,7 +228,7 @@
template = Template.live(funder_template.dmptemplate_id)
- put admin_customize_template_path(template)
+ get admin_customize_template_path(template)
customization = Template.where(customization_of: template.dmptemplate_id).last
|