diff --git a/README.md b/README.md index 470c7cd..d439328 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Roadmap is a Ruby on Rails application and you will need to have: * Ruby >= 2.2.2 * Rails >= 4.2 -* MySql >= 5.0 OR PostgreSql +* MySQL >= 5.0 OR PostgreSQL Further detail on how to install Ruby on Rails applications are available from the Ruby on Rails site: http://rubyonrails.org @@ -34,7 +34,7 @@ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/ #### Installation -* Create your database. Select UTF-8 Unicode (utf8) encoding. +* Create your database. Select UTF-8 Unicode encoding (`utf8mb4` if using MySQL). * Clone this repository (or Fork the repository first if you plan on contributing) > > git clone https://github.com/[your organization]/roadmap.git diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index ee20348..17e316f 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -8,7 +8,7 @@ @note = Note.new @note.user_id = params[:note][:user_id] - # create answer if we dont already have one + # create answer if we don't have one already if params[:note][:answer_id].present? @answer = Answer.find(params[:note][:answer_id]) else diff --git a/app/controllers/phases_controller.rb b/app/controllers/phases_controller.rb index e3980fd..d20b7ea 100644 --- a/app/controllers/phases_controller.rb +++ b/app/controllers/phases_controller.rb @@ -4,8 +4,8 @@ after_action :verify_authorized - # GET /plans/:plan_id/phases/:id/edit - def edit + # GET /plans/:plan_id/phases/:id/edit + def edit @plan = Plan.eager_load2(params[:plan_id]) # authorization done on plan so found in plan_policy @@ -69,12 +69,12 @@ if !user_signed_in? then respond_to do |format| - format.html { redirect_to edit_user_registration_path } - end - end - + format.html { redirect_to edit_user_registration_path } + end end + end + # GET /plans/PLANID/phases/PHASEID/status.json def status diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index ae629a1..06373d9 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -161,10 +161,11 @@ respond_to do |format| if @plan.update_attributes(attrs) format.html { redirect_to @plan, :editing => false, notice: success_message(_('plan'), _('saved')) } - format.json { head :no_content } + format.json {render json: {code: 1, msg: success_message(_('plan'), _('saved'))}} else flash[:alert] = failed_update_error(@plan, _('plan')) format.html { render action: "edit" } + format.json {render json: {code: 0, msg: failed_update_error(@plan, _('plan'))}} end end end @@ -173,7 +174,12 @@ @plan = Plan.find(params[:id]) authorize @plan @visibility = @plan.visibility.present? ? @plan.visibility.to_s : Rails.application.config.default_plan_visibility - @allow_visibility = (@plan.num_answered_questions >= 1 && !@plan.is_test?) + + min_percentage = Rails.application.config.default_plan_percentage_answered + nanswers = @plan.num_answered_questions() + nquestions = @plan.num_questions() + value=(nanswers.to_f/nquestions*100).round(2) + @allow_visibility = (value >= min_percentage && !@plan.is_test?) end @@ -289,13 +295,9 @@ respond_to do |format| if @plan.save @plan.assign_creator(current_user) - flash[:notice] = success_message(_('plan'), _('copied')) - format.js { render js: "window.location='#{plan_url(@plan)}?editing=true'" } - # format.html { redirect_to @plan, notice: _('Plan was successfully duplicated.') } - # format.json { head :no_content } + format.html { redirect_to @plan, notice: success_message(_('plan'), _('copied')) } else - flash[:alert] = failed_create_error(@plan, 'Plan') - format.js {} + format.html { redirect_to plans_path, alert: failed_create_error(@plan, 'Plan') } end end end @@ -318,9 +320,9 @@ authorize plan plan.visibility = (params[:is_test] === "1" ? :is_test : :privately_visible) if plan.save - render json: {msg: (plan.is_test? ? _('Your project is now a test.') : _('Your project is no longer a test.') )} + render json: {code: 1, msg: (plan.is_test? ? _('Your project is now a test.') : _('Your project is no longer a test.') )} else - render status: :bad_request, json: {msg: _("Unable to change the plan's test status")} + render status: :bad_request, json: {code: 0, msg: _("Unable to change the plan's test status")} end end @@ -453,7 +455,6 @@ if templates.empty? templates << Template.where(is_default: true, published: true).first end - templates = (templates.count > 0 ? templates.sort{|x,y| x.title <=> y.title} : []) end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 43e0c55..041a0c3 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -50,9 +50,7 @@ UserMailer.permissions_change_notification(@role, current_user).deliver_now render json: {code: 1, msg: "Successfully changed the permissions for #{@role.user.email}. They have been notified via email."} else -# flash[:alert] = failed_create_error(@role, _('role')) - #format.html{ render action: "edit" } - render json: {code: 1, msg: flash[:alert]} + render json: {code: 0, msg: flash[:alert]} end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 0572dd2..f920923 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,16 +1,4 @@ class SessionsController < Devise::SessionsController - - # POST /auth/:provider/callback - # --------------------------------------------------------------------- -=begin - def oauth_create - existing_user = User.find_by_email(params[:user][:email]) - - unless params[:omniauth].nil? - existing_user = UserIdentifier.find_by(identifier: params[:omniauth][:auth]) - end - end -=end # Capture the user's shibboleth id if they're coming in from an IDP # --------------------------------------------------------------------- @@ -35,5 +23,4 @@ session[:locale] = nil set_gettext_locale #Method defined at controllers/application_controller.rb end - end \ No newline at end of file diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index c14979f..bc42e4b 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -158,7 +158,9 @@ end sections.each do |section| - output += "\n#{section.title}\n" + if question_headings + output += "\n#{section.title}\n" + end section.questions.each do |question| answer = self.plan.answer(question.id, false) #skip if question un-answered diff --git a/app/models/org.rb b/app/models/org.rb index 66c2bfb..069c95e 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -146,8 +146,8 @@ # def resize_image unless logo.nil? - if logo.height != 165 - self.logo = logo.thumb('x165') # resize height and maintain aspect ratio + if logo.height != 75 + self.logo = logo.thumb('x75') # resize height and maintain aspect ratio end end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 358998f..4a19104 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,11 +1,11 @@

<%= _('Welcome.')%>

-
+
-
+
<%= raw _('

%{application_name} has been jointly developed by the %{organisation_name} to help you write data management plans.

') % {:application_name => Rails.configuration.branding[:application][:name], :organisation_name => Rails.configuration.branding[:organisation][:name]} %>

<%= _('Screencast on how to use %{application_name}') % {:application_name => Rails.configuration.branding[:application][:name]} %>

diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index 7944147..6f91d01 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -1,4 +1,4 @@ -