Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
509d7b2
add ability to merge Orgs
briri Dec 15, 2020
23187c3
Merge branch 'development' into merge-orgs
briri Dec 15, 2020
177f66e
fix to plan merges for org.merge
briri Feb 10, 2021
d1e7b73
Merge branch 'development' into merge-orgs
briri Mar 10, 2021
2fcab79
fixed some rubocop issues
briri Mar 10, 2021
42ea9c1
Merge branch 'master' into merge-orgs
briri Mar 10, 2021
875632a
Merge branch 'development' into merge-orgs
briri Mar 10, 2021
48e9472
Merge branch 'development' into merge-orgs
briri Mar 25, 2021
e398d3b
fix issue https://github.com/DMPRoadmap/roadmap/issues/2843
nicolasfranck Mar 26, 2021
4e44e78
fix issue 2845
nicolasfranck Mar 26, 2021
36e7fca
Merge branch 'development' into fix_issue_2845
briri Mar 31, 2021
dc90f25
fixed rubocop complaint
briri Apr 1, 2021
6f35c7e
Merge branch 'development' into fix_issue_2845
briri Apr 1, 2021
47f2277
Merge pull request #2846 from nicolasfranck/fix_issue_2845
briri Apr 1, 2021
15477d0
Merge branch 'development' into fix_issue_2843
briri Apr 1, 2021
bcce080
Merge branch 'development' into merge-orgs
briri Apr 1, 2021
2af0c9f
Merge pull request #2844 from nicolasfranck/fix_issue_2843
briri Apr 1, 2021
7226511
further optimize queries
nicolasfranck Apr 2, 2021
4f4619c
fix typo
nicolasfranck Apr 2, 2021
ddb15d1
make rubocop less grumpy
nicolasfranck Apr 2, 2021
514a8aa
redirect edit page of notification after successfull creation/update
nicolasfranck Apr 6, 2021
ddc695b
Merge pull request #2862 from nicolasfranck/pr_notifications_controll…
briri Apr 6, 2021
d0d5da0
Merge branch 'development' into merge-orgs
briri Apr 12, 2021
e60de0f
roles_controller crashes when email is not supplied
nicolasfranck Apr 15, 2021
6316600
aria-required should also be required
nicolasfranck Apr 15, 2021
f84c56d
Merge branch 'development' into pr_plan_edit_less_queries
nicolasfranck Apr 16, 2021
72de423
Merge pull request #2874 from nicolasfranck/fix_share_required_params
briri Apr 16, 2021
a1bb038
Merge branch 'development' into pr_plan_edit_less_queries
briri Apr 16, 2021
90acb9e
Merge pull request #2861 from nicolasfranck/pr_plan_edit_less_queries
briri Apr 18, 2021
e448d88
Merge branch 'development' into merge-orgs
briri Apr 18, 2021
f0de3d3
Merge branch 'master' into development
briri Apr 19, 2021
6a3e001
Merge branch 'development' into merge-orgs
briri Apr 20, 2021
0cbc81f
fix rubocop and eslinter issues
briri Apr 26, 2021
2641e26
Merge branch 'merge-orgs' of github.com:DMPRoadmap/roadmap into merge…
briri Apr 26, 2021
a740764
bumped caches for gihub actions
briri Apr 26, 2021
8e7fcce
fix for failing test
briri Apr 26, 2021
7c914bf
fix for failing test
briri Apr 26, 2021
fe644e5
run application within RAILS_RELATIVE_URL_ROOT
nicolasfranck May 12, 2021
ec0302d
Merge branch 'master' into development
briri Jun 11, 2021
9c96cbf
fixed issue where users who create an account rather than accept an i…
briri Jun 15, 2021
cf21f10
Merge branch 'master' into development
briri Jun 21, 2021
487c7c8
only include active roles in plan share tab; don't take inactive role…
nicolasfranck Jun 24, 2021
d9b67f3
Merge pull request #2954 from nicolasfranck/fix_issue_2951
raycarrick-ed Jun 25, 2021
327eb05
updated paginable logic to allow non-remote refresh of tables during …
briri Jun 25, 2021
f2fb8ee
added spinner that gets displayed on UJS/Ajax calls:
briri Jun 25, 2021
1f099fc
fixed rubocop
briri Jun 25, 2021
c504583
fixed rubocop
briri Jun 25, 2021
081aad2
add 'other' role to contributors page
briri Jun 29, 2021
a812b42
fixed layout of roles on contributor form
briri Jun 29, 2021
4aa1d93
found a better spinner gif and updated to restrict the size of the sp…
briri Jun 29, 2021
525d7a2
Issue #462 - Fix for the case where API calls for Plans was failing in
Jul 5, 2021
e72bbee
Merge branch 'development' into bug_462_api_not_possible_to_get_plan_…
briri Jul 12, 2021
8b9de21
Merge pull request #2965 from DigitalCurationCentre/bug_462_api_not_p…
raycarrick-ed Jul 14, 2021
52e6986
added tr-TR language and ran translation:sync
briri Jun 23, 2021
00a98d3
tried to sync tr-TR
briri Jun 23, 2021
65508f8
added tr-TR to the correct Translation.io account and ran translation…
briri Jun 23, 2021
bc4db89
could still create new orgs when adding contributor
raycarrick-ed Jul 1, 2021
565825b
Update contributors_controller.rb
raycarrick-ed Jul 5, 2021
9af7ace
Update contributors_controller.rb
raycarrick-ed Jul 5, 2021
f69aa57
Update contributors_controller_spec.rb
raycarrick-ed Jul 5, 2021
b2dfc11
fix and add more tests for restrict_orgs
raycarrick-ed Jul 6, 2021
7c4829d
fixes for rubocop
raycarrick-ed Jul 6, 2021
a287642
translation:sync 2021/07/14
raycarrick-ed Jul 14, 2021
cbb0ada
Issue #462 - Fix for error messaging when you attempt Merge accounts
Jul 14, 2021
a496343
Merge branch 'development' into add-other-role
raycarrick-ed Jul 15, 2021
eb50fe6
Merge branch 'development' into add-spinner
raycarrick-ed Jul 15, 2021
7444b95
Merge pull request #2961 from DMPRoadmap/add-other-role
raycarrick-ed Jul 15, 2021
4db93fc
Merge branch 'development' into add-spinner
raycarrick-ed Jul 15, 2021
6e1d0d3
Merge pull request #2960 from DMPRoadmap/add-spinner
raycarrick-ed Jul 15, 2021
11a6ca5
Merge branch 'development' into translation_sync_july_2021
briri Jul 16, 2021
fdccc29
Merge pull request #2969 from DMPRoadmap/translation_sync_july_2021
briri Jul 16, 2021
861721a
Merge branch 'development' into bug_423_merging_accounts
briri Jul 19, 2021
2c8eccd
Merge pull request #2970 from DigitalCurationCentre/bug_423_merging_a…
briri Jul 19, 2021
bb1ba88
Merge branch 'development' into pagination-in-query-string
briri Jul 19, 2021
1b97135
Merge branch 'development' into invitation-fix
briri Jul 19, 2021
961efeb
Merge branch 'development' into merge-orgs
briri Jul 20, 2021
3c9cbef
Merge branch 'development' into merge-orgs
briri Jul 20, 2021
f4ed7f4
patch to allow toggleSpinner() to be called via js.erb templates
briri Jul 20, 2021
8653a9d
Merge branch 'development' into fix_issue_2897
briri Jul 23, 2021
4e59a8b
Issue #2972 - Add project Start and End Dates, ID and Grant Number to…
Jul 26, 2021
70a16cc
Merge pull request #2900 from nicolasfranck/fix_issue_2897
raycarrick-ed Jul 26, 2021
7200145
Merge branch 'development' into update-spinner
briri Jul 26, 2021
b82e4bf
Merge pull request #2976 from DMPRoadmap/update-spinner
briri Jul 26, 2021
38ac86a
added logic to hide spinner after merge analysis runs
briri Jul 26, 2021
8dc0f92
Merge branch 'development' into merge-orgs
briri Jul 26, 2021
01c4781
Merge pull request #2763 from DMPRoadmap/merge-orgs
briri Jul 26, 2021
cc87c01
Merge branch 'development' into invitation-fix
briri Jul 26, 2021
c6acbc7
Merge pull request #2946 from DMPRoadmap/invitation-fix
briri Jul 26, 2021
cfbe830
Merge branch 'development' into pagination-in-query-string
briri Jul 26, 2021
8e93c60
Merge pull request #2959 from DMPRoadmap/pagination-in-query-string
briri Jul 26, 2021
6a0f813
Merge branch 'master' into development
briri Jul 26, 2021
25f4971
Merge branch 'master' into development
raycarrick-ed Jul 27, 2021
c469b5c
fix up tests for org merging
raycarrick-ed Jul 27, 2021
e24b0aa
Merge branch 'development' into bug_2972_project_start-end_date_to_pd…
briri Jul 27, 2021
90c9dd3
fix merge issue with app.pot
briri Jul 27, 2021
6849416
Merge pull request #2982 from DMPRoadmap/bug_2972_project_start-end_d…
briri Jul 27, 2021
c707405
Merge branch 'development' of github.com:DMPRoadmap/roadmap into deve…
briri Jul 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Try to retrieve the gems from the cache
- name: 'Cache Gems'
uses: actions/cache@v1
uses: actions/cache@v2.1.5
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -62,7 +62,7 @@ jobs:

