Skip to content

Commit

Permalink
Merge branch 'seek-1.16' into issue-2079
Browse files Browse the repository at this point in the history
  • Loading branch information
whomingbird committed Dec 17, 2024
2 parents edae952 + 3c90331 commit 9be4512
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 43 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
${{ runner.os }}-
- name: Install Python dependencies
run: |
python3.9 -m pip install --upgrade pip
python3.9 -m pip install setuptools==58
python3.9 -m pip install -r requirements.txt
- name: Create test database
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ RUN touch config/using-docker #allows us to see within SEEK we are running in a

# Python dependencies from requirements.txt
ENV PATH="/var/www/.local/bin:$PATH"
RUN python3.9 -m pip install --upgrade pip
RUN python3.9 -m pip install setuptools==58
RUN python3.9 -m pip install -r requirements.txt

Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ GEM
nokogiri (~> 1)
rake
mini_mime (1.1.5)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
minitest (5.25.1)
minitest-reporters (1.5.0)
ansi
Expand Down Expand Up @@ -492,7 +492,7 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.4)
nokogiri (1.16.7)
nokogiri (1.16.8)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nori (1.1.5)
Expand Down Expand Up @@ -607,9 +607,9 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails-observers (0.1.5)
activemodel (>= 4.0)
rails-perftest (0.0.7)
Expand Down
11 changes: 8 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module ApplicationHelper
include ImagesHelper
include SessionsHelper

ALLOWED_HTML_WITH_TABLES = Rails::HTML::Concern::Scrubber::SafeList::DEFAULT_ALLOWED_TAGS.dup +
Set.new(%w(table thead tbody tfoot tr th td))

def no_items_to_list_text
content_tag :div, id: 'no-index-items-text' do
"There are no #{resource_text_from_controller.pluralize} found that are visible to you."
Expand Down Expand Up @@ -224,7 +227,7 @@ def text_or_not_specified(text, options = {})
else
text.capitalize! if options[:capitalize]
res = text.html_safe
res = sanitized_text(res)
res = sanitized_text(res, allow_tables: options[:markdown])
res = truncate_without_splitting_words(res, options[:length]) if options[:length]
if options[:markdown]
# Convert `>` etc. back to `>` so markdown blockquotes can be used.
Expand Down Expand Up @@ -428,8 +431,10 @@ def using_docker?
Seek::Docker.using_docker?
end

def sanitized_text(text)
Rails::Html::SafeListSanitizer.new.sanitize(text)
def sanitized_text(text, allow_tables: false)
opts = {}
opts[:tags] = ALLOWED_HTML_WITH_TABLES if allow_tables
Rails::Html::SafeListSanitizer.new.sanitize(text, opts)
end

# whether manage attributes should be shown, dont show if editing (rather than new or managing)
Expand Down
1 change: 1 addition & 0 deletions app/helpers/filtering_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module FilteringHelper
def filter_link(key, filter, hidden: false, replace: false)
link_to(page_and_sort_params.merge({ page: nil, filter: filter.active ? without_filter(key, filter.value) : with_filter(key, filter.value, replace: replace) }),
title: filter.label,
rel: 'nofollow',
class: "filter-option#{' filter-option-active' if filter.active}#{' filter-option-hidden' if hidden}") do
content_tag(:span, filter.label, class: 'filter-option-label') +
content_tag(:span, filter.count, class: 'filter-option-count')
Expand Down
17 changes: 13 additions & 4 deletions app/models/sample_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ def can_see_hidden_item?(user)
can_view?(user)
end

def self.is_asset?
false
end

# although has a downloadable template, it doesn't have the full downloadable behaviour of an asset with data and it's own accessible permissions
def is_downloadable?
false
end

def self.supports_extended_metadata?
false
end

private

# whether the referring sample is valid and gives permission to view
Expand Down Expand Up @@ -292,9 +305,5 @@ def validate_title_is_not_type_of_seek_sample_multi
end
end

def self.supports_extended_metadata?
false
end

