diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 008e253..c952b33 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,11 +38,12 @@ def store_location # store last url - this is needed for post-login redirect to whatever the user last visited. - if (request.fullpath != "/users/sign_in" && \ - request.fullpath != "/users/sign_up" && \ - request.fullpath != "/users/password" && \ - request.fullpath != "/users/sign_up?nosplash=true" && \ - !request.xhr?) # don't store ajax calls + unless ["/users/sign_in", + "/users/sign_up", + "/users/password", + "/users/invitation/accept", + ].any? { |ur| request.fullpath.include?(ur) } \ + or request.xhr? # don't store ajax calls session[:previous_url] = request.fullpath end end diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 6c3e73e..27cca0d 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -110,6 +110,7 @@ @all_guidance_groups = @plan.get_guidance_group_options @selected_guidance_groups = @plan.guidance_groups.pluck(:id) + respond_to do |format| if @plan.save @@ -130,7 +131,24 @@ @plan = Plan.eager_load(params[:id]) authorize @plan @editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id)) + + # Get all Guidance Groups applicable for the plan and group them by org @all_guidance_groups = @plan.get_guidance_group_options + @all_ggs_grouped_by_org = @all_guidance_groups.sort.group_by(&:org) + + # Important ones come first on the page - we grab the user's org's GGs and "Organisation" org type GGs + @important_ggs = [] + @important_ggs << [current_user.org, @all_ggs_grouped_by_org.delete(current_user.org)] + @all_ggs_grouped_by_org.each do |org, ggs| + if org.organisation? + @important_ggs << [org,ggs] + @all_ggs_grouped_by_org.delete(org) + end + end + + # Sort the rest by org name for the accordion + @all_ggs_grouped_by_org = @all_ggs_grouped_by_org.sort_by {|org,gg| org.name} + @selected_guidance_groups = @plan.guidance_groups.pluck(:id) @based_on = @plan.base_template diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index d2419a8..5bbc856 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -3,6 +3,7 @@ after_action :verify_authorized def create + registered = true @role = Role.new(role_params) authorize @role access_level = params[:role][:access_level].to_i @@ -14,16 +15,17 @@ message = _('User added to project') user = User.find_by(email: params[:user]) if user.nil? + registered = false User.invite!(email: params[:user]) message = _('Invitation issued successfully.') user = User.find_by(email: params[:user]) end @role.user = user if @role.save - UserMailer.sharing_notification(@role, current_user).deliver + if registered then UserMailer.sharing_notification(@role, current_user).deliver_now end flash[:notice] = message else - flash[:notice] = generate_error_notice(@role, _('role')) + flash[:notice] = failed_create_error(@role, _('role')) end end else @@ -40,10 +42,10 @@ set_access_level(access_level) if @role.update_attributes(role_params) flash[:notice] = _('Sharing details successfully updated.') - UserMailer.permissions_change_notification(@role).deliver_now + UserMailer.permissions_change_notification(@role, current_user).deliver_now redirect_to controller: 'plans', action: 'share', id: @role.plan.id else - flash[:notice] = generate_error_notice(@role, _('role')) + flash[:notice] = failed_create_error(@role, _('role')) render action: "edit" end end @@ -55,7 +57,7 @@ plan = @role.plan @role.destroy flash[:notice] = _('Access removed') - UserMailer.project_access_removed_notification(user, plan).deliver_now + UserMailer.project_access_removed_notification(user, plan, current_user).deliver_now redirect_to controller: 'plans', action: 'share', id: @role.plan.id end @@ -83,4 +85,4 @@ end end -end \ No newline at end of file +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 44efc03..f679ba2 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -18,17 +18,19 @@ end end - def permissions_change_notification(role) + def permissions_change_notification(role, current_user) @role = role + @current_user = current_user FastGettext.with_locale FastGettext.default_locale do mail(to: @role.user.email, subject: "#{_('Changed permissions on a DMP in')} #{Rails.configuration.branding[:application][:name]}") end end - def project_access_removed_notification(user, plan) + def project_access_removed_notification(user, plan, current_user) @user = user @plan = plan + @current_user = current_user FastGettext.with_locale FastGettext.default_locale do mail(to: @user.email, subject: "#{_('Permissions removed on a DMP in')} #{Rails.configuration.branding[:application][:name]}") @@ -42,4 +44,4 @@ subject: "#{_('API rights in')} #{Rails.configuration.branding[:application][:name]}") end end -end \ No newline at end of file +end diff --git a/app/models/guidance.rb b/app/models/guidance.rb index dfec5dc..8ba321b 100644 --- a/app/models/guidance.rb +++ b/app/models/guidance.rb @@ -3,7 +3,7 @@ # This class keeps the information organisations enter to support users when answering questions. # It always belongs to a guidance group class and it can be linked directly to a question or through one or more themes # [+Created:+] 07/07/2014 -# [+Copyright:+] Digital Curation Centre and University of California Curation Center +# [+Copyright:+] Digital Curation Centre and California Digital Library diff --git a/app/views/devise/mailer/invitation_instructions.html.erb b/app/views/devise/mailer/invitation_instructions.html.erb index b3366dc..c7235c1 100644 --- a/app/views/devise/mailer/invitation_instructions.html.erb +++ b/app/views/devise/mailer/invitation_instructions.html.erb @@ -1,12 +1,8 @@ <% FastGettext.with_locale FastGettext.default_locale do %> -
<%= _("Hello") %> <%= @resource.email %>!
+<%= _("Hello") %> <%= @resource.email %>,
+<%= _("A colleague has invited you to contribute to their Data Management Plan at ") %> <%= link_to Rails.configuration.branding[:application][:name], root_url %>.
+<%= link_to _("Click here to accept the invitation"), accept_invitation_url(@resource, :invitation_token => @token) %> (<%= _("or copy") %> <%= accept_invitation_url(@resource, :invitation_token => @token) %> <%= _("into your browser") %>).
+<%= _("If you don't want to accept the invitation, please ignore this email.") %>
<%= _("Your account won't be created until you access the link above and set your password.") %>
<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _("A colleague has invited you to contribute to their Data Management Plan at ") %> <%= link_to Rails.configuration.branding[:application][:name], root_url %>
- -<%= link_to _("Click here to accept the invitation"), accept_invitation_url(@resource, :invitation_token => @token) %> (<%= _("or copy") %> <%= accept_invitation_url(@resource, :invitation_token => @token) %> <%= _("into your browser") %>).
- -
- <%= _("If you don't want to accept the invitation, please ignore this email.") %>
- <%= _("Your account won't be created until you access the link above and set your password.") %>
-
| + <% if groups && groups.size == 1 %> + <%= check_box_tag "guidance_group_ids[]", groups[0].id, @selected_guidance_groups.include?(groups[0].id) %> + <%= org.name %> + <% elsif groups %> + <%= org.name %> + <% groups.each do |group| %> + |
| + └─ <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %> + <%= group.name %> + |
| - <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %> - <%= group.name %> - | -
| + <% if groups && groups.size == 1 %> + <%= check_box_tag "guidance_group_ids[]", groups[0].id, @selected_guidance_groups.include?(groups[0].id) %> + <%= org.name %> + <% elsif groups %> + <%= org.name %> + <% groups.each do |group| %> + |
| + └─ <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %> + <%= group.name %> + |
<%= _('Hello ') %><%= @role.user.name %>
- - <% +<% access_level = "read-only" permissions = "This means you can read the plan and leave comments." if @role.editor? @@ -12,13 +10,9 @@ access_level = "co-owner" permissions = "This means you can write and edit the plan in a collaborative manner. You can also grant rights to other collaborators." end - %> +%> +<%= _('Hello ') %><%= @role.user.name %>,
+<%= _('Your permissions relating to ') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%= _(' have been changed by') %><%="#{@current_user.firstname} #{@current_user.surname}. " %><%= _('You now have ') %><%= access_level %><%= _(' access. ') %><%= permissions %>
+<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _('Your permissions relating to ') %>"<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: I18n.default_locale) %>"<%= _(' have changed. You now have ') %><%= access_level %><%= _(' access. ')%><%= permissions %>
- -
- <%=_('All the best,')%>
-
- <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
-
<%= _('Hello ') %><%= @user.email %>
+<%= _('Hello ') %><%= @user.email %>,
+<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= "#{@current_user.firstname} #{@current_user.surname}"%>.
+<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= @user.email %>.
- -
- <%=_('All the best,')%>
-
- <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
-
<%= _('Hello ') %><%= @role.user.name %>
+<% + access_level = "read-only" + permissions = "This means you can read the plan and leave comments." + if @role.editor? + access_level = "editor" + permissions = "This means you can write and edit the plan in a collaborative manner." + end + if @role.administrator? + access_level = "co-owner" + permissions = "This means you can write and edit the plan in a collaborative manner. You can also grant rights to other collaborators." + end +%> +<%= _('Hello ') %><%= @role.user.name %>,
+<%= _('A colleague has invited you to contribute to their Data Management Plan at ') %><%= link_to Rails.configuration.branding[:application][:name], root_url %>.
+<%= _('You have been given ') %><%= access_level %><%= _(' access to') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%=_(' by ')%><%= "#{@user.firstname} #{@user.surname}"%>.
+<%= link_to _('Click here'), url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' to accept the invitation, (or copy ') %><%= url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' into your browser)')%>
+<%= _('If you don\'t want to accept the invitation, please ignore this email.') %>
+<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _('A colleague has invited you to contribute to their Data Management Plan at ') %><%=Rails.configuration.branding[:application][:name]%>
- -<%= _('You have been given ') %><%= @access_level %><%= _(' access to') %>"<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%=_(' by ')%><%= @user.firstname %>.
- -<%= link_to _('Click here'), url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' to accept the invitation, (or copy ') %><%= url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' into your browser)')%> - -
<%= _('If you don\'t want to accept the invitation, please ignore this email.') %>
- -
- <%=_('All the best,')%>
-
- <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
-
Please note that your email address is used as your username. If you change this, remember to use your new email address on sign in.
" msgstr "Please note that your email address is used as your username. If you change this, remember to use your new email address on sign in.
" - msgid "Please select from the following drop-down so we can determine what questions and guidance should be displayed in your plan.
" msgstr "Please select from the following drop-down so we can determine what questions and guidance should be displayed in your plan.
" @@ -839,6 +843,9 @@ msgid "Original funder template has changed!" msgstr "Original funder template has changed!" +msgid "Other institutions" +msgstr "" + msgid "Otherwise leave blank." msgstr "Otherwise leave blank." @@ -1385,6 +1392,9 @@ msgid "You need to sign in or sign up before continuing." msgstr "You need to sign in or sign up before continuing." +msgid "You now have " +msgstr "" + msgid "Your" msgstr "Your" @@ -1451,6 +1461,9 @@ msgid "activerecord.errors.models.user.attributes.password.blank" msgstr "can't be blank" +msgid "activerecord.errors.models.user.attributes.password_confirmation.confirmation" +msgstr "passwords must match" + msgid "add guidance text" msgstr "add guidance text" diff --git a/config/locale/en_US/app.po b/config/locale/en_US/app.po index 99f6bcc..078709c 100644 --- a/config/locale/en_US/app.po +++ b/config/locale/en_US/app.po @@ -40,6 +40,10 @@ msgid " access to" msgstr " access to" +#, fuzzy +msgid " access. " +msgstr " access to" + msgid " by" msgstr " by" @@ -49,8 +53,9 @@ msgid " has been removed by " msgstr " has been removed by " -msgid " have changed. " -msgstr " have changed. " +#, fuzzy +msgid " have been changed by" +msgstr " by" msgid " into your browser)" msgstr " into your browser)." @@ -838,6 +843,9 @@ msgid "Original funder template has changed!" msgstr "Original funder template has changed!" +msgid "Other institutions" +msgstr "" + msgid "Otherwise leave blank." msgstr "Otherwise leave blank." @@ -1384,6 +1392,9 @@ msgid "You need to sign in or sign up before continuing." msgstr "You need to sign in or sign up before continuing." +msgid "You now have " +msgstr "" + msgid "Your" msgstr "Your" @@ -1450,6 +1461,9 @@ msgid "activerecord.errors.models.user.attributes.password.blank" msgstr "can't be blank" +msgid "activerecord.errors.models.user.attributes.password_confirmation.confirmation" +msgstr "passwords must match" + msgid "add guidance text" msgstr "add guidance text" diff --git a/config/locale/es/app.po b/config/locale/es/app.po index 514f582..debb763 100644 --- a/config/locale/es/app.po +++ b/config/locale/es/app.po @@ -42,6 +42,9 @@ msgid " access to" msgstr "" +msgid " access. " +msgstr "" + #, fuzzy msgid " by" msgstr " por " @@ -53,8 +56,9 @@ msgid " has been removed by " msgstr " por " -msgid " have changed. " -msgstr "" +#, fuzzy +msgid " have been changed by" +msgstr " por " msgid " into your browser)" msgstr "" @@ -861,6 +865,9 @@ msgid "Original funder template has changed!" msgstr "templates" +msgid "Other institutions" +msgstr "" + msgid "Otherwise leave blank." msgstr "Si no, déjelo en blanco." @@ -1418,6 +1425,9 @@ msgid "You need to sign in or sign up before continuing." msgstr "" +msgid "You now have " +msgstr "" + msgid "Your" msgstr "" @@ -1489,6 +1499,10 @@ msgid "activerecord.errors.models.user.attributes.password.blank" msgstr "user" +#, fuzzy +msgid "activerecord.errors.models.user.attributes.password_confirmation.confirmation" +msgstr "user" + msgid "add guidance text" msgstr "" diff --git a/config/locale/fr/app.po b/config/locale/fr/app.po index 24df940..c41d966 100644 --- a/config/locale/fr/app.po +++ b/config/locale/fr/app.po @@ -42,6 +42,9 @@ msgid " access to" msgstr "" +msgid " access. " +msgstr "" + #, fuzzy msgid " by" msgstr " par " @@ -53,8 +56,9 @@ msgid " has been removed by " msgstr " par " -msgid " have changed. " -msgstr "" +#, fuzzy +msgid " have been changed by" +msgstr " par " msgid " into your browser)" msgstr "" @@ -859,6 +863,9 @@ msgid "Original funder template has changed!" msgstr "templates" +msgid "Other institutions" +msgstr "" + msgid "Otherwise leave blank." msgstr "Sinon laissez ce champ vide." @@ -1415,6 +1422,9 @@ msgid "You need to sign in or sign up before continuing." msgstr "" +msgid "You now have " +msgstr "" + msgid "Your" msgstr "" @@ -1486,6 +1496,10 @@ msgid "activerecord.errors.models.user.attributes.password.blank" msgstr "user" +#, fuzzy +msgid "activerecord.errors.models.user.attributes.password_confirmation.confirmation" +msgstr "user" + msgid "add guidance text" msgstr "" diff --git a/config/locale/i18n_placeholders.rb b/config/locale/i18n_placeholders.rb index 532b25f..6b4d094 100644 --- a/config/locale/i18n_placeholders.rb +++ b/config/locale/i18n_placeholders.rb @@ -7,4 +7,6 @@ #msgstr "can't be blank" _("activerecord.errors.models.user.attributes.password.blank") #msgstr "can't be blank" +_("activerecord.errors.models.user.attributes.password_confirmation.confirmation") +#msgstr "passwords must match" diff --git a/lib/assets/javascripts/admin.js b/lib/assets/javascripts/admin.js index 62b2b77..5997e27 100644 --- a/lib/assets/javascripts/admin.js +++ b/lib/assets/javascripts/admin.js @@ -2,7 +2,7 @@ /* **Project: DMPRoadmap **Description: This file include all javascript regarding admin interface -**Copyright: Digital Curation Centre and University of California Curation Center +**Copyright: Digital Curation Centre and California Digital Library */