# Try to retrieve the yarn JS dependencies from the cache
- name: 'Cache Yarn Packages'
uses: actions/cache@v1
uses: actions/cache@v2.1.5
with:
path: node_modules/
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

# Try to retrieve the gems from the cache
- name: 'Cache Gems'
uses: actions/cache@v1
uses: actions/cache@v2.1.5
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -79,7 +79,7 @@ jobs:

# Try to retrieve the yarn JS dependencies from the cache
- name: 'Cache Yarn Packages'
uses: actions/cache@v1
uses: actions/cache@v2.1.5
with:
path: node_modules/
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
Expand Down
Binary file added app/assets/images/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/assets/stylesheets/blocks/_spinner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.spinner-border {
position: fixed;
top: 48%;
left: 43%;
}

.spinner-border img {
height: 80px;
width: 80px;
}
4 changes: 3 additions & 1 deletion app/controllers/api/v0/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def index
params[:per_page] = max_pages if params[:per_page].to_i > max_pages
end

@plans = @user.org.plans.includes([{ roles: :user }, { answers: :question_options },
# Get all the Org Admin plans
org_admin_plans = @user.org.org_admin_plans
@plans = org_admin_plans.includes([{ roles: :user }, { answers: :question_options },
template: [{ phases: {
sections: { questions: %i[question_format themes] }
} }, :org]])
Expand Down
12 changes: 8 additions & 4 deletions app/controllers/concerns/paginable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Paginable
# one approach to just include everything in the double splat `**options` param

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/ParameterLists
def paginable_renderise(partial: nil, controller: nil, action: nil,
def paginable_renderise(partial: nil, template: nil, controller: nil, action: nil,
path_params: {}, query_params: {}, scope: nil,
locals: {}, **options)
unless scope.is_a?(ActiveRecord::Relation)
Expand All @@ -50,6 +50,7 @@ def paginable_renderise(partial: nil, controller: nil, action: nil,
# Default options
@paginable_options = {}.merge(options)
@paginable_options[:view_all] = options.fetch(:view_all, true)
@paginable_options[:remote] = options.fetch(:remote, true)
# Assignment for paginable_params based on arguments passed to the method
@args = paginable_params.to_h
@args[:controller] = controller if controller
Expand All @@ -72,14 +73,17 @@ def paginable_renderise(partial: nil, controller: nil, action: nil,
locals = locals.merge(
scope: @refined_scope,
paginable_params: @args,
search_term: @args[:search]
search_term: @args[:search],
remote: @paginable_options[:remote]
)
# If this was an ajax call then render as JSON
if options[:format] == :json
render json: { html: render_to_string(layout: "/layouts/paginable",
partial: partial, locals: locals) }
else
elsif partial.present?
render(layout: "/layouts/paginable", partial: partial, locals: locals)
else
render(template: template, locals: locals)
end
end
end
Expand All @@ -104,7 +108,7 @@ def paginable_sort_link(sort_field)
sort_link_name(sort_field),
sort_link_url(sort_field),
class: "paginable-action",
data: { remote: true },
data: { remote: @paginable_options[:remote] },
aria: { label: sort_field }
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/org_admin/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index

@super_admin = current_user.can_super_admin?
@clicked_through = params[:click_through].present?
@plans = @super_admin ? Plan.all.page(1) : current_user.org.plans.page(1)
@plans = @super_admin ? Plan.all.page(1) : current_user.org.org_admin_plans.page(1)
end

# GET org_admin/plans/:id/feedback_complete
Expand Down Expand Up @@ -61,7 +61,7 @@ def download_plans

plans = CSV.generate do |csv|
csv << header_cols
org.plans.includes(template: :org).order(updated_at: :desc).each do |plan|
org.org_admin_plans.includes(template: :org).order(updated_at: :desc).each do |plan|
csv << [
plan.title.to_s,
plan.template.title.to_s,
Expand Down
12 changes: 5 additions & 7 deletions app/controllers/paginable/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ def organisationally_or_publicly_visible

# GET /paginable/plans/publicly_visible/:page
def publicly_visible
paginable_renderise(
partial: "publicly_visible",
scope: Plan.publicly_visible.includes(:template),
query_params: { sort_field: "plans.updated_at", sort_direction: :desc },
format: :json
)
# We want the pagination/sort/search to be retained in the URL so redirect instead
# of processing this as a JSON
paginable_params = params.permit(:page, :search, :sort_field, :sort_direction)
redirect_to public_plans_path(paginable_params.to_h)
end

# GET /paginable/plans/org_admin/:page
Expand All @@ -49,7 +47,7 @@ def org_admin
# check if current user if super_admin
@super_admin = current_user.can_super_admin?
@clicked_through = params[:click_through].present?
plans = @super_admin ? Plan.all : current_user.org.plans
plans = @super_admin ? Plan.all : current_user.org.org_admin_plans
plans = plans.joins(:template, roles: [user: :org]).where(Role.creator_condition)

paginable_renderise(
Expand Down
16 changes: 4 additions & 12 deletions app/controllers/paginable/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,10 @@ def customisable
# GET /paginable/templates/publicly_visible/:page (AJAX)
# -----------------------------------------------------
def publicly_visible
templates = Template.live(Template.families(Org.funder.pluck(:id)).pluck(:family_id))
.publicly_visible.pluck(:id) <<
Template.where(is_default: true).unarchived.published.pluck(:id)
paginable_renderise(
partial: "publicly_visible",
scope: Template.joins(:org)
.includes(:org)
.where(id: templates.uniq.flatten)
.published,
query_params: { sort_field: "templates.title", sort_direction: :asc },
format: :json
)
# We want the pagination/sort/search to be retained in the URL so redirect instead
# of processing this as a JSON
paginable_params = params.permit(:page, :search, :sort_field, :sort_direction)
redirect_to public_templates_path(paginable_params.to_h)
end

# GET /paginable/templates/:id/history/:page (AJAX)
Expand Down
19 changes: 14 additions & 5 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def create
elsif !@plan.template.customization_of.nil?
# We used a customized version of the the funder template
# rubocop:disable Layout/LineLength
msg += " #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{plan_params[:org_name]}"
msg += " #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}"
# rubocop:enable Layout/LineLength
else
# We used the specified org's or funder's template
Expand Down Expand Up @@ -219,7 +219,16 @@ def show
# doing this when we refactor the Plan editing UI
# GET /plans/:plan_id/phases/:id/edit
def edit
plan = Plan.includes({ template: { phases: { sections: :questions } } }, { answers: :notes })
plan = Plan.includes(
{ template: {
phases: {
sections: {
questions: %i[question_format question_options annotations themes]
}
}
} },
{ answers: :notes }
)
.find(params[:id])
authorize plan
phase_id = params[:phase_id].to_i
Expand Down Expand Up @@ -258,7 +267,7 @@ def update

if @plan.update(attrs) # _attributes(attrs)
format.html do
redirect_to plan_contributors_path(@plan),
redirect_to plan_path(@plan),
notice: success_message(@plan, _("saved"))
end
format.json do
Expand Down Expand Up @@ -293,7 +302,7 @@ def share
@plan = Plan.find(params[:id])
if @plan.present?
authorize @plan
@plan_roles = @plan.roles
@plan_roles = @plan.roles.where(active: true)
else
redirect_to(plans_path)
end
Expand All @@ -306,7 +315,7 @@ def request_feedback
@plan = Plan.find(params[:id])
if @plan.present?
authorize @plan
@plan_roles = @plan.roles
@plan_roles = @plan.roles.where(active: true)
else
redirect_to(plans_path)
end
Expand Down
25 changes: 21 additions & 4 deletions app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ class PublicPagesController < ApplicationController

# GET template_index
# -----------------------------------------------------
# rubocop:disable Metrics/AbcSize
def template_index
@templates_query_params = {
page: paginable_params.fetch(:page, 1),
search: paginable_params.fetch(:search, ""),
sort_field: paginable_params.fetch(:sort_field, "templates.title"),
sort_direction: paginable_params.fetch(:sort_direction, "asc")
}

templates = Template.live(Template.families(Org.funder.pluck(:id)).pluck(:family_id))
.publicly_visible.pluck(:id) <<
Template.where(is_default: true).unarchived.published.pluck(:id)
@templates = Template.includes(:org)
.where(id: templates.uniq.flatten)
.unarchived.published.order(title: :asc).page(1)
.unarchived.published
end
# rubocop:enable Metrics/AbcSize

# GET template_export/:id
# -----------------------------------------------------
Expand Down Expand Up @@ -79,13 +88,21 @@ def template_export
# GET /plans_index
# ------------------------------------------------------------------------------------
def plan_index
@plans = Plan.publicly_visible.includes(:template).page(1)
@plans = Plan.publicly_visible.includes(:template)
render "plan_index", locals: {
query_params: {
sort_field: "plans.updated_at",
sort_direction: "desc"
page: paginable_params.fetch(:page, 1),
search: paginable_params.fetch(:search, ""),
sort_field: paginable_params.fetch(:sort_field, "plans.updated_at"),
sort_direction: paginable_params.fetch(:sort_direction, "desc")
}
}
end

private

def paginable_params
params.permit(:page, :search, :sort_field, :sort_direction)
end

end
21 changes: 16 additions & 5 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def create
existing_user = User.where_case_insensitive("email", sign_up_params[:email]).first
if existing_user.present?
if existing_user.invitation_token.present? && !existing_user.accept_terms?
# Destroys the existing user since the accept terms are nil/false. and they
# have an invitation Note any existing role for that user will be deleted too.
# Added to accommodate issue at: https://github.com/DMPRoadmap/roadmap/issues/322
# when invited user creates an account outside the invite workflow
# If the user is creating an account but they have an outstanding invitation, remember
# any plans that were shared with the invitee so we can attach them to the new User record
shared_plans = existing_user.roles
.select(&:active?)
.map { |role| { plan_id: role.plan_id, access: role.access } }
existing_user.destroy

else
redirect_to after_sign_up_error_path_for(resource),
alert: _("That email address is already registered.")
Expand All @@ -88,6 +88,17 @@ def create

build_resource(attrs)

# If the user is creating an account but they have an outstanding invitation, attach the shared
# plan(s) to their new User record
if shared_plans.present? && shared_plans.any?
shared_plans.each do |role_hash|
plan = Plan.find_by(id: role_hash[:plan_id])
next unless plan.present?

Role.create(plan: plan, user: resource, access: role_hash[:access], active: true)
end
end

# Determine if reCAPTCHA is enabled and if so verify it
use_recaptcha = Rails.configuration.x.application.use_recaptcha || false
if (!use_recaptcha || verify_recaptcha(model: resource)) && resource.save
Expand Down
11 changes: 9 additions & 2 deletions app/controllers/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def create
authorize @role

message = ""
if role_params[:user].present? && plan.present?
if role_params[:user].present? &&
role_params[:user].key?(:email) &&
role_params[:user][:email].present? && plan.present?

if @role.plan.owner.present? && @role.plan.owner.email == role_params[:user][:email]
# rubocop:disable Layout/LineLength
flash[:notice] = _("Cannot share plan with %{email} since that email matches with the owner of the plan.") % {
Expand All @@ -26,7 +29,11 @@ def create
# rubocop:enable Layout/LineLength
else
user = User.where_case_insensitive("email", role_params[:user][:email]).first
if Role.find_by(plan: @role.plan, user: user) # role already exists
if user.present? &&
Role.where(plan: @role.plan, user: user, active: true)
.count
.positive? # role already exists

flash[:notice] = _("Plan is already shared with %{email}.") % {
email: role_params[:user][:email]
}
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/super_admin/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create
@notification.notification_type = "global"
if @notification.save
flash.now[:notice] = success_message(@notification, _("created"))
render :edit
redirect_to edit_super_admin_notification_path(@notification)
else
flash.now[:alert] = failure_message(@notification, _("create"))
render :new
Expand All @@ -49,6 +49,7 @@ def update
authorize(Notification)
if @notification.update(notification_params)
flash.now[:notice] = success_message(@notification, _("updated"))
return redirect_to edit_super_admin_notification_path(@notification)
else
flash.now[:alert] = failure_message(@notification, _("update"))
end
Expand Down
Loading