class UnknownAttributeException < RuntimeError; end
end
2 changes: 1 addition & 1 deletion app/views/projects/import_from_fairdata_station.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<%= panel('Sharing permissions') do %>
<div class="alert alert-info">
<p>
The following sharing permissions will be applied to all the items created. It is possible to change them individually after they have been created. %>.
The following sharing permissions will be applied to all the items created. It is possible to change them individually after they have been created.
</p>
<p>
Note that <strong>Download</strong> is shown but only applicable to some types. Where not applicable, then <strong>View</strong> will be applied.
Expand Down
2 changes: 2 additions & 0 deletions app/views/sample_types/_template.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% return unless @sample_type.can_download? %>
<h2>Template</h2>
<div id="template-details">

<% if @sample_type.template %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sample_types/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="col-md-9 col-sm-8 box_about_actor">
<%= item_description h(@sample_type.description) -%>

<h2>Template</h2>

<%= render :partial => "template" %>

<h2>Attributes</h2>
Expand Down
7 changes: 4 additions & 3 deletions app/views/workflows/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@

<% begin %>
<% if @display_workflow.diagram_exists? || @display_workflow.can_render_diagram? %>
<% diagram_path = diagram_workflow_path(@workflow, version: @display_workflow.version) %>
<% is_svg = @display_workflow&.diagram&.extension == 'svg' %>
<div class="row">
<div class="col-md-12">
<div class="workflow-diagram">
<% diagram_path = diagram_workflow_path(@workflow, version: @display_workflow.version) %>
<% if @display_workflow&.diagram.extension == 'svg' %>
<% if is_svg %>
<%= content_tag(:embed, '', type: 'image/svg+xml', src: diagram_path, class: 'svg-pan-zoom', width: 1000, height: 500) %>
<p class="help-block">Click and drag the diagram to pan, double click or use the controls to zoom.</p>
<% else %>
Expand All @@ -44,7 +45,7 @@
</div>
<% end %>
<% rescue StandardError => e %>
<% raise e if Rails.env.development? %>
<% raise e unless Rails.env.production? %>
<% Rails.logger.error(e.inspect) %>
<% Rails.logger.error(e.backtrace.join("\n")) %>
<div class="alert alert-warning">Could not render the workflow diagram.</div>
Expand Down
8 changes: 4 additions & 4 deletions config/help_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Document: https://docs.seek4science.org/help/user-guide/adding-assets.html
Presentation: https://docs.seek4science.org/help/user-guide/adding-assets.html
Event: https://docs.seek4science.org/help/user-guide/general-attributes.html#events
clipboard_api_mozilla: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API
ExtendedMetadataType: https://docs.seek4science.org/tech/extended-metadata
extended_metadata_technical_overview: https://github.com/seek4science/seek-documentation/blob/gh-pages-extended_metadata-type/tech/extended_metadata/extended-metadata-type.md
extended_metadata_type_json_schema: https://github.com/seek4science/seek-documentation/blob/gh-pages-extended_metadata-type/tech/extended_metadata/extended_metadata_type_schema.json
extended_metadata_type_example: https://github.com/seek4science/seek-documentation/blob/gh-pages-extended_metadata-type/tech/extended_metadata/a-complete-example.md
ExtendedMetadataType: https://docs.seek4science.org/tech/extended-metadata/extended-metadata-type.html
extended_metadata_technical_overview: https://docs.seek4science.org/tech/extended-metadata/extended-metadata-type.html
extended_metadata_type_json_schema: https://docs.seek4science.org/tech/extended-metadata/extended-metadata-type-schema.json
extended_metadata_type_example: https://docs.seek4science.org/tech/extended-metadata/a-complete-example.html
2 changes: 1 addition & 1 deletion config/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

major: 1
minor: 16
patch: 0-pre
patch: 0
4 changes: 2 additions & 2 deletions docker-compose-relative-root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
seek: # The SEEK application
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16

container_name: seek
command: docker/entrypoint.sh
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
seek_workers: # The SEEK delayed job workers
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16
container_name: seek-workers
command: docker/start_workers.sh
restart: always
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-virtuoso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:

