Commit f94ea25c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '902-privileges-migration-for-users' into 'master'

Resolve "Privileges migration for USERS"

Closes #902

See merge request !917
parents 07fccfd3 57e1db59
Pipeline #13303 canceled with stage
in 6 minutes and 42 seconds
......@@ -51,6 +51,8 @@ minerva (14.0.0~beta.0) unstable; urgency=low
* Bug fix: too long name for data overlay in info window is trimmed (#919)
* Bug fix: too long name in general overlay list is wrapped (#857)
* Bug fix: after genome is removed list of genomes is refreshed (#922)
* Bug fix: migrating from old minerva will grant WRITE_PROJECT privilege to
users who have manage comments or manage overlays privilege (#902)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 21 Aug 2019 21:00:00 +0200
......
......@@ -1195,8 +1195,6 @@ GuiUtils.prototype.hideTab = function (abstractGuiElement, panel) {
GuiUtils.prototype.disableTab = function (element, message) {
var hideReason = $(".minerva-hide-reason", element);
if (hideReason.length === 0) {
console.log("not hidden");
$(element).children().css("visibility", "hidden");
$("[class='minerva-help-button']", element).children().css("visibility", "visible");
var hideReasonDiv = document.createElement("div");
......
......@@ -16,11 +16,32 @@ alter table reaction_table add column product integer;
alter table reaction_table add column input_operator integer;
alter table reaction_table add column output_operator integer;
update reaction_table set reactant = (select id from reaction_node_table where node_type_db='REACTANT_NODE' and reaction_id=reaction_table.id order by id limit 1);
update reaction_table set product = (select id from reaction_node_table where node_type_db='PRODUCT_NODE' and reaction_id=reaction_table.id order by id limit 1);
--old version of computing first reactant, product, input and output operators (this version is ~100 slower than new one). This is an issue for big maps. For db with 30k reactions it toook 25minutes
--
--update reaction_table set reactant = (select id from reaction_node_table where node_type_db='REACTANT_NODE' and reaction_id=reaction_table.id order by id limit 1);
--update reaction_table set product = (select id from reaction_node_table where node_type_db='PRODUCT_NODE' and reaction_id=reaction_table.id order by id limit 1);
--update reaction_table set input_operator = (select id from reaction_node_table where node_type_db in ('AND_OPERATOR_NODE', 'ASSOCIATION_OPERATOR_NODE', 'NAND_OPERATOR_NODE', 'OR_OPERATOR_NODE', 'UNKNOWN_OPERATOR_NODE') and reaction_id=reaction_table.id order by id limit 1);
--update reaction_table set output_operator = (select id from reaction_node_table where node_type_db in ('DISSOCIATION_OPERATOR_NODE', 'SPLIT_OPERATOR_NODE', 'TRUNCATION_OPERATOR_NODE') and reaction_id=reaction_table.id order by id limit 1);
update reaction_table set input_operator = (select id from reaction_node_table where node_type_db in ('AND_OPERATOR_NODE', 'ASSOCIATION_OPERATOR_NODE', 'NAND_OPERATOR_NODE', 'OR_OPERATOR_NODE', 'UNKNOWN_OPERATOR_NODE') and reaction_id=reaction_table.id order by id limit 1);
update reaction_table set output_operator = (select id from reaction_node_table where node_type_db in ('DISSOCIATION_OPERATOR_NODE', 'SPLIT_OPERATOR_NODE', 'TRUNCATION_OPERATOR_NODE') and reaction_id=reaction_table.id order by id limit 1);
create table tmp_node (
node_id integer,
node_type_db varchar,
reaction_id integer,
CONSTRAINT tmp_fkey FOREIGN KEY (reaction_id)
REFERENCES reaction_table (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
insert into tmp_node select min(id), node_type_db, reaction_id from reaction_node_table group by node_type_db, reaction_id;
insert into tmp_node select min(id), 'INPUT_NODE', reaction_id from reaction_node_table where node_type_db in ('AND_OPERATOR_NODE', 'ASSOCIATION_OPERATOR_NODE', 'NAND_OPERATOR_NODE', 'OR_OPERATOR_NODE', 'UNKNOWN_OPERATOR_NODE') group by reaction_id;
insert into tmp_node select min(id), 'OUTPUT_NODE', reaction_id from reaction_node_table where node_type_db in ('DISSOCIATION_OPERATOR_NODE', 'SPLIT_OPERATOR_NODE', 'TRUNCATION_OPERATOR_NODE') group by reaction_id;
update reaction_table set reactant = tmp_node.node_id from tmp_node where tmp_node.reaction_id=reaction_table.id and tmp_node.node_type_db = 'REACTANT_NODE';
update reaction_table set product = tmp_node.node_id from tmp_node where tmp_node.reaction_id=reaction_table.id and tmp_node.node_type_db = 'PRODUCT_NODE';
update reaction_table set input_operator = tmp_node.node_id from tmp_node where tmp_node.reaction_id=reaction_table.id and tmp_node.node_type_db = 'INPUT_NODE';
update reaction_table set output_operator = tmp_node.node_id from tmp_node where tmp_node.reaction_id=reaction_table.id and tmp_node.node_type_db = 'OUTPUT_NODE';
drop table tmp_node;
update reaction_table set start_point = (select one_before_last_point from reaction_node_table, polyline_data_table where reaction_node_table.id = reaction_table.reactant and polyline_data_table.id = line_id);
update reaction_table set end_point = (select second_point from reaction_node_table, polyline_data_table where reaction_node_table.id = reaction_table.product and polyline_data_table.id = line_id);
......
--remove artifacts (privileges to non-existing projects)
delete from privilege_table where (type = 'VIEW_PROJECT' or type ='EDIT_COMMENTS_PROJECT') and not id_object in (select id from project_table);
delete from privilege_table where (type = 'VIEW_PROJECT' or type ='EDIT_COMMENTS_PROJECT' or type='LAYOUT_MANAGEMENT') and not id_object in (select id from project_table);
alter table privilege_table rename column id_object to object_id;
delete from privilege_table where level = 0;
......@@ -34,6 +34,12 @@ from (select user_id, object_id from privilege_table where type = 'VIEW_PROJECT'
inner join (select id, object_id from privilege_table where type = 'READ_PROJECT') s2
on s1.object_id = s2.object_id;
insert into user_privilege_map_table (user_id, privilege_id)
select s1.user_id, s2.id
from (select user_id, object_id from privilege_table where type = 'EDIT_COMMENTS_PROJECT' or type = 'LAYOUT_MANAGEMENT') s1
inner join (select id, object_id from privilege_table where type = 'WRITE_PROJECT') s2
on s1.object_id = s2.object_id;
insert into user_privilege_map_table (user_id, privilege_id)
select s1.user_id, s2.id
from (select user_id, object_id from privilege_table where type = 'VIEW_PROJECT' and user_id in (select user_id from privilege_table where type = 'ADD_MAP')) s1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment