diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 103341a..ba7b816 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -61,7 +61,7 @@ @guidance_groups = get_available_guidance @always_guidance = get_always_available_guidance @institutions = orgs_of_type(constant("organisation_types.institution")) - + respond_to do |format| format.html # new.html.erb end diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 9c7f757..075371b 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -2,19 +2,16 @@ # [+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 DmptemplatesController < ApplicationController +class TemplatesController < ApplicationController after_action :verify_authorized # GET /dmptemplates def admin_index - authorize Dmptemplate + authorize Template #institutional templates - @dmptemplates_own = Dmptemplate.own_institutional_templates(current_user.organisation_id) + @dmptemplates_own = Template.own_institutional_templates(current_user.org_id) #funders templates - @dmptemplates_funders = Dmptemplate.funders_templates - respond_to do |format| - format.html # index.html.erb - end + @dmptemplates_funders = Template.funders_templates end # GET /dmptemplates/1 diff --git a/app/models/template.rb b/app/models/template.rb index 02f9442..1ddcb9d 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -110,7 +110,7 @@ # # @return [string] the string name of an organisation type def org_type - org_type = organisation.organisation_type.name + org_type = org.organisation_type return org_type end @@ -121,18 +121,23 @@ # @param temp [dmptemplate] a template object # @return [Boolean] true if temp has customisation by the given organisation def has_customisations?(org_id, temp) - if temp.organisation_id != org_id then - temp.phases.each do |phase| - phase.versions.each do |version| - version.sections.each do |section| - return true if section.organisation_id == org_id - end - end - return false - end - else - return false + modifiable = true + phases.each do |phase| + modifiable = modifable && phase.modifiable end + return !modifiable + # if temp.org_id != org_id then + # temp.phases.each do |phase| + # phase.versions.each do |version| + # version.sections.each do |section| + # return true if section.organisation_id == org_id + # end + # end + # return false + # end + # else + # return false + # end end ## diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index 1587ad4..671ab79 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -9,12 +9,12 @@ <% if (user_signed_in? && current_user.can_org_admin? && ( action_name.include? "admin_" ) ) %> <% if current_user.can_modify_templates? %> - <% if namespace == "dmptemplates" then %> + <% if namespace == "templates" then %>
  • <% else %>
  • <% end %> - <%= link_to t("org_admin.template_label"), admin_index_dmptemplate_path(current_user.org_id) %> + <%= link_to t("org_admin.template_label"), admin_index_template_path(current_user.org_id) %>
  • <% end %> <% if current_user.can_modify_guidance? %> @@ -41,7 +41,7 @@ <% else %>
  • <% end %> - <%= link_to t("org_admin.user_list_label"), "/org/admin/users/admin_index", :class => "main_nav_last_li"%> + <%= link_to t("org_admin.user_list_label"), "/org/admin/users/admin_index", class: "main_nav_last_li"%>
  • <% end %> <% else %> @@ -115,6 +115,6 @@ <% end %> - <%end%> + <% end %> diff --git a/app/views/layouts/_signin_signout.html.erb b/app/views/layouts/_signin_signout.html.erb index d8ac13d..0ee3fa5 100644 --- a/app/views/layouts/_signin_signout.html.erb +++ b/app/views/layouts/_signin_signout.html.erb @@ -1,31 +1,31 @@
    + + <% end %> +
    \ No newline at end of file diff --git a/app/views/templates/admin_index.html.erb b/app/views/templates/admin_index.html.erb index b22018c..9af877a 100644 --- a/app/views/templates/admin_index.html.erb +++ b/app/views/templates/admin_index.html.erb @@ -15,7 +15,7 @@
    <%= link_to t("org_admin.templates.create_template"), - admin_new_dmptemplate_path, + admin_new_template_path, :class => 'btn btn-primary' %>
    @@ -47,25 +47,21 @@ <%= org_template.published %> - <% last_temp_updated = org_template.updated_at %> - <% org_template.phases.each do |phase|%> - <% if phase.versions.any? then%> - <% phase.versions.each do |version| %> - <% if org_template.updated_at.to_date < version.updated_at.to_date then %> - <% last_temp_updated = version.updated_at %> - <%end%> - <%end%> - <%end%> - <%end%> - <%= l last_temp_updated.to_date, :formats => :short %> - + <% last_temp_updated = org_template.updated_at %> + <% org_template.phases.each do |phase|%> + <% if org_template.updated_at.to_date < phase.updated_at.to_date then %> + <% last_temp_updated = phase.updated_at %> + <% end %> + <% end %> + <%= l last_temp_updated.to_date, :formats => :short %> + <%if current_user.can_org_admin? then%> <% b_label = t('helpers.submit.edit')%> <%else%> <% b_label = t('helpers.view')%> <%end%> - <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> + <%= link_to b_label, admin_template_template_path(org_template), :class => "dmp_table_link"%> <%end%> @@ -78,7 +74,7 @@
    -<% if current_user.org_type != constant("organisation_types.funder") then %> +<% if !current_user.org.funder? then %>

    <%= t("org_admin.templates.funders_temp") %>

    @@ -131,7 +127,7 @@ <%if current_user.can_org_admin? then%> <% if org_template.org_type == constant("organisation_types.funder") then %> - <%if org_template.has_customisations?(current_user.organisation_id, org_template) then%> + <%if org_template.has_customisations?(current_user.org_id, org_template) then%> <% b_label = t("org_admin.templates.edit_customisation")%> <%else%> <% b_label = t("org_admin.templates.customise")%> @@ -142,7 +138,7 @@ <%else%> <% b_label = t("helpers.view")%> <%end%> - <%= link_to b_label, admin_template_dmptemplate_path(org_template), :class => "dmp_table_link"%> + <%= link_to b_label, admin_template_template_path(org_template), :class => "dmp_table_link"%> <%end%> diff --git a/config/routes.rb b/config/routes.rb index a11677a..97252d6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,7 +79,7 @@ end end - resources :dmptemplates, :path => 'org/admin/templates', only: [] do + resources :templates, :path => 'org/admin/templates', only: [] do member do get 'admin_index' get 'admin_template'