fixing hound

This commit is contained in:
zmagod 2017-01-25 15:00:14 +01:00
parent afd8328e9c
commit 1220466035
5 changed files with 149 additions and 63 deletions

View file

@ -52,46 +52,123 @@ class User < ActiveRecord::Base
has_many :custom_fields, inverse_of: :user
has_many :reports, inverse_of: :user
has_many :created_assets, class_name: 'Asset', foreign_key: 'created_by_id'
has_many :modified_assets, class_name: 'Asset', foreign_key: 'last_modified_by_id'
has_many :created_checklists, class_name: 'Checklist', foreign_key: 'created_by_id'
has_many :modified_checklists, class_name: 'Checklist', foreign_key: 'last_modified_by_id'
has_many :created_checklist_items, class_name: 'ChecklistItem', foreign_key: 'created_by_id'
has_many :modified_checklist_items, class_name: 'ChecklistItem', foreign_key: 'last_modified_by_id'
has_many :modified_comments, class_name: 'Comment', foreign_key: 'last_modified_by_id'
has_many :modified_custom_fields, class_name: 'CustomField', foreign_key: 'last_modified_by_id'
has_many :created_my_module_groups, class_name: 'MyModuleGroup', foreign_key: 'created_by_id'
has_many :created_my_module_tags, class_name: 'MyModuleTag', foreign_key: 'created_by_id'
has_many :created_my_modules, class_name: 'MyModule', foreign_key: 'created_by_id'
has_many :modified_my_modules, class_name: 'MyModule', foreign_key: 'last_modified_by_id'
has_many :archived_my_modules, class_name: 'MyModule', foreign_key: 'archived_by_id'
has_many :restored_my_modules, class_name: 'MyModule', foreign_key: 'restored_by_id'
has_many :created_teams, class_name: 'Team', foreign_key: 'created_by_id'
has_many :modified_teams, class_name: 'Team', foreign_key: 'last_modified_by_id'
has_many :created_projects, class_name: 'Project', foreign_key: 'created_by_id'
has_many :modified_projects, class_name: 'Project', foreign_key: 'last_modified_by_id'
has_many :archived_projects, class_name: 'Project', foreign_key: 'archived_by_id'
has_many :restored_projects, class_name: 'Project', foreign_key: 'restored_by_id'
has_many :modified_reports, class_name: 'Report', foreign_key: 'last_modified_by_id'
has_many :modified_results, class_name: 'Result', foreign_key: 'modified_by_id'
has_many :archived_results, class_name: 'Result', foreign_key: 'archived_by_id'
has_many :restored_results, class_name: 'Result', foreign_key: 'restored_by_id'
has_many :created_sample_groups, class_name: 'SampleGroup', foreign_key: 'created_by_id'
has_many :modified_sample_groups, class_name: 'SampleGroup', foreign_key: 'last_modified_by_id'
has_many :assigned_sample_my_modules, class_name: 'SampleMyModule', foreign_key: 'assigned_by_id'
has_many :created_sample_types, class_name: 'SampleType', foreign_key: 'created_by_id'
has_many :modified_sample_types, class_name: 'SampleType', foreign_key: 'last_modified_by_id'
has_many :modified_samples, class_name: 'Sample', foreign_key: 'last_modified_by_id'
has_many :modified_assets,
class_name: 'Asset',
foreign_key: 'last_modified_by_id'
has_many :created_checklists,
class_name: 'Checklist',
foreign_key: 'created_by_id'
has_many :modified_checklists,
class_name: 'Checklist',
foreign_key: 'last_modified_by_id'
has_many :created_checklist_items,
class_name: 'ChecklistItem',
foreign_key: 'created_by_id'
has_many :modified_checklist_items,
class_name: 'ChecklistItem',
foreign_key: 'last_modified_by_id'
has_many :modified_comments,
class_name: 'Comment',
foreign_key: 'last_modified_by_id'
has_many :modified_custom_fields,
class_name: 'CustomField',
foreign_key: 'last_modified_by_id'
has_many :created_my_module_groups,
class_name: 'MyModuleGroup',
foreign_key: 'created_by_id'
has_many :created_my_module_tags,
class_name: 'MyModuleTag',
foreign_key: 'created_by_id'
has_many :created_my_modules,
class_name: 'MyModule',
foreign_key: 'created_by_id'
has_many :modified_my_modules,
class_name: 'MyModule',
foreign_key: 'last_modified_by_id'
has_many :archived_my_modules,
class_name: 'MyModule',
foreign_key: 'archived_by_id'
has_many :restored_my_modules,
class_name: 'MyModule',
foreign_key: 'restored_by_id'
has_many :created_teams,
class_name: 'Team',
foreign_key: 'created_by_id'
has_many :modified_teams,
class_name: 'Team',
foreign_key: 'last_modified_by_id'
has_many :created_projects,
class_name: 'Project',
foreign_key: 'created_by_id'
has_many :modified_projects,
class_name: 'Project',
foreign_key: 'last_modified_by_id'
has_many :archived_projects,
class_name: 'Project',
foreign_key: 'archived_by_id'
has_many :restored_projects,
class_name: 'Project',
foreign_key: 'restored_by_id'
has_many :modified_reports,
class_name: 'Report',
foreign_key: 'last_modified_by_id'
has_many :modified_results,
class_name: 'Result',
foreign_key: 'modified_by_id'
has_many :archived_results,
class_name: 'Result',
foreign_key: 'archived_by_id'
has_many :restored_results,
class_name: 'Result',
foreign_key: 'restored_by_id'
has_many :created_sample_groups,
class_name: 'SampleGroup',
foreign_key: 'created_by_id'
has_many :modified_sample_groups,
class_name: 'SampleGroup',
foreign_key: 'last_modified_by_id'
has_many :assigned_sample_my_modules,
class_name: 'SampleMyModule',
foreign_key: 'assigned_by_id'
has_many :created_sample_types,
class_name: 'SampleType',
foreign_key: 'created_by_id'
has_many :modified_sample_types,
class_name: 'SampleType',
foreign_key: 'last_modified_by_id'
has_many :modified_samples,
class_name: 'Sample',
foreign_key: 'last_modified_by_id'
has_many :modified_steps, class_name: 'Step', foreign_key: 'modified_by_id'
has_many :created_tables, class_name: 'Table', foreign_key: 'created_by_id'
has_many :modified_tables, class_name: 'Table', foreign_key: 'last_modified_by_id'
has_many :modified_tables,
class_name: 'Table',
foreign_key: 'last_modified_by_id'
has_many :created_tags, class_name: 'Tag', foreign_key: 'created_by_id'
has_many :modified_tags, class_name: 'Tag', foreign_key: 'last_modified_by_id'
has_many :assigned_user_my_modules, class_name: 'UserMyModule', foreign_key: 'assigned_by_id'
has_many :assigned_user_teams, class_name: 'UserTeam', foreign_key: 'assigned_by_id'
has_many :assigned_user_projects, class_name: 'UserProject', foreign_key: 'assigned_by_id'
has_many :added_protocols, class_name: 'Protocol', foreign_key: 'added_by_id', inverse_of: :added_by
has_many :archived_protocols, class_name: 'Protocol', foreign_key: 'archived_by_id', inverse_of: :archived_by
has_many :restored_protocols, class_name: 'Protocol', foreign_key: 'restored_by_id', inverse_of: :restored_by
has_many :modified_tags,
class_name: 'Tag',
foreign_key: 'last_modified_by_id'
has_many :assigned_user_my_modules,
class_name: 'UserMyModule',
foreign_key: 'assigned_by_id'
has_many :assigned_user_teams,
class_name: 'UserTeam',
foreign_key: 'assigned_by_id'
has_many :assigned_user_projects,
class_name: 'UserProject',
foreign_key: 'assigned_by_id'
has_many :added_protocols,
class_name: 'Protocol',
foreign_key: 'added_by_id',
inverse_of: :added_by
has_many :archived_protocols,
class_name: 'Protocol',
foreign_key: 'archived_by_id',
inverse_of: :archived_by
has_many :restored_protocols,
class_name: 'Protocol',
foreign_key: 'restored_by_id',
inverse_of: :restored_by
has_many :user_notifications, inverse_of: :user
has_many :notifications, through: :user_notifications
@ -166,19 +243,19 @@ class User < ActiveRecord::Base
def active_status_str
if active?
I18n.t("users.enums.status.active")
I18n.t('users.enums.status.active')
else
I18n.t("users.enums.status.pending")
I18n.t('users.enums.status.pending')
end
end
def projects_by_teams(team_id = 0, sort_by = nil, archived = false)
archived = archived ? true : false
query = Project.all.joins(:user_projects);
sql = "projects.team_id IN " +
"(SELECT DISTINCT team_id FROM user_teams WHERE user_teams.user_id = ?) " +
"AND (projects.visibility=1 OR user_projects.user_id=?) " +
"AND projects.archived = ? ";
query = Project.all.joins(:user_projects)
sql = 'projects.team_id IN (SELECT DISTINCT team_id ' \
'FROM user_teams WHERE user_teams.user_id = ?) ' \
'AND (projects.visibility=1 OR user_projects.user_id=?) ' \
'AND projects.archived = ? '
case sort_by
when "old"
@ -193,17 +270,17 @@ class User < ActiveRecord::Base
if team_id > 0
result = query
.where("projects.team_id = ?", team_id)
.where(sql, id, id, archived)
.order(sort)
.distinct
.group_by { |project| project.team }
.where('projects.team_id = ?', team_id)
.where(sql, id, id, archived)
.order(sort)
.distinct
.group_by(&:team)
else
result = query
.where(sql, id, id, archived)
.order(sort)
.distinct
.group_by { |project| project.team }
.where(sql, id, id, archived)
.order(sort)
.distinct
.group_by(&:team)
end
result || []
end