seek: # The SEEK application
#build: .
image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16
container_name: seek
command: docker/entrypoint.sh
restart: always
Expand All @@ -38,7 +38,7 @@ services:

seek_workers: # The SEEK delayed job workers
#build: .
image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16
container_name: seek-workers
command: docker/start_workers.sh
restart: always
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-with-email.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
seek: # The SEEK application
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16

container_name: seek
command: docker/entrypoint.sh
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
seek_workers: # The SEEK delayed job workers
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16
container_name: seek-workers
command: docker/start_workers.sh
restart: always
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
seek: # The SEEK application
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16

container_name: seek
command: docker/entrypoint.sh
Expand Down Expand Up @@ -41,7 +41,7 @@ services:
seek_workers: # The SEEK delayed job workers
#build: .

image: fairdom/seek:1.16-dev
image: fairdom/seek:1.16
container_name: seek-workers
command: docker/start_workers.sh
restart: always
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/seek_dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ namespace :seek_dev do
pub_ids = Project.find(project_id).publications.map(&:id)
pub_ids.each do |id|
permission = Publication.find(id).policy.permissions.where(contributor_type: "Person", contributor_id: person_id).first_or_initialize
permission.update_attributes(access_type: Policy::MANAGING)
permission.update(access_type: Policy::MANAGING)
end

end
Expand Down
23 changes: 20 additions & 3 deletions lib/tasks/seek_upgrades.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace :seek do
update_observation_unit_policies
fix_xlsx_marked_as_zip
add_policies_to_existing_sample_types
fix_previous_sample_type_permissions
]

# these are the tasks that are executes for each upgrade as standard, and rarely change
Expand Down Expand Up @@ -104,13 +105,13 @@ namespace :seek do

# Visible if linked to public samples
if st.samples.any? { |sample| sample.is_published? }
policy.access_type = Policy::VISIBLE
policy.access_type = Policy::ACCESSIBLE
else
policy.access_type = Policy::NO_ACCESS
end
# Visible to each project
st.projects.map do |project|
policy.permissions << Permission.new(contributor_type: Permission::PROJECT, contributor_id: project.id, access_type: Policy::VISIBLE)
policy.permissions << Permission.new(contributor_type: Permission::PROJECT, contributor_id: project.id, access_type: Policy::ACCESSIBLE)
end
# Project admins can manage
project_admins = st.projects.map(&:project_administrators).flatten
Expand All @@ -125,7 +126,23 @@ namespace :seek do
counter += 1
end
end
puts "...Added policies to #{counter} sample types"
puts "... Added policies to #{counter} sample types"
end

task(fix_previous_sample_type_permissions: [:environment]) do
only_once('fix_previous_sample_type_permissions 1.16.0') do
puts '... Updating previous sample type permissions ...'
SampleType.includes(:policy).where.not(policy_id: nil).each do |sample_type|
policy = sample_type.policy
if policy.access_type == Policy::VISIBLE
policy.update_column(:access_type, Policy::ACCESSIBLE)
end
policy.permissions.where(access_type: Policy::VISIBLE).where(contributor_type: Permission::PROJECT).update_all(access_type: Policy::ACCESSIBLE)
putc('.')
end
AuthLookupUpdateQueue.enqueue(SampleType.all)
puts '... Finished updating previous sample type permissions'
end
end

private
Expand Down
1 change: 1 addition & 0 deletions script/ansible/Deploy-SEEK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
- name: Install SEEK's python requirements
shell: bash -lc "{{ item }}"
with_items:
- python3.9 -m pip install --upgrade pip
- python3.9 -m pip install setuptools==58
- python3.9 -m pip install -r requirements.txt
args:
Expand Down
20 changes: 10 additions & 10 deletions test/functional/documents_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ class DocumentsControllerTest < ActionController::TestCase

