diff options
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb index 1fd51a779..2b7866d9f 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -252,6 +252,14 @@ class Referential < ActiveRecord::Base before_destroy :destroy_schema before_destroy :destroy_jobs + def referential_read_only? + in_referential_suite? || archived? + end + + def in_referential_suite? + referential_suite_id.present? + end + def in_workbench? workbench_id.present? end @@ -315,7 +323,7 @@ class Referential < ActiveRecord::Base query = "select distinct(public.referential_metadata.referential_id) FROM public.referential_metadata, unnest(line_ids) line, LATERAL unnest(periodes) period WHERE public.referential_metadata.referential_id - IN (SELECT public.referentials.id FROM public.referentials WHERE referentials.workbench_id = #{workbench_id} and referentials.archived_at is null #{not_myself}) + IN (SELECT public.referentials.id FROM public.referentials WHERE referentials.workbench_id = #{workbench_id} and referentials.archived_at is null and referentials.referential_suite_id is null #{not_myself}) AND line in (#{line_ids.join(',')}) and (#{periods_query});" self.class.connection.select_values(query).map(&:to_i) @@ -334,9 +342,6 @@ class Referential < ActiveRecord::Base end end - def in_referential_suite? - referential_suite_id.present? - end attr_accessor :inline_clone def clone_schema @@ -456,7 +461,7 @@ class Referential < ActiveRecord::Base # No explicit unlock is needed as it will be released at the end of the # transaction. ActiveRecord::Base.connection.execute( - 'LOCK referentials IN ACCESS EXCLUSIVE MODE' + 'LOCK public.referentials IN ACCESS EXCLUSIVE MODE' ) end end |
