Merge pull request #4606 from scinote-eln/develop

November 2022 cleanup release
This commit is contained in:
artoscinote 2022-11-09 10:49:27 +01:00 committed by GitHub
commit e4673f67ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 103 additions and 74 deletions

View file

@ -1 +1 @@
1.26.1
1.26.2

View file

@ -68,7 +68,9 @@
background-color: $color-concrete;
display: flex;
justify-content: center;
max-height: 300px;
min-height: 200px;
overflow-y: auto;
padding: .5em 0;
img {

View file

@ -403,7 +403,7 @@ class User < ApplicationRecord
result = result.where.not(confirmed_at: nil) if active_only
if team_to_ignore.present?
ignored_ids = UserTeam.select(:user_id).where(team_id: team_to_ignore.id)
ignored_ids = UserAssignment.select(:user_id).where(assignable: team_to_ignore)
result = result.where.not(users: { id: ignored_ids })
end
@ -629,7 +629,7 @@ class User < ApplicationRecord
query_teams = teams.pluck(:id)
query_teams &= filters[:teams].map(&:to_i) if filters[:teams]
query_teams &= User.team_by_subject(filters[:subjects]) if filters[:subjects]
User.where(id: UserTeam.where(team_id: query_teams).select(:user_id))
User.where(id: UserAssignment.where(assignable_id: query_teams, assignable_type: 'Team').select(:user_id))
.search(false, search_query)
.select(:full_name, :id)
.map { |i| { label: escape_input(i[:full_name]), value: i[:id] } }

View file

@ -4,7 +4,7 @@ module ModelExporters
class TeamExporter < ModelExporter
def initialize(team_id)
super()
@team = Team.includes(:user_teams).find(team_id)
@team = Team.find(team_id)
end
def export_to_dir
@ -42,9 +42,11 @@ module ModelExporters
@tiny_mce_assets_to_copy.push(team.tiny_mce_assets) if team.tiny_mce_assets.present?
{
team: team,
default_admin_id: team.user_teams.where(role: 2).first.user.id,
default_admin_id: team.user_assignments.where(user_role: UserRole.find_predefined_owner_role).first.user.id,
users: team.users.map { |u| user(u) },
user_teams: team.user_teams,
user_assignments: team.user_assignments.map do |ua|
user_assignment(ua)
end,
notifications: Notification
.includes(:user_notifications)
.where('user_notifications.user_id': team.users)
@ -52,7 +54,11 @@ module ModelExporters
repositories: team.repositories.map { |r| repository(r) },
tiny_mce_assets: team.tiny_mce_assets.map { |tma| tiny_mce_asset_data(tma) },
protocols: team.protocols.where(my_module: nil).map do |pr|
protocol(pr)
protocol(pr).merge(
user_assignments: pr.user_assignments.map do |ua|
user_assignment(ua)
end
)
end,
protocol_keywords: team.protocol_keywords,
project_folders: team.project_folders,
@ -124,13 +130,17 @@ module ModelExporters
user_id: user_assignment.user_id,
assigned_by_id: user_assignment.assigned_by_id,
role_name: user_assignment.user_role.name,
assigned: user_assignment.assigned
assigned: user_assignment.assigned,
team_id: user_assignment.team_id
}
end
def report(report)
{
report: report,
user_assignments: report.user_assignments.map do |ua|
user_assignment(ua)
end,
report_elements: report.report_elements
}
end
@ -146,6 +156,10 @@ module ModelExporters
end
}
unless repository.is_a?(RepositorySnapshot)
result[:user_assignments] =
repository.user_assignments.where(team: repository.team, user: repository.team.users).map do |ua|
user_assignment(ua)
end
result[:repository_snapshots] = repository.repository_snapshots.map { |r| repository(r) }
end
result

View file