View file

@ -92,7 +92,9 @@ module FirstTimeDataGenerator
# old = team.projects.where(name: 'Demo project - qPCR')[0]
# old.archive! user
i = 1
while team.projects.where(name: name = "Demo project - qPCR (#{i})").present?
while team.projects.where(
name: name = "Demo project - qPCR (#{i})"
).present?
i += 1
end
end

View file

@ -10,7 +10,7 @@ module ProtocolsImporter
protocol_type: (type == :public ? :in_repository_public : :in_repository_private),
published_on: (type == :public ? Time.now : nil),
added_by: user,
team: @team
team: team
)
# Try to rename record

View file

@ -7,18 +7,21 @@ Rails.application.config.assets.version = '1.0'
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js application.css, and all non-JS/CSS in app/assets folder are already added.
# application.js application.css, and all non-JS/CSS
# in app/assets folder are already added.
Rails.application.config.assets.precompile += %w(underscore.js)
Rails.application.config.assets.precompile += %w(jsPlumb-2.0.4-min.js)
Rails.application.config.assets.precompile += %w(jsnetworkx.js)
Rails.application.config.assets.precompile += %w(handsontable.full.min.js)
Rails.application.config.assets.precompile += %w(users/settings/preferences.js)
Rails.application.config.assets.precompile += %w(users/settings/teams.js)
Rails.application.config.assets.precompile += %w(users/settings/teams/add_user_modal.js)
Rails.application.config.assets.precompile +=
%w(users/settings/teams/add_user_modal.js)
Rails.application.config.assets.precompile += %w(users/settings/team.js)
Rails.application.config.assets.precompile += %w(my_modules/activities.js)
Rails.application.config.assets.precompile += %w(my_modules/protocols.js)
Rails.application.config.assets.precompile += %w(my_modules/protocols/protocol_status_bar.js)
Rails.application.config.assets.precompile +=
%w(my_modules/protocols/protocol_status_bar.js)
Rails.application.config.assets.precompile += %w(my_modules/results.js)
Rails.application.config.assets.precompile += %w(results/result_tables.js)
Rails.application.config.assets.precompile += %w(results/result_assets.js)
@ -35,16 +38,20 @@ Rails.application.config.assets.precompile += %w(samples/sample_datatable.js)
Rails.application.config.assets.precompile += %w(projects/index.js)
Rails.application.config.assets.precompile += %w(samples/samples_importer.js)
Rails.application.config.assets.precompile += %w(projects/canvas.js)
Rails.application.config.assets.precompile += %w(experiments/dropdown_actions.js)
Rails.application.config.assets.precompile +=
%w(experiments/dropdown_actions.js)
Rails.application.config.assets.precompile += %w(reports/index.js)
Rails.application.config.assets.precompile += %w(reports/new.js)
Rails.application.config.assets.precompile += %w(protocols/index.js)
Rails.application.config.assets.precompile += %w(protocols/header.js)
Rails.application.config.assets.precompile += %w(protocols/steps.js)
Rails.application.config.assets.precompile += %w(protocols/edit.js)
Rails.application.config.assets.precompile += %w(protocols/import_export/eln_table.js)
Rails.application.config.assets.precompile += %w(protocols/import_export/import.js)
Rails.application.config.assets.precompile += %w(protocols/import_export/export.js)
Rails.application.config.assets.precompile +=
%w(protocols/import_export/eln_table.js)
Rails.application.config.assets.precompile +=
%w(protocols/import_export/import.js)
Rails.application.config.assets.precompile +=
%w(protocols/import_export/export.js)
Rails.application.config.assets.precompile += %w(datatables.js)
Rails.application.config.assets.precompile += %w(search/index.js)
Rails.application.config.assets.precompile += %w(navigation.js)

View file

@ -104,7 +104,7 @@ Rails.application.routes.draw do
to: 'user_notifications#index',
as: 'notifications'
resources :teams, only: [] do
resources :teams do
resources :samples, only: [:new, :create]
resources :sample_types, except: [:show, :new] do
get 'sample_type_element', to: 'sample_types#sample_type_element'