assert_select '.filter-category[data-filter-category="project"]' do
assert_select '.filter-category-title', text: 'Project'
assert_select '.filter-option', count: 2
assert_select ".filter-option[rel='nofollow']", count: 2
assert_select '.filter-option.filter-option-active', count: 0
assert_select ".filter-option[title='#{project.title}']" do
assert_select '[href=?]', documents_path(filter: { project: project.id })
Expand All @@ -728,7 +728,7 @@ class DocumentsControllerTest < ActionController::TestCase

assert_select '.filter-category[data-filter-category="contributor"]' do
assert_select '.filter-category-title', text: 'Submitter'
assert_select '.filter-option', href: /documents\?filter\[contributor\]=\d+/, count: 8
assert_select ".filter-option[rel='nofollow']", href: /documents\?filter\[contributor\]=\d+/, count: 8
assert_select '.filter-option.filter-option-active', count: 0
# Should show 6 options and hide the rest
assert_select '.filter-option.filter-option-hidden', count: 2
Expand All @@ -737,7 +737,7 @@ class DocumentsControllerTest < ActionController::TestCase

assert_select '.filter-category[data-filter-category="tag"]' do
assert_select '.filter-category-title', text: 'Tag'
assert_select '.filter-option', count: 1
assert_select ".filter-option[rel='nofollow']", count: 1
assert_select '.filter-option.filter-option-active', count: 0
assert_select ".filter-option[title='awkward&id=1unsafe[]tag !']" do
assert_select '.filter-option-label', text: 'awkward&id=1unsafe[]tag !'
Expand Down Expand Up @@ -772,14 +772,14 @@ class DocumentsControllerTest < ActionController::TestCase
# Should show other project in projects category
assert_select '.filter-category[data-filter-category="project"]' do
assert_select '.filter-category-title', text: 'Project'
assert_select '.filter-option.filter-option-active', count: 1
assert_select '.filter-option', count: 2
assert_select ".filter-option[title='#{project.title}']" do
assert_select ".filter-option[rel='nofollow'].filter-option-active", count: 1
assert_select ".filter-option[rel='nofollow']", count: 2
assert_select ".filter-option[title='#{project.title}'][rel='nofollow']" do
assert_select '[href=?]', documents_path(filter: { programme: programme.id, project: [other_project.id, project.id] })
assert_select '.filter-option-label', text: project.title
assert_select '.filter-option-count', text: '7'
end
assert_select ".filter-option[title='#{other_project.title}'].filter-option-active" do
assert_select ".filter-option[title='#{other_project.title}'][rel='nofollow'].filter-option-active" do
assert_select '[href=?]', documents_path(filter: { programme: programme.id })
assert_select '.filter-option-label', text: other_project.title
assert_select '.filter-option-count', text: '1'
Expand All @@ -789,7 +789,7 @@ class DocumentsControllerTest < ActionController::TestCase

assert_select '.filter-category[data-filter-category="contributor"]' do
assert_select '.filter-category-title', text: 'Submitter'
assert_select '.filter-option', count: 1
assert_select ".filter-option[rel='nofollow']", count: 1
assert_select '.filter-option.filter-option-active', count: 0
assert_select '.filter-option.filter-option-hidden', count: 0
assert_select ".filter-option[title='#{other_project_doc.contributor.name}']" do
Expand All @@ -808,11 +808,11 @@ class DocumentsControllerTest < ActionController::TestCase

assert_select '.active-filters' do
assert_select '.active-filter-category-title', count: 2
assert_select ".filter-option[title='#{programme.title}'].filter-option-active" do
assert_select ".filter-option[title='#{programme.title}'][rel='nofollow'].filter-option-active" do
assert_select '[href=?]', documents_path(filter: { project: other_project.id })
assert_select '.filter-option-label', text: programme.title
end
assert_select ".filter-option[title='#{other_project.title}'].filter-option-active" do
assert_select ".filter-option[title='#{other_project.title}'][rel='nofollow'].filter-option-active" do
assert_select '[href=?]', documents_path(filter: { programme: programme.id })
assert_select '.filter-option-label', text: other_project.title
end
Expand Down
Loading

0 comments on commit 9be4512

Please sign in to comment.