@ -27,6 +27,8 @@ class TeamImporter
@checklist_mappings = {}
@table_mappings = {}
@report_mappings = {}
@label_template_mappings = {}
@step_text_mappings = {}
@project_counter = 0
@repository_counter = 0
@ -59,25 +61,18 @@ class TeamImporter
team_last_modified_by = team.last_modified_by_id
team.last_modified_by_id = nil
team.without_templates = true
team.skip_user_assignments = true
team.save!
@team_id = team.id
create_users(team_json['users'], team)
puts 'Assigning users to the team...'
create_user_assignments(team_json['user_assignments'], team)
# Find new id of the first admin in the team
@admin_id = @user_mappings[team_json['default_admin_id']]
create_notifications(team_json['notifications'])
puts 'Assigning users to the team...'
team_json['user_teams'].each do |user_team_json|
user_team = UserTeam.new(user_team_json)
user_team.id = nil
user_team.user_id = find_user(user_team.user_id)
user_team.team_id = team.id
user_team.assigned_by_id = find_user(user_team.assigned_by_id)
user_team.save!
end
create_protocol_keywords(team_json['protocol_keywords'], team)
create_protocols(team_json['protocols'], nil, team)
create_project_folders(team_json['project_folders'], team)
@ -316,6 +311,7 @@ class TeamImporter
team.label_templates.where.not(type: 'FluicsLabelTemplate').destroy_all
label_templates_json.each do |template_json|
template = LabelTemplate.new(template_json)
orig_template_id = template.id
template.id = nil
template.team_id = team.id
template.created_by_id = find_user(template.created_by_id) if template.created_by_id
@ -323,6 +319,7 @@ class TeamImporter
template.save!
@label_template_counter += 1
@label_template_mappings[orig_template_id] = template.id
end
end
@ -457,7 +454,11 @@ class TeamImporter
repository.archived_by_id = find_user(repository.archived_by_id)
repository.restored_by_id = find_user(repository.restored_by_id)
repository.discarded_by_id = find_user(repository.discarded_by_id)
repository.skip_user_assignments = true
repository.save!
create_user_assignments(repository_json['user_assignments'], repository)
@repository_mappings[orig_repository_id] = repository.id
@repository_counter += 1
repository_json['repository_columns'].each do |repository_column_json|
@ -790,6 +791,9 @@ class TeamImporter
protocol.skip_user_assignments = true
protocol.parent_id = @protocol_mappings[protocol.parent_id] unless protocol.parent_id.nil?
protocol.save!
create_user_assignments(protocol_json['user_assignments'], protocol) if protocol.in_repository?
@protocol_counter += 1
@protocol_mappings[orig_protocol_id] = protocol.id
@ -832,9 +836,11 @@ class TeamImporter
step_json['step_orderable_elements'].each do |element_json|
if element_json['step_text']
orderable = StepText.new(element_json['step_text'])
orig_step_text_id = orderable.id
orderable.step_id = step.id
orderable.id = nil
orderable.save!
@step_text_mappings[orig_step_text_id] = orderable.id
elsif element_json['table']
table = Table.new(element_json['table'])
orig_table_id = table.id
@ -983,7 +989,11 @@ class TeamImporter
report.user_id = find_user(report.user_id)
report.last_modified_by_id = find_user(report.last_modified_by_id)
report.team_id = team.id
report.skip_user_assignments = true
report.save!
create_user_assignments(report_json['user_assignments'], report)
@report_mappings[orig_report_id] = report.id
@report_counter += 1
report_json['report_elements'].each do |report_element_json|
@ -1057,6 +1067,7 @@ class TeamImporter
user_assignment.user_id = find_user(user_assignment_json['user_id'])
user_assignment.assigned = user_assignment_json['assigned']
user_assignment.assigned_by_id = find_user(user_assignment_json['assigned_by_id'])
user_assignment.team_id = @team_id
user_assignment.save!
end
end

View file

@ -48,6 +48,7 @@
<!-- RIGHT TOOLBAR BLOCK -->
<div class="toolbar-right-block">
<% if RepositoryBase.stock_management_enabled? %>
<div class="active-reminders-filter"
title="<%= t('repositories.index.active_reminders.description') %>"
data-checked-title="<%= t('repositories.index.active_reminders.checked_description') =%>"
@ -62,6 +63,7 @@
<span class="active-reminders-short-label"><%= t('repositories.index.active_reminders.short_label') %></span>
</span>
</div>
<% end %>
<div class="toolbar-filters"></div>
<% if @repository.is_a?(BmtRepository) %>
<div class="toolbar-bmt-filters">

View file

@ -4,7 +4,7 @@ require 'rufus-scheduler'
scheduler = Rufus::Scheduler.singleton
if ENV['ENABLE_TEMPLATES_SYNC']
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
# Templates sync periodic task
scheduler.every '12h' do
Rails.logger.info('Templates, syncing all template projects')
@ -33,8 +33,8 @@ if Rails.application.secrets.system_notifications_uri.present? &&
end
end
if ENV['ENABLE_FLUICS_SYNC'] && LabelPrinter.fluics.any?
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
scheduler.every '24h' do
LabelPrinters::Fluics::SyncService.new.sync_templates!
LabelPrinters::Fluics::SyncService.new.sync_templates! if LabelPrinter.fluics.any?
end
end

