diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index bcaf9b9..1c47e84 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -91,30 +91,53 @@ end def do_update(require_password = true, confirm = false) - if require_password # user is changing email or password - if current_user.email != params[:user][:email] # if user is changing email - if params[:user][:current_password].blank? # password needs to be present - message = _('Please enter your password to change email address.') - successfully_updated = false - else + mandatory_params = true + message = _('Save Unsuccessful.') + ' ' # added to by below, overwritten otherwise + # ensure that the required fields are present + if params[:user][:email].blank? + message +=_('Please enter an email address.') + ' ' + mandatory_params &&= false + end + if params[:user][:firstname].blank? + message +=_('Please enter a First name.') + ' ' + mandatory_params &&= false + end + if params[:user][:surname].blank? + message +=_('Please enter a Last name.') + ' ' + mandatory_params &&= false + end + if params[:user][:org_id].blank? + message += _('Please select an organisation, or select Other.') + mandatory_params &&= false + end + if mandatory_params # has the user entered all the details + if require_password # user is changing email or password + if current_user.email != params[:user][:email] # if user is changing email + if params[:user][:current_password].blank? # password needs to be present + message = _('Please enter your password to change email address.') + successfully_updated = false + else + successfully_updated = current_user.update_with_password(password_update) + end + elsif params[:user][:password].present? # if user is changing password + successfully_updated = false # shared across first 3 conditions + if params[:user][:current_password].blank? + message = _('Please enter your current password') + elsif params[:user][:password_confirmation].blank? + message = _('Please enter a password confirmation') + elsif params[:user][:password] != params[:user][:password_confirmation] + message = _('Password and comfirmation must match') + else + successfully_updated = current_user.update_with_password(password_update) + end + else # potentially unreachable... but I dont like to leave off the else successfully_updated = current_user.update_with_password(password_update) end - elsif params[:user][:password].present? # if user is changing password - successfully_updated = false # shared across first 3 conditions - if params[:user][:current_password].blank? - message = _('Please enter your current password') - elsif params[:user][:password_confirmation].blank? - message = _('Please enter a password confirmation') - elsif params[:user][:password] != params[:user][:password_confirmation] - message = _('Password and comfirmation must match') - else - successfully_updated = current_user.update_with_password(password_update) - end - else # potentially unreachable... but I dont like to leave off the else - successfully_updated = current_user.update_with_password(password_update) + else # password not required + successfully_updated = current_user.update_without_password(update_params) end - else # password not required - successfully_updated = current_user.update_without_password(update_params) + else + successfully_updated = false end #unlink shibboleth from user's details diff --git a/app/views/annotations/_add_annotation.html.erb b/app/views/annotations/_add_annotation.html.erb index 51e62d4..8add942 100644 --- a/app/views/annotations/_add_annotation.html.erb +++ b/app/views/annotations/_add_annotation.html.erb @@ -26,7 +26,7 @@
<%= submit_tag _('Save'), class: "btn btn-primary" %> - <%= hidden_field_tag :question_id, question.id %> - <%= link_to _('Cancel'), "#", id: "cancel_add_annotations", class: "btn cancel" %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + <%= link_to _('Cancel'), "#", class: "btn cancel cancel_add_annotations" %>
<%end%> diff --git a/config/locale/app.pot b/config/locale/app.pot index d0af969..1520d3f 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-07 12:24+0100\n" -"PO-Revision-Date: 2017-06-07 12:24+0100\n" +"POT-Creation-Date: 2017-06-08 13:02+0100\n" +"PO-Revision-Date: 2017-06-08 13:02+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -966,6 +966,12 @@ msgid "Plan was successfully updated." msgstr "" +msgid "Please enter a First name." +msgstr "" + +msgid "Please enter a Last name." +msgstr "" + msgid "Please enter a password confirmation" msgstr "" @@ -978,6 +984,9 @@ msgid "Please enter an email address" msgstr "" +msgid "Please enter an email address." +msgstr "" + msgid "Please enter the name of your organisation." msgstr "" @@ -1014,6 +1023,9 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +msgid "Please select an organisation, or select Other." +msgstr "" + msgid "Please select one" msgstr "" @@ -1119,6 +1131,9 @@ msgid "Save" msgstr "" +msgid "Save Unsuccessful." +msgstr "" + msgid "Saving..." msgstr "" diff --git a/config/locale/de/app.po b/config/locale/de/app.po index 05fb0a6..8146f34 100644 --- a/config/locale/de/app.po +++ b/config/locale/de/app.po @@ -1022,6 +1022,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Bitte geben Sie ihren Vornamen ein." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Bitte geben Sie ihren Vornamen ein." + msgid "Please enter a password confirmation" msgstr "" @@ -1034,6 +1042,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Bitte prüfen Sie die Korrektheit ihrer Web-Adresse." + msgid "Please enter the name of your organisation." msgstr "Bitte geben Sie den Namen Ihrer Organisation an." @@ -1071,6 +1083,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organisation" + msgid "Please select one" msgstr "" @@ -1178,6 +1194,10 @@ msgid "Save" msgstr "Speichern" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Speichern" + msgid "Saving..." msgstr "Speichere..." diff --git a/config/locale/en_GB/app.po b/config/locale/en_GB/app.po index 7917de2..d0ebad7 100644 --- a/config/locale/en_GB/app.po +++ b/config/locale/en_GB/app.po @@ -1001,6 +1001,14 @@ msgid "Plan was successfully updated." msgstr "Plan was successfully updated." +#, fuzzy +msgid "Please enter a First name." +msgstr "Please enter your first name." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Please enter your first name." + msgid "Please enter a password confirmation" msgstr "" @@ -1013,6 +1021,10 @@ msgid "Please enter an email address" msgstr "Please enter an email address" +#, fuzzy +msgid "Please enter an email address." +msgstr "Please enter an email address" + msgid "Please enter the name of your organisation." msgstr "Please enter the name of your organisation." @@ -1050,6 +1062,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "organisation" + msgid "Please select one" msgstr "" @@ -1157,6 +1173,10 @@ msgid "Save" msgstr "Save" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Save" + msgid "Saving..." msgstr "Saving..." diff --git a/config/locale/en_US/app.po b/config/locale/en_US/app.po index bc78cda..4cb0fb5 100644 --- a/config/locale/en_US/app.po +++ b/config/locale/en_US/app.po @@ -1001,6 +1001,14 @@ msgid "Plan was successfully updated." msgstr "Plan was successfully updated." +#, fuzzy +msgid "Please enter a First name." +msgstr "Please enter your first name." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Please enter your first name." + msgid "Please enter a password confirmation" msgstr "" @@ -1013,6 +1021,10 @@ msgid "Please enter an email address" msgstr "Please enter an email address" +#, fuzzy +msgid "Please enter an email address." +msgstr "Please enter an email address" + msgid "Please enter the name of your organisation." msgstr "Please enter the name of your organization." @@ -1050,6 +1062,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "Please only enter up to 165 characters, you have used" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "organization" + msgid "Please select one" msgstr "" @@ -1157,6 +1173,10 @@ msgid "Save" msgstr "Save" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Save" + msgid "Saving..." msgstr "Saving..." diff --git a/config/locale/es/app.po b/config/locale/es/app.po index 25a2dcd..25d8f59 100644 --- a/config/locale/es/app.po +++ b/config/locale/es/app.po @@ -1017,6 +1017,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Por favor, introduzca su nombre." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Por favor, introduzca su nombre." + msgid "Please enter a password confirmation" msgstr "" @@ -1029,6 +1037,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Por favor, introduzca una dirección web válida." + msgid "Please enter the name of your organisation." msgstr "Por favor, introduzca el nombre de su entidad." @@ -1066,6 +1078,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organización" + msgid "Please select one" msgstr "" @@ -1173,6 +1189,10 @@ msgid "Save" msgstr "Guardar" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Guardar" + msgid "Saving..." msgstr "Guardando..." diff --git a/config/locale/fr/app.po b/config/locale/fr/app.po index d5ca2db..1bc520c 100644 --- a/config/locale/fr/app.po +++ b/config/locale/fr/app.po @@ -1014,6 +1014,14 @@ msgid "Plan was successfully updated." msgstr "" +#, fuzzy +msgid "Please enter a First name." +msgstr "Entrez votre prénom, svp." + +#, fuzzy +msgid "Please enter a Last name." +msgstr "Entrez votre prénom, svp." + msgid "Please enter a password confirmation" msgstr "" @@ -1026,6 +1034,10 @@ msgid "Please enter an email address" msgstr "" +#, fuzzy +msgid "Please enter an email address." +msgstr "Formation à la rédaction de documents scientifiques en anglais une adresse web valide." + msgid "Please enter the name of your organisation." msgstr "Veuillez saisir le nom de votre organisme.." @@ -1063,6 +1075,10 @@ msgid "Please only enter up to 165 characters, you have used" msgstr "" +#, fuzzy +msgid "Please select an organisation, or select Other." +msgstr "Organisation" + msgid "Please select one" msgstr "" @@ -1170,6 +1186,10 @@ msgid "Save" msgstr "Enregistrer" +#, fuzzy +msgid "Save Unsuccessful." +msgstr "Enregistrer" + msgid "Saving..." msgstr "Enregistrement en cours..." diff --git a/lib/assets/javascripts/admin.js b/lib/assets/javascripts/admin.js index 5c7636f..7b47b6b 100644 --- a/lib/assets/javascripts/admin.js +++ b/lib/assets/javascripts/admin.js @@ -153,7 +153,7 @@ e.preventDefault(); }); - //cancelling edit of an annotation + //cancelling addition of an annotation $(".cancel_add_annotations").click(function(e){ var q_id = $(this).prev(".question_id").val(); $('#add_annotations_block_'+ q_id).hide(); diff --git a/test/functional/registrations_controller_test.rb b/test/functional/registrations_controller_test.rb index 8976103..ef0079b 100644 --- a/test/functional/registrations_controller_test.rb +++ b/test/functional/registrations_controller_test.rb @@ -87,13 +87,13 @@ sign_in @user # Change name - put user_registration_path, {user: {email: @user.email, firstname: 'Testing', surname: 'UPDATE'}} + put user_registration_path, {user: {email: @user.email, firstname: 'Testing', surname: 'UPDATE', org_id: Org.first.id}} assert_equal _('Details successfully updated.'), flash[:notice] assert_response :redirect assert_redirected_to edit_user_registration_url # Change email but didn't provide password - put user_registration_path, {user: {email: 'something@else.org', firstname: @user.firstname, surname: @user.surname}} + put user_registration_path, {user: {email: 'something@else.org', firstname: @user.firstname, surname: @user.surname, org_id: Org.first.id}} assert_response :success assert_equal _('Please enter your password to change email address.'), flash[:notice]