diff --git a/Gemfile b/Gemfile index c95209d..53d9493 100644 --- a/Gemfile +++ b/Gemfile @@ -73,8 +73,6 @@ gem 'wicked_pdf' gem 'htmltoword' gem 'feedjira' -gem 'caracal' # WORD DOC EXPORTING -gem 'caracal-rails' gem 'yaml_db', :git => 'https://github.com/vyruss/yaml_db.git' # ------------------------------------------------ diff --git a/Gemfile.lock b/Gemfile.lock index 38f77ae..37b6745 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,13 +86,6 @@ rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - caracal (1.0.8) - nokogiri (~> 1.6) - rubyzip (~> 1.1) - tilt (>= 1.4) - caracal-rails (1.0.1) - caracal (~> 1.0) - rails (>= 3.2) coderay (1.1.1) commonjs (0.2.7) concurrent-ruby (1.0.2) @@ -367,8 +360,6 @@ better_errors binding_of_caller byebug - caracal - caracal-rails contact_us (>= 1.2.0) devise devise_invitable diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index 9f9163d..de50db4 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -38,7 +38,7 @@ # # get the ids of the dynamically selected guidance groups # and keep a map of them so we can extract the names later - guidance_groups_ids = @plan.plan_guidance_groups.select{|pgg| pgg.selected}.map{|pgg| pgg.guidance_group.id} + guidance_groups_ids = @plan.plan_guidance_groups.map{|pgg| pgg.guidance_group.id} guidance_groups = GuidanceGroup.includes({guidances: :themes}).find(guidance_groups_ids) # create a map from theme to array of guidances diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 1408264..e0f6648 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -21,45 +21,65 @@ authorize @plan @funders = Org.funders.all + no_org = Org.new() + no_org.id = -1 + no_org.name = "No Funder" + @funders.unshift(no_org) + + respond_to do |format| format.html # new.html.erb end end + # we get here either from selecting a funder or if if the first selection + # results in multiple templates, from a template selection screen def create @plan = Plan.new authorize @plan @plan.save + message = "" + + # if we have a template_id we've been selcting between templates, otherwise funders if params[:template_id] @templates = [ Template.find(params[:template_id] ) ] else + funder_id = params[:plan][:funder_id].to_i - funder_id = params[:plan][:funder_id] - if !funder_id.blank? + if funder_id.present? && funder_id != -1 + @templates = [] + # get all funder @templates funder = Org.find(params[:plan][:funder_id]) - @templates = get_most_recent( funder.templates.where("published = ?", true).all ) + funder_templates = get_most_recent( funder.templates.where(published: true).all ) - orgtemplates = current_user.org.templates.all - replacements = [] + # get org templates and index by customization id + orgtemplates = get_most_recent( current_user.org.templates.all ) - # replace any that are customised by the org - orgtemplates.each do |orgt| - base_template = orgt.customization_of - @templates.delete(base_template) - replacements << orgt + orgt_by_customization = orgtemplates.collect{|t| [t.customization_of, t]}.to_h + + # go through funder templates and replace with org cusomizations if needed + funder_templates.each do |ft| + if orgt_by_customization.has_key?(ft.dmptemplate_id) + message = _(" - using template customised by your institution") + @templates << orgt_by_customization[ft.dmptemplate_id] + else + @templates << ft + end end - @templates + replacements + else # either didn't select funder or selected "No Funder" - else # get all org @templates which are not customisations - @templates = current_user.org.templates.where(customization_of: nil) + @templates = get_most_recent( current_user.org.templates.where(customization_of: nil) ) - # if none of these get the basic dcc template + message = _(" - choosing default template for your institution") + + # if none of these get the default template if @templates.blank? - @templates = Template.find_by_is_default(true) + @templates = get_most_recent( Template.where(is_default: true, customization_of: nil) ) + message = _(" - no funder or institution template, choosing default template") end end end @@ -69,25 +89,31 @@ # to choose otherwise just create the plan # and go to the plan/show template if @templates.length > 1 + message += _(" - there are more than one to choose from") + flash.notice = message + respond_to do |format| + format.html + end return end @plan.template = @templates[0] + @based_on = @plan.base_template() + @plan.principal_investigator = current_user.name @plan.title = _('My plan')+' ('+@plan.template.title+')' # We should use interpolated string since the order of the words from this message could vary among languages @plan.assign_creator(current_user.id) - @plan.set_possible_guidance_groups + @all_guidance_groups = @plan.get_guidance_group_options + @selected_guidance_groups = @plan.guidance_groups.pluck(:id) - @selected_guidance_groups = @plan.guidance_groups.map{ |pgg| [pgg.name, pgg.id, :checked => false] } - @selected_guidance_groups.sort! - respond_to do |format| if @plan.save - format.html { redirect_to({:action => "show", :id => @plan.id, :editing => true }, {:notice => _('Plan was successfully created.')}) } + flash.notice = _('Plan was successfully created.') + message + format.html { redirect_to({:action => "show", :id => @plan.id, :editing => true }) } else flash[:notice] = failed_create_error(@plan, _('plan')) format.html { render action: "new" } @@ -102,10 +128,10 @@ @plan = Plan.eager_load(params[:id]) authorize @plan @editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id)) - @selected_guidance_groups = [] - all_guidance_groups = @plan.plan_guidance_groups - @selected_guidance_groups = all_guidance_groups.map{ |pgg| [ pgg.guidance_group.name, pgg.guidance_group.id, :checked => pgg.selected ] } - @selected_guidance_groups.sort! + @all_guidance_groups = @plan.get_guidance_group_options + @selected_guidance_groups = @plan.plan_guidance_groups.pluck(:guidance_group_id) + @based_on = @plan.base_template + respond_to :html end @@ -152,24 +178,30 @@ def update_guidance_choices @plan = Plan.find(params[:id]) authorize @plan - guidance_ids = params[:plan][:plan_guidance_group_ids] - -# TODO: This always appears to be empty for a new plan. What SHOULD it contain, all guidance_groups? - @plan.plan_guidance_groups.each do |pgg| - pgg.selected = guidance_ids.include?(pgg.guidance_group_id.to_s) - pgg.save! + guidance_group_ids = params[:guidance_group_ids].blank? ? [] : params[:guidance_group_ids].map(&:to_i) + all_guidance_groups = @plan.get_guidance_group_options + plan_groups = @plan.guidance_groups + guidance_groups = GuidanceGroup.where( id: guidance_group_ids) + all_guidance_groups.each do |group| + # case where plan group exists but not in selection + if plan_groups.include?(group) && ! guidance_groups.include?(group) + # remove from plan groups + @plan.guidance_groups.delete(group) + end + # case where plan group dosent exist and in selection + if !plan_groups.include?(group) && guidance_groups.include?(group) + # add to plan groups + @plan.guidance_groups << group + end end - @plan.save! - - respond_to do |format| - format.json { head :no_content } - end + @plan.save + redirect_to action: "show" end def share @plan = Plan.find(params[:id]) authorize @plan - @plan_data = @plan.to_hash + #@plan_data = @plan.to_hash end @@ -308,6 +340,8 @@ render 'show_export' end + + def export @plan = Plan.find(params[:id]) authorize @plan @@ -317,6 +351,7 @@ @exported_plan = ExportedPlan.new.tap do |ep| ep.plan = @plan + ep.phase_id = params[:phase_id] ep.user = current_user ep.format = params[:format].to_sym plan_settings = @plan.settings(:export) @@ -328,7 +363,7 @@ begin @exported_plan.save! - file_name = @exported_plan.project_name + file_name = @plan.title.gsub(/ /, "_") respond_to do |format| format.html @@ -358,12 +393,15 @@ private + # different versions of the same template have the same dmptemplate_id + # but different version numbers so for each set of templates with the + # same dmptemplate_id choose the highest version number. def get_most_recent( templates ) groups = Hash.new templates.each do |t| k = t.dmptemplate_id if !groups.has_key?(k) - groups[k] =t + groups[k] = t else other = groups[k] if other.version < t.version diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 7177155..14549b7 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -17,7 +17,7 @@ end @role.user = user if @role.save - UserMailer.sharing_notification(@role).deliver_now + UserMailer.sharing_notification(@role, current_user).deliver flash[:notice] = message else flash[:notice] = generate_error_notice(@role, _('role')) @@ -64,12 +64,18 @@ def set_access_level(access_level) if access_level >= 1 @role.commenter = true + else + @role.commenter = false end if access_level >= 2 @role.editor = true + else + @role.editor = false end if access_level >= 3 @role.administrator = true + else + @role.administrator = false end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ce0d122..57b504f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -47,7 +47,7 @@ end end end - + if @user.save! redirect_to({controller: 'users', action: 'admin_index'}, {notice: _('Information was successfully updated.')}) # helpers.success key does not exist, replaced with a generic string else diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index d7339b5..687d2b9 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -45,7 +45,6 @@ invitation_sent_at: Field::DateTime, invitation_accepted_at: Field::DateTime, other_organisation: Field::String, - dmponline3: Field::Boolean, accept_terms: Field::Boolean, api_token: Field::String, }.freeze @@ -104,7 +103,6 @@ :invitation_sent_at, :invitation_accepted_at, :other_organisation, - :dmponline3, :accept_terms, :api_token, ].freeze @@ -131,25 +129,24 @@ :orcid_id, :shibboleth_id, # :encrypted_password, - :reset_password_token, - :reset_password_sent_at, - :remember_created_at, - :sign_in_count, - :current_sign_in_at, - :last_sign_in_at, - :current_sign_in_ip, - :last_sign_in_ip, - :confirmation_token, - :confirmed_at, - :confirmation_sent_at, - :invitation_token, - :invitation_created_at, - :invitation_sent_at, - :invitation_accepted_at, - :other_organisation, - :dmponline3, +# :reset_password_token, +# :reset_password_sent_at, +# :remember_created_at, +# :sign_in_count, +# :current_sign_in_at, +# :last_sign_in_at, +# :current_sign_in_ip, +# :last_sign_in_ip, +# :confirmation_token, +# :confirmed_at, +# :confirmation_sent_at, +# :invitation_token, +# :invitation_created_at, +# :invitation_sent_at, +# :invitation_accepted_at, +# :other_organisation, :accept_terms, - :api_token, +# :api_token, ].freeze # Overwrite this method to customize how users are displayed @@ -160,7 +157,7 @@ # end def display_resource(user) - "user.name (##{user.id})" + "#{user.firstname} #{user.surname} (##{user.id})" end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 634aea8..681679b 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,7 +1,7 @@ class UserMailer < ActionMailer::Base default from: Rails.configuration.branding[:organisation][:email] - def sharing_notification(role) + def sharing_notification(role, user) @role = role FastGettext.with_locale FastGettext.default_locale do mail(to: @role.user.email, diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index 0e44f19..9fdbf97 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -79,22 +79,13 @@ end end -# TODO: This looks like it will always return an empty array as questions is undefined - # sections taken from fields settings def sections - # TODO: How do we know which phase to use here!? - sections = self.plan.template.phases.first.sections - - return [] if questions.empty? - - section_ids = questions.pluck(:section_id).uniq - sections = sections.select {|section| section_ids.member?(section.id) } - + sections = Phase.find(self.phase_id).sections sections.sort_by(&:number) end def questions_for_section(section_id) - questions.where(section_id: section_id) + questions.where(section_id: section_id).sort_by(&:number) end def admin_details diff --git a/app/models/plan.rb b/app/models/plan.rb index 30ce215..6718a3b 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -85,6 +85,17 @@ + def base_template + base = nil + t = self.template + if t.customization_of.present? + base = Template.where("dmptemplate_id = ? and created_at < ?", t.customization_of, self.created_at).order(version: :desc).first + end + return base + end + + + ## # returns the most recent answer to the given question id # optionally can create an answer if none exists @@ -136,10 +147,33 @@ self.guidance_groups = ggroups.uniq end - - - ## + # returns all of the possible guidance groups for the plan (all options to + # be selected by the user to display) + # + # @return Array + def get_guidance_group_options + # find all the themes in this plan + # and get the guidance groups they belong to + ggroups = [] + self.template.phases.each do |phase| + phase.sections.each do |section| + section.questions.each do |question| + question.themes.each do |theme| + theme.guidances.each do |guidance| + ggroups << guidance.guidance_group + end + end + end + end + end + return ggroups.uniq! + end + + + + + ## # returns the guidances associated with the project's organisation, for a specified question # # @param question [Question] the question to find guidance for @@ -174,7 +208,7 @@ end # Get guidance by theme from any guidance groups currently selected - self.plan_guidance_groups.where(selected: true).each do |pgg| + self.plan_guidance_groups.each do |pgg| group = pgg.guidance_group group.guidances.each do |guidance| common_themes = guidance.themes.all & question.themes.all @@ -187,6 +221,9 @@ return guidances end + + + ## # adds the given guidance to a hash indexed by a passed guidance group and theme # @@ -909,98 +946,6 @@ - ## - # - # The following method is to help optimise data access. - # Even using includes or joins the data access gets performed lazily - # and the caching appears to be forgotten at times over view/partial boundaries - # To get round it we can pull everything out into a hash and use that - # which guarantees no further DB accesses. - # - # The serializable_hash method only pulls in one level but this includes - # attributes which are "through" other attributes. So we do a basic - # conversion to hash and then a "fixup" which knits the pieces together into - # the structure which we really want. - # - def to_hash - plan_data = self.serializable_hash( - include: [ :template, :phases, :sections, - :answers, :notes, :roles, :users, :questions, - :plan_guidance_groups, :guidance_groups] - ) - - # serializable_hash only works over one level so we still need to go and extract - # the deeper levels and knit them in. - # - # want hash of questions by id to add in suggested answers and question_formats - question_hash = {} - - plan_data["questions"].each do |q| - question_hash[q["id"]] = q - end - - question_ids = question_hash.keys - - # pull out suggested answers - suggested_answers = SuggestedAnswer.where(question_id: question_ids).where.not(text: '') - suggested_answers.each do |sa| - question_hash[sa.question_id]["suggested_answer"] = sa.serializable_hash - end - - # pull out question_formats - qf_hash = {} - QuestionFormat.all.each do |qf| - qf_hash[qf.id] = qf.serializable_hash - end - # add question _formats to questions - question_hash.values.each do |q| - q["question_format"] = qf_hash[q["question_format_id"]] - end - - # get the ids of the dynamically selected guidance groups - # and keep a map of them so we can extract the name later - gg_ids = plan_data["plan_guidance_groups"].select{|pgg| pgg["selected"]}.map{|pgg| pgg["guidance_group_id"]} - gg_hash = {} - ggs = GuidanceGroup.find(gg_ids).each do |gg| - gg_hash[gg.id] = gg.serializable_hash - end - - # create a map from theme to array of guidances - theme_guidance = {} - guidances = Guidance.joins(:themes) - .select('guidances.guidance_group_id, guidances.text, themes.title') - .where(guidance_group: gg_ids) - .to_a - - guidances.each do |g| - title = g.title - if !theme_guidance.has_key?(title) - theme_guidance[title] = Array.new - end - theme_guidance[title] << { - "text" => g.text, - "org" => gg_hash[g.guidance_group_id]["name"] - } - end - - # link the guidance to the questions - plan_data["questions"].each do |q| - qg = {} - if q.has_key?("themes") - q["themes"].each do |t| - title = t["title"] - qg[title] = theme_guidance[title] if theme_guidance.has_key?(title) - end - q["theme_guidance"] = qg - end - end - - fixup_hash(plan_data) - - return plan_data - end - - # the following two methods are for eager loading. One gets used for the plan/show # page and the oter for the plan/edit. The difference is just that one pulls in more than # the other. @@ -1033,87 +978,6 @@ private - # reconnect the various parts of the hash so that: - # plan = { - # template: - # phases: - # sections: - # questions: - # answers - # } - # - # becomes a nested structure like so - # - # plan = { template: { - # phases: [ { - # sections: [ { - # questions: [ { - # answers: [...] - # - def fixup_hash(plan) - # sort out guidance first so we can add it to the questions - # before rolling up - # - ghash = {} - plan["guidance_groups"].map{|g| ghash[g["id"]] = g} - plan["plan_guidance_groups"].each do |pgg| - pgg["guidance_group"] = ghash[ pgg["guidance_group_id"] ] - end - - rollup(plan, "notes", "answer_id", "answers") - rollup(plan, "answers", "question_id", "questions") - rollup(plan, "questions", "section_id", "sections", true) - rollup(plan, "sections", "phase_id", "phases", true) - - plan["template"]["phases"] = plan.delete("phases") - plan["template"]["phases"].sort! { |x,y| x["number"].to_i <=> y["number"].to_i } - - plan["template"]["org"] = Org.find(plan["template"]["org_id"]).serializable_hash() - - # when editing phases we want the number of questions answered - # so calculate that now - plan["template"]["phases"].each do |phase| - phase["sections"].each do |section| - nanswers = 0 - section["questions"].each do |question| - if question.has_key?("answers") && question["answers"].first["text"].present? - nanswers += 1 - end - end - section["nanswers"] = nanswers - end - end - end - - - # find all object under src_plan_key - # merge them into the items under obj_plan_key using - # super_id = id - # so we have answers which each have a question_id - # rollup(plan, "answers", "quesiton_id", "questions") - # will put the answers into the right questions. - # sort determines whether the items being rolled up should be sorted by number field - def rollup(plan, src_plan_key, super_id, obj_plan_key, sort = false) - id_to_obj = Hash.new() - plan[src_plan_key].each do |o| - id = o[super_id] - if !id_to_obj.has_key?(id) - id_to_obj[id] = Array.new - end - id_to_obj[id] << o - end - - plan[obj_plan_key].each do |o| - id = o["id"] - if id_to_obj.has_key?(id) - if sort - id_to_obj[ id ].sort! { |x,y| x["number"].to_i <=> y["number"].to_i } - end - o[src_plan_key] = id_to_obj[ id ] - end - end - plan.delete(src_plan_key) - end ## # adds a user to the project @@ -1137,9 +1001,25 @@ role.user_id = user_id role.plan_id = id - role.creator= is_creator - role.editor= is_editor - role.administrator= is_administrator + # if you get assigned a role you can comment + role.commenter= true + + # the rest of the roles are inclusing so creator => administrator => editor + if is_creator + role.creator = true + role.administrator = true + role.editor = true + end + + if is_administrator + role.administrator = true + role.editor = true + end + + if is_editor + role.editor = true + end + role.save # This is necessary because we're creating the associated record but not assigning it diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb index 38193da..e14ec26 100644 --- a/app/views/phases/_answer_form.html.erb +++ b/app/views/phases/_answer_form.html.erb @@ -69,7 +69,7 @@
    <% options.each do |op| %>
  1. - <% if answer.option_ids[0] == op.id then%> + <% if answer.question_option_ids[0] == op.id then%> <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> <%else%> <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index f1fc89a..f91d5f7 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -21,7 +21,7 @@
    - <% @phase.sections.each do |section| %> + <% @phase.sections.order(:number).each do |section| %> <% sectionid = section.id %> diff --git a/app/views/plans/_dropdowns_new_plan.html.erb b/app/views/plans/_dropdowns_new_plan.html.erb index 1fb8708..c7e9d7e 100644 --- a/app/views/plans/_dropdowns_new_plan.html.erb +++ b/app/views/plans/_dropdowns_new_plan.html.erb @@ -1,13 +1,13 @@ -<%= semantic_form_for @plan, :url => {:controller => :plans, :action => :create }, :html=>{:method=>:post} do |f| %> +<%= semantic_form_for @plan, url: plans_path(@plan) do |f| %> <%= f.inputs do %> <%= hidden_field_tag :default_tag, "false" ,:id => "default_tag" %>

    <%= _('Create a new plan') %>

    -

    <%= raw _("

    Please select from the following drop-downs so we can determine what questions and guidance should be displayed in your plan.

    If you aren't responding to specific requirements from a funder or an institution, select here to write a generic DMP based on the most common themes.

    ")%>

    +

    <%= raw _("

    Please select from the following drop-down so we can determine what questions and guidance should be displayed in your plan.

    ")%>

    @@ -19,7 +19,7 @@ <%= f.input :funder_id, :as => :select, :collection => @funders, - :label => _('If applying for funding, select your research funder.'), + :label => _('Select your research funder or no funder, as appropariate.'), :input_html => { :multiple => false, :class => ["select2", "select2-container"] }, :include_blank => _('Select Funder') %> diff --git a/app/views/plans/_plan_details.html.erb b/app/views/plans/_plan_details.html.erb index 309d29a..b18eb89 100644 --- a/app/views/plans/_plan_details.html.erb +++ b/app/views/plans/_plan_details.html.erb @@ -173,20 +173,22 @@
    - <%= semantic_form_for @plan, :url => {:controller => :plans, :action => :update_guidance_choices }, :html=>{:method=>:put}, :remote => true do |f| %> - <%= f.inputs do %> - <%= f.input :plan_guidance_groups, - :as => :check_boxes, - :collection => selected_guidance_groups %> - <% end %> - - <%= f.actions do %> -
    - <%= f.submit _('Save'), :class => 'btn btn-primary' %> - <%= _('helpers.links.cancel') %> -
    - <%end%> - <%end%> + <%= form_tag( update_guidance_choices_plan_path(@plan), method: :put) do %> + + + <% @all_guidance_groups.each do |group| %> + + + + <% end %> + + +
    + <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %> + <%= group.name %> +
    + <%= submit_tag _('Save'), class: "btn btn-primary"%> + <% end %>
    @@ -204,9 +206,9 @@ <%= plan.template.org.name %> <%end%> - <%if plan.template.customization_of.present? %> - <% ctemplate = Template.find(plan.template.customization_of) %> - <%= " (#{_(Customised from)} " + ctemplate.org.name + ")" %> + + <%if based_on.present? %> + <%= " (#{_('Customised from')} " + based_on.org.name + ")" %> <%end%> diff --git a/app/views/plans/export.docx.erb b/app/views/plans/export.docx.erb new file mode 100644 index 0000000..db005f6 --- /dev/null +++ b/app/views/plans/export.docx.erb @@ -0,0 +1,44 @@ +

    <%= @exported_plan.title %>

    +

    <%= @plan.template.title %>

    + +<% details = @exported_plan.admin_details %> +<% if details.present? %> +

    <%= _('Admin Details') %>

    + <% details.each do |field| %> + <% value = @exported_plan.send(field) %> +

    + <%= admin_field_t(field.to_s) %>: + <%= value.present? ? value : _('-') %> +

    + <% end %> +<% end %> + + + +<% @exported_plan.sections.each do |section| %> +

    <%= section.title %>

    + <% questions = @exported_plan.questions_for_section(section.id) %> + <% questions.each do |question| %> +

    <%= raw question.text %>

    + + <% answer = @plan.answer(question.id, false) %> + <% if answer.nil? then %> +

    <%= _('Question not answered') %>

    + <% else %> + <% q_format = question.question_format %> + <% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || + q_format.title == _('Radio buttons') || q_format.title == _('Dropdown') %> +
      + <% answer.question_options.each do |option| %> +
    • <%= raw option.text %>
    • + <% end %> +
    + <% if question.option_comment_display %> + <%= raw answer.text %> + <% end %> + <%else%> + <%= raw answer.text %> + <%end%> + <% end %> + <% end %> +<% end %> diff --git a/app/views/plans/share.html.erb b/app/views/plans/share.html.erb index e4a597f..bf8837b 100644 --- a/app/views/plans/share.html.erb +++ b/app/views/plans/share.html.erb @@ -5,6 +5,7 @@ <%= render :partial => "plan_nav_tabs", locals: {plan: @plan, plan_data: @plan_data, active: "share"} %> +
    diff --git a/app/views/plans/show.html.erb b/app/views/plans/show.html.erb index ea6bcbe..61c37e8 100644 --- a/app/views/plans/show.html.erb +++ b/app/views/plans/show.html.erb @@ -7,4 +7,4 @@ <%= render :partial => "plan_nav_tabs", locals: {plan: @plan, active: "details"} %> -<%= render :partial => "plan_details", locals: {plan: @plan, selected_guidance_groups: @selected_guidance_groups} %> +<%= render :partial => "plan_details", locals: {plan: @plan, based_on: @based_on, selected_guidance_groups: @selected_guidance_groups} %> diff --git a/app/views/shared/_export_links.html.erb b/app/views/shared/_export_links.html.erb index 6898a04..6ce39cd 100644 --- a/app/views/shared/_export_links.html.erb +++ b/app/views/shared/_export_links.html.erb @@ -1,5 +1,6 @@ <% javascript("export_configure") %>
    + <%= label_tag(:format, _('format')) %> <%= select_tag(:format, options_for_select(ExportedPlan::VALID_FORMATS, :pdf), class: 'export-format-selection') %> diff --git a/app/views/user_mailer/sharing_notification.html.erb b/app/views/user_mailer/sharing_notification.html.erb index 296d6b2..befc872 100644 --- a/app/views/user_mailer/sharing_notification.html.erb +++ b/app/views/user_mailer/sharing_notification.html.erb @@ -1,5 +1,5 @@ <% FastGettext.with_locale FastGettext.default_locale do %> -

    <%= _('Hello') %> <%= @role.user.name %>

    +

    <%= _('Hello ') %> <%= @role.user.name %>

    <% access_level = "read-only" @@ -10,5 +10,9 @@ end %> -

    <%= _('You have been given') %> <%= access_level %> <%= _(' access to') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: I18n.default_locale) %>".

    -<% end %> +

    <%= _('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 %>.

    + +

    <%=_('Please follow the link above to login to ')%><%=Rails.configuration.branding[:application][:name]%><%=_(' to view/edit the plan')%>.

    +

    <%=_('Thanks')%>

    +

    <%=Rails.configuration.branding[:application][:name]%> <%=_(' team')%>

    +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5242472..2f0a5ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,9 @@ Rails.application.routes.draw do namespace :admin do - resources :users - resources :orgs - resources :perms + resources :users, only: [:new, :create, :edit, :update, :index, :show] + resources :orgs, only: [:new, :create, :edit, :update, :index, :show] + resources :perms, only: [:new, :create, :edit, :update, :index, :show] resources :languages resources :templates resources :token_permission_types diff --git a/db/migrate/20170412143945_add_phase_id_to_exported_plan.rb b/db/migrate/20170412143945_add_phase_id_to_exported_plan.rb new file mode 100644 index 0000000..01df115 --- /dev/null +++ b/db/migrate/20170412143945_add_phase_id_to_exported_plan.rb @@ -0,0 +1,9 @@ +class AddPhaseIdToExportedPlan < ActiveRecord::Migration + def up + add_column :exported_plans, :phase_id, :integer + end + + def down + remove_column :exported_plans, :phase_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 7161ae7..cbe7b61 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170303220255) do +ActiveRecord::Schema.define(version: 20170412143945) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -40,6 +40,7 @@ t.string "format" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "phase_id" end create_table "file_types", force: :cascade do |t|