View file

@ -957,7 +957,7 @@ en:
no_tags: "+ Add tags"
manage_tags: "Manage tags"
create_new_tag: "create new"
recent_protocols_from_repository: "Recent protocols from the Repository"
recent_protocols_from_repository: "Recent protocols from the Templates"
notes:
title: "Notes"
no_description: "No task description"
@ -969,10 +969,10 @@ en:
title: "Protocol"
options_dropdown:
title: "Protocol options"
load_from_repo: "Load from repository"
load_from_repo: "Load from templates"
import: "Import protocol"
export: "Export protocol"
save_to_repo: "Save to repository"
save_to_repo: "Save to templates"
delete_steps: "Delete all steps"
description:
title: "Edit task %{module} description"
@ -1018,48 +1018,48 @@ en:
template_updated: "Protocol template updated on:"
protocol_updated: "Protocol updated on:"
messages:
template_updated_html: "There is a new version of this protocol available in the protocol repository.<br>Would you like to update it?"
template_updated_html: "There is a new version of this protocol available in the protocol templates.<br>Would you like to update it?"
protocol_updated: "The version of this protocol in the task is modified, do you wish to save it as a new protocol template?"
unlinked: "This protocol is not linked to the repository."
unlinked: "This protocol is not linked to the templates."
btns:
unlink: "Unlink protocol template"
unlink_title: "Unlink this protocol from the parent in the repository"
unlink_title: "Unlink this protocol from the parent in the templates"
revert: "Revert protocol"
revert_title: "Revert the protocol to the repository version. This will discard any local changes."
save_to_repository: "Save to repository"
save_a_copy_to_repository: "Save a copy to repository"
save_to_repository_title: "Copy this protocol to repository"
update_self: "Update from repository"
update_self_title: "Update this protocol with the version stored in the repository"
revert_title: "Revert the protocol to the templates version. This will discard any local changes."
save_to_repository: "Save to templates"
save_a_copy_to_repository: "Save a copy to templates"
save_to_repository_title: "Copy this protocol to templates"
update_self: "Update from templates"
update_self_title: "Update this protocol with the version stored in the templates"
confirm_link_update_modal:
unlink_title: "Unlink protocol template"
unlink_message: "Are you sure you want to unlink the task protocol from the repository version? This will stop any tracking of changes."
unlink_message: "Are you sure you want to unlink the task protocol from the templates version? This will stop any tracking of changes."
unlink_btn_text: "Unlink"
revert_title: "Revert protocol"
revert_message: "Are you sure you want to revert the task protocol to the repository version? This will override any local changes you made."
revert_message: "Are you sure you want to revert the task protocol to the templates version? This will override any local changes you made."
revert_btn_text: "Revert"
update_parent_title: "Update repository version"
update_parent_message: "Are you sure you want to update the repository protocol with this version? This will override any other changes made in the repository version."
update_self_title: "Update from repository"
update_self_message: "Are you sure you want to update this protocol with the version from the repository? This will override any local changes you made."
update_parent_title: "Update templates version"
update_parent_message: "Are you sure you want to update the templates protocol with this version? This will override any other changes made in the templates version."
update_self_title: "Update from templates"
update_self_message: "Are you sure you want to update this protocol with the version from the templates? This will override any local changes you made."
unlink_flash: "Protocol was successfully unlinked."
unlink_error: "Failed to unlink protocol."
revert_flash: "Protocol was successfully reverted to protocol version."
revert_error: "Failed to revert protocol."
revert_error_locked: "Failed to revert protocol. One or more files in the protocol are currently being edited."
update_parent_flash: "Protocol in repository was successfully updated with the version from the task."
update_parent_error: "Failed to update repository version of the protocol."
update_parent_error_locked: "Failed to update repository version of the protocol. One or more files in the protocol are currently being edited."
update_from_parent_flash: "Version in the repository was successfully updated."
update_from_parent_error: "Failed to update the protocol with the version in the repository."
update_from_parent_error_locked: "Failed to update the protocol with the version in the repository. One or more files in the protocol are currently being edited."
load_from_repository_flash: "Successfully loaded the protocol from the repository."
load_from_repository_error: "Failed to load the protocol from the repository."
load_from_repository_error_locked: "Failed to load the protocol from the repository. One or more files in the protocol are currently being edited."
update_parent_flash: "Protocol in templates was successfully updated with the version from the task."
update_parent_error: "Failed to update templates version of the protocol."
update_parent_error_locked: "Failed to update templates version of the protocol. One or more files in the protocol are currently being edited."
update_from_parent_flash: "Version in the templates was successfully updated."
update_from_parent_error: "Failed to update the protocol with the version in the templates."
update_from_parent_error_locked: "Failed to update the protocol with the version in the templates. One or more files in the protocol are currently being edited."
load_from_repository_flash: "Successfully loaded the protocol from the templates."
load_from_repository_error: "Failed to load the protocol from the templates."
load_from_repository_error_locked: "Failed to load the protocol from the templates. One or more files in the protocol are currently being edited."
load_from_repository_modal:
title: "Load protocol from repository"
title: "Load protocol from templates"
text: "Choose the protocol to be loaded to the task."
text2: "This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository."
text2: "This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates."
tab_public: "Team protocols"
tab_private: "My protocols"
tab_recent: "Recent protocols"
@ -1072,20 +1072,20 @@ en:
thead_published_on: "Published at"
thead_created_at: "Created at"
thead_updated_at: "Last modified at"
confirm_message: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository."
import_to_linked_task_rep: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository."
confirm_message: "Are you sure you wish to load protocol from templates? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates."
import_to_linked_task_rep: "Are you sure you wish to load protocol from templates? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates."
load: "Load"
copy_to_repository_modal:
title: "Save to protocol repository"
name_label: "Repository protocol name"
title: "Save to protocol templates"
name_label: "Templates protocol name"
name_placeholder: "My protocol"
type_label: "Save to"
type_public: "Team protocols"
type_private: "My protocols"
type_text: "You can make a copy of a protocol and save it to Team protocols or My protocols. Team protocols are visible to all team members, My protocols are for personal usage only."
link_label: "Link task to this protocol in repository"
link_label: "Link task to this protocol in templates"
link_text: "<strong>Warning!</strong>&nbsp;This will unlink the currently linked protocol."
error_400: "Due to unknown error, protocol could not be copied to repository."
error_400: "Due to unknown error, protocol could not be copied to templates."
confirm: "Save"
load_from_file_flash: "Successfully loaded the protocol from the file."
load_from_file_error: "Failed to load the protocol from file."
@ -2488,7 +2488,7 @@ en:
title_import_into_protocol_protocols_io: "Load protocol from protocols.io file"
import_into_protocol_message: "This will overwrite the current protocol!"
import_into_protocol_confirm: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol."
import_to_linked_task_file: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository."
import_to_linked_task_file: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates."
name_label: "Protocol name"
authors_label: "Authors"
description_label: "Description"

