diff --git a/Gemfile.lock b/Gemfile.lock index 8067a42..51506da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,12 +265,6 @@ rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.3.0) - ransack (1.8.2) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) - i18n - polyamorous (~> 1.3) recaptcha (4.1.0) json redcarpet (3.3.4) @@ -407,4 +401,4 @@ ruby 2.2.2p95 BUNDLED WITH - 1.13.7 + 1.14.6 diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index ad95917..afe9711 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -102,7 +102,9 @@ @phase = Phase.eager_load(:sections).find_by('phases.id = ?', params[:id]) authorize @phase - @edit = params[:edit] == "true" ? true : false + @edit = (@phase.template.org == current_user.org) + #@edit = params[:edit] == "true" ? true : false + #verify if there are any sections if not create one @sections = @phase.sections if !@sections.any?() || @sections.count == 0 @@ -138,7 +140,7 @@ def admin_add @template = Template.find(params[:id]) @phase = Phase.new - phase.template = @template + @phase.template = @template authorize @phase @phase.number = @template.phases.count + 1 end diff --git a/app/controllers/sections_controller.rb b/app/controllers/sections_controller.rb index 9670c84..6df6210 100644 --- a/app/controllers/sections_controller.rb +++ b/app/controllers/sections_controller.rb @@ -8,9 +8,9 @@ authorize @section @section.description = params["section-desc"] @section.modifiable = true - @phase = section.phase + @phase = @section.phase if @section.save - redirect_to admin_show_phase_template_path(id: @section.phase_id, + redirect_to admin_show_phase_path(id: @section.phase_id, :section_id => @section.id, edit: 'true'), notice: _('Information was successfully created.') else render action: "phases/admin_show" diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 7d3cd05..4f5e453 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -168,7 +168,7 @@ new_version.published = false new_version.save! end - redirect_to admin_index_template_path(), notice: _('Information was successfully updated.') + redirect_to admin_template_template_path(), notice: _('Information was successfully updated.') else render action: "edit" end @@ -197,10 +197,6 @@ break random unless Template.exists?(dmptemplate_id: random) end authorize @template - - # Auto create a default phase - @template.phases << Phase.new({number: 1, title: "#{_('Phase')} 1", modifiable: true}) - if @template.save! redirect_to admin_template_template_path(@template), notice: _('Information was successfully created.') else diff --git a/app/views/phases/admin_add.html.erb b/app/views/phases/admin_add.html.erb index ce326b8..a5141aa 100644 --- a/app/views/phases/admin_add.html.erb +++ b/app/views/phases/admin_add.html.erb @@ -26,7 +26,7 @@
- <%= form_for :phase, url: { admin_create_phase_path} do |f| %> + <%= form_for :phase, {url: admin_create_phase_path} do |f| %>

<%= _('Phase details')%>

diff --git a/app/views/phases/admin_preview.html.erb b/app/views/phases/admin_preview.html.erb index 1f87258..59ce2d0 100644 --- a/app/views/phases/admin_preview.html.erb +++ b/app/views/phases/admin_preview.html.erb @@ -43,7 +43,7 @@ <% section.questions.order("number").each do |question| %> - <%= render partial: 'question/preview_question', locals: {question: question}%> + <%= render partial: 'questions/preview_question', locals: {question: question}%> <% if last_question_id == question.id then %>
<% else %> diff --git a/app/views/sections/_show_section.html.erb b/app/views/sections/_show_section.html.erb index 32bcdba..0573cb1 100644 --- a/app/views/sections/_show_section.html.erb +++ b/app/views/sections/_show_section.html.erb @@ -36,7 +36,7 @@ <% if section.phase.template.customization_of.present? %> <% end %>
diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb index 94e5feb..79b61df 100644 --- a/app/views/templates/_admin_nav_tabs.html.erb +++ b/app/views/templates/_admin_nav_tabs.html.erb @@ -19,7 +19,10 @@ <% end %> - <% if current_user.can_org_admin? && (template.org.funder? || current_user.org.funder?) %> + <% if current_user.can_org_admin? && + (template.org.funder? || + current_user.org.funder? || + (template.org == current_user.org)) %> <% if active == 'add_plan' %>
  • <% else %> diff --git a/app/views/templates/admin_template.html.erb b/app/views/templates/admin_template.html.erb index c515865..19ed6e1 100644 --- a/app/views/templates/admin_template.html.erb +++ b/app/views/templates/admin_template.html.erb @@ -19,7 +19,8 @@
    - <% if @hash[:template][:org].funder? || current_user.org.funder? %> + <% if @hash[:template][:org].funder? || current_user.org.funder? || + @hash[:template][:org] == current_user.org %>