diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 7ad732e..57cbabc 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -3,6 +3,7 @@ # [+Copyright:+] Digital Curation Centre and University of California Curation Center class TemplatesController < ApplicationController + respond_to :html after_action :verify_authorized # GET /dmptemplates @@ -31,15 +32,13 @@ # PUT /dmptemplates/1 def admin_update - @dmptemplate = Dmptemplate.find(params[:id]) - authorize @dmptemplate - @dmptemplate.description = params["template-desc"] - respond_to do |format| - if @dmptemplate.update_attributes(params[:dmptemplate]) - format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') } - else - format.html { render action: "edit" } - end + @template = Template.find(params[:id]) + authorize @template + @template.description = params["template-desc"] + if @template.update_attributes(params[:template]) + redirect_to admin_template_template_path(params[:template]), notice: I18n.t('org_admin.templates.updated_message') + else + render action: "edit" end end diff --git a/app/views/templates/_edit_template.html.erb b/app/views/templates/_edit_template.html.erb index 051d4b4..10c33ea 100644 --- a/app/views/templates/_edit_template.html.erb +++ b/app/views/templates/_edit_template.html.erb @@ -20,7 +20,7 @@ <%= t('org_admin.templates.published_label') %> - <%if template.published? || template.has_published_versions? then%> + <%if template.published? then%> <%= f.check_box :published, as: :check_boxes %> <%else%> <%= t('org_admin.templates.cannot_publish')%> diff --git a/app/views/templates/_show_template.html.erb b/app/views/templates/_show_template.html.erb index 4165555..5763d33 100644 --- a/app/views/templates/_show_template.html.erb +++ b/app/views/templates/_show_template.html.erb @@ -1,6 +1,6 @@ -<% if template.org.funder? || current_user.org.funder? then %> +<% if template.org.not_funder? || current_user.org.funder? then %>

<%= link_to t("org_admin.templates.edit_details"), '# ', class: "btn btn-primary", id: "edit_template_button"%>