diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 261c1dd..4f83340 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,5 +1,5 @@ # [+Project:+] DMPRoadmap -# [+Description:+] This controller is responsible for all the actions in the admin interface under templates (e.g. phases, versions, sections, questions, annotations) (index; show; create; edit; delete) +# [+Description:+] This controller is responsible for all the actions in the admin interface under templates (e.g. phases, versions, sections, questions, suggested answer) (index; show; create; edit; delete) # [+Copyright:+] Digital Curation Centre and University of California Curation Center class TemplatesController < ApplicationController @@ -106,12 +106,6 @@ @template.published = true @template.save - # Create a new version - new_version = Template.deep_copy(@template) - new_version.version = (@template.version + 1) - new_version.published = false - new_version.save - flash[:notice] = _('Your template has been published and is now available to users.') redirect_to admin_index_template_path(current_user.org) @@ -150,6 +144,16 @@ flash[:notice] = _('You are viewing a historical version of this template. You will not be able to make changes.') end + # If the template is published + if @template.published? + # We need to create a new, editable version + new_version = Template.deep_copy(@template) + new_version.version = (@template.version + 1) + new_version.published = false + new_version.save + @template = new_version + end + # once the correct template has been generated, we convert it to hash @hash = @template.to_hash end @@ -245,4 +249,4 @@ @current = Template.current(@template.dmptemplate_id) end -end \ No newline at end of file +end diff --git a/app/views/user_mailer/permissions_change_notification.html.erb b/app/views/user_mailer/permissions_change_notification.html.erb index 92eed7f..c2c0740 100644 --- a/app/views/user_mailer/permissions_change_notification.html.erb +++ b/app/views/user_mailer/permissions_change_notification.html.erb @@ -12,7 +12,7 @@ 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 %>
+<%= _('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.name(false)}. " %><%= _('You now have ') %><%= access_level %><%= _(' access. ') %><%= permissions %>
<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _('Hello ') %><%= @user.email %>,
-<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= "#{@current_user.firstname} #{@current_user.surname}"%>.
+<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= "#{@current_user.name(false)}"%>.
<%=_('All the best,')%>
<%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<%= _('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}"%>.
+<%= _('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.name(false)}" %>.
<%= 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')%>.