View file

@ -247,9 +247,9 @@ en:
task_step_text_duplicated_html: "%{user} duplicated text <strong>%{text_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> on task %{my_module}."
task_step_table_duplicated_html: "%{user} duplicated table <strong>%{table_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> on task %{my_module}."
task_step_checklist_duplicated_html: "%{user} duplicated checklist <strong>%{checklist_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> on task %{my_module}."
protocol_step_text_duplicated_html: "%{user} duplicated text <strong>%{text_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in protocol %{protocol} in Protocol repository."
protocol_step_table_duplicated_html: "%{user} duplicated table <strong>%{table_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in protocol %{protocol} in Protocol repository."
protocol_step_checklist_duplicated_html: "%{user} duplicated checklist <strong>%{checklist_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in protocol %{protocol} in Protocol repository."
protocol_step_text_duplicated_html: "%{user} duplicated text <strong>%{text_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in Protocol repository."
protocol_step_table_duplicated_html: "%{user} duplicated table <strong>%{table_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in Protocol repository."
protocol_step_checklist_duplicated_html: "%{user} duplicated checklist <strong>%{checklist_name}</strong> in protocols step %{step_position} <strong>%{step}</strong> in Protocol repository."
label_template_created_html: "%{user} created %{type} label template %{label_template} in Label templates."
label_template_edited_html: "%{user} edited %{type} label template %{label_template} in Label templates."
label_template_deleted_html: "%{user} deleted %{type} label template %{label_template} in Label templates."