def insert_publish_resources(default_owner_id): current_resources = Redis.hgetall("resources") Cursor.execute(""" SELECT PublishXRef.Id, PublishFreeze.Id, InbredSet.InbredSetCode FROM PublishXRef, PublishFreeze, InbredSet, Publication WHERE PublishFreeze.InbredSetId = PublishXRef.InbredSetId AND InbredSet.Id = PublishXRef.InbredSetId AND Publication.Id = PublishXRef.PublicationId""") resource_results = Cursor.fetchall() for resource in resource_results: if resource[2]: resource_ob = {} if resource[2]: resource_ob['name'] = resource[2] + "_" + str(resource[0]) else: resource_ob['name'] = str(resource[0]) resource_ob['owner_id'] = default_owner_id resource_ob['data'] = {"dataset": str(resource[1]), "trait": str(resource[0])} resource_ob['type'] = "dataset-publish" resource_ob['default_mask'] = {"data": "view", "metadata": "view", "admin": "not-admin"} resource_ob['group_masks'] = {} add_resource(resource_ob, update=False) else: continue
def insert_probeset_resources(default_owner_id): current_resources = Redis.hgetall("resources") Cursor.execute(""" SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.confidentiality, ProbeSetFreeze.public FROM ProbeSetFreeze""") resource_results = Cursor.fetchall() for i, resource in enumerate(resource_results): resource_ob = {} resource_ob['name'] = resource[1] resource_ob['owner_id'] = default_owner_id resource_ob['data'] = {"dataset": str(resource[0])} resource_ob['type'] = "dataset-probeset" if resource[2] < 1 and resource[3] > 0: resource_ob['default_mask'] = {"data": "view", "metadata": "view", "admin": "not-admin"} else: resource_ob['default_mask'] = {"data": "no-access", "metadata": "no-access", "admin": "not-admin"} resource_ob['group_masks'] = {} add_resource(resource_ob, update=False)
def insert_geno_resources(default_owner_id): current_resources = Redis.hgetall("resources") Cursor.execute(""" SELECT GenoFreeze.Id, GenoFreeze.ShortName, GenoFreeze.confidentiality FROM GenoFreeze""") resource_results = Cursor.fetchall() for i, resource in enumerate(resource_results): resource_ob = {} resource_ob['name'] = resource[1] if resource[1] == "HET3-ITPGeno": resource_ob['owner_id'] = "c5ce8c56-78a6-474f-bcaf-7129d97f56ae" else: resource_ob['owner_id'] = default_owner_id resource_ob['data'] = {"dataset": str(resource[0])} resource_ob['type'] = "dataset-geno" if resource[2] < 1: resource_ob['default_mask'] = {"data": "view", "metadata": "view", "admin": "not-admin"} else: resource_ob['default_mask'] = {"data": "no-access", "metadata": "no-access", "admin": "not-admin"} resource_ob['group_masks'] = {} add_resource(resource_ob, update=False)
def add_new_resource(dataset, trait_id=None): resource_ob = { 'owner_id': "none", # webqtlConfig.DEFAULT_OWNER_ID, 'default_mask': webqtlConfig.DEFAULT_PRIVILEGES, 'group_masks': {} } if dataset.type == "Publish": group_code = get_group_code(dataset) if group_code is None: group_code = "" resource_ob['name'] = group_code + "_" + str(trait_id) resource_ob['data'] = {'dataset': dataset.id, 'trait': trait_id} resource_ob['type'] = 'dataset-publish' elif dataset.type == "Geno": resource_ob['name'] = dataset.name resource_ob['data'] = {'dataset': dataset.id} resource_ob['type'] = 'dataset-geno' else: resource_ob['name'] = dataset.name resource_ob['data'] = {'dataset': dataset.id} resource_ob['type'] = 'dataset-probeset' resource_info = add_resource(resource_ob, update=False) return resource_info
def change_default_privileges(): resource_id = request.form['resource_id'] admin_status = check_owner_or_admin(resource_id=resource_id) if admin_status == "owner" or admin_status == "edit-admins": resource_info = get_resource_info(resource_id) default_mask = resource_info['default_mask'] if request.form['open_to_public'] == "True": default_mask['data'] = 'view' else: default_mask['data'] = 'no-access' resource_info['default_mask'] = default_mask add_resource(resource_info) flash("Your changes have been saved.", "alert-info") return redirect(url_for("manage_resource", resource_id=resource_id)) else: return redirect(url_for("no_access_page"))