forked from enviPath/enviPy
[Feature] Alias Support (#151)
Fixes #149 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#151
This commit is contained in:
@ -691,6 +691,7 @@ class PackageManager(object):
|
|||||||
struc.uuid = UUID(structure["id"].split("/")[-1]) if keep_ids else uuid4()
|
struc.uuid = UUID(structure["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
struc.name = structure["name"]
|
struc.name = structure["name"]
|
||||||
struc.description = structure["description"]
|
struc.description = structure["description"]
|
||||||
|
struc.aliases = structure.get("aliases", [])
|
||||||
struc.smiles = structure["smiles"]
|
struc.smiles = structure["smiles"]
|
||||||
struc.save()
|
struc.save()
|
||||||
|
|
||||||
@ -728,6 +729,7 @@ class PackageManager(object):
|
|||||||
r.package = pack
|
r.package = pack
|
||||||
r.name = rule["name"]
|
r.name = rule["name"]
|
||||||
r.description = rule["description"]
|
r.description = rule["description"]
|
||||||
|
r.aliases = rule.get("aliases", [])
|
||||||
r.smirks = rule["smirks"]
|
r.smirks = rule["smirks"]
|
||||||
r.reactant_filter_smarts = rule.get("reactantFilterSmarts", None)
|
r.reactant_filter_smarts = rule.get("reactantFilterSmarts", None)
|
||||||
r.product_filter_smarts = rule.get("productFilterSmarts", None)
|
r.product_filter_smarts = rule.get("productFilterSmarts", None)
|
||||||
@ -747,6 +749,7 @@ class PackageManager(object):
|
|||||||
r.uuid = UUID(par_rule["id"].split("/")[-1]) if keep_ids else uuid4()
|
r.uuid = UUID(par_rule["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
r.name = par_rule["name"]
|
r.name = par_rule["name"]
|
||||||
r.description = par_rule["description"]
|
r.description = par_rule["description"]
|
||||||
|
r.aliases = par_rule.get("aliases", [])
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
mapping[par_rule["id"]] = r.uuid
|
mapping[par_rule["id"]] = r.uuid
|
||||||
@ -766,6 +769,7 @@ class PackageManager(object):
|
|||||||
r.uuid = UUID(seq_rule["id"].split("/")[-1]) if keep_ids else uuid4()
|
r.uuid = UUID(seq_rule["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
r.name = seq_rule["name"]
|
r.name = seq_rule["name"]
|
||||||
r.description = seq_rule["description"]
|
r.description = seq_rule["description"]
|
||||||
|
r.aliases = seq_rule.get("aliases", [])
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
mapping[seq_rule["id"]] = r.uuid
|
mapping[seq_rule["id"]] = r.uuid
|
||||||
@ -791,6 +795,7 @@ class PackageManager(object):
|
|||||||
r.uuid = UUID(reaction["id"].split("/")[-1]) if keep_ids else uuid4()
|
r.uuid = UUID(reaction["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
r.name = reaction["name"]
|
r.name = reaction["name"]
|
||||||
r.description = reaction["description"]
|
r.description = reaction["description"]
|
||||||
|
r.aliases = reaction.get("aliases", [])
|
||||||
r.medlinereferences = (reaction["medlinereferences"],)
|
r.medlinereferences = (reaction["medlinereferences"],)
|
||||||
r.multi_step = True if reaction["multistep"] == "true" else False
|
r.multi_step = True if reaction["multistep"] == "true" else False
|
||||||
r.save()
|
r.save()
|
||||||
@ -824,6 +829,7 @@ class PackageManager(object):
|
|||||||
pw.uuid = UUID(pathway["id"].split("/")[-1]) if keep_ids else uuid4()
|
pw.uuid = UUID(pathway["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
pw.name = pathway["name"]
|
pw.name = pathway["name"]
|
||||||
pw.description = pathway["description"]
|
pw.description = pathway["description"]
|
||||||
|
pw.aliases = pathway.get("aliases", [])
|
||||||
pw.save()
|
pw.save()
|
||||||
|
|
||||||
mapping[pathway["id"]] = pw.uuid
|
mapping[pathway["id"]] = pw.uuid
|
||||||
@ -836,6 +842,8 @@ class PackageManager(object):
|
|||||||
n = Node()
|
n = Node()
|
||||||
n.uuid = UUID(node["id"].split("/")[-1]) if keep_ids else uuid4()
|
n.uuid = UUID(node["id"].split("/")[-1]) if keep_ids else uuid4()
|
||||||
n.name = node["name"]
|
n.name = node["name"]
|
||||||
|
n.description = node.get("description")
|
||||||
|
n.aliases = node.get("aliases", [])
|
||||||
n.pathway = pw
|
n.pathway = pw
|
||||||
n.depth = node["depth"]
|
n.depth = node["depth"]
|
||||||
n.default_node_label = CompoundStructure.objects.get(
|
n.default_node_label = CompoundStructure.objects.get(
|
||||||
@ -862,6 +870,7 @@ class PackageManager(object):
|
|||||||
e.name = edge["name"]
|
e.name = edge["name"]
|
||||||
e.pathway = pw
|
e.pathway = pw
|
||||||
e.description = edge["description"]
|
e.description = edge["description"]
|
||||||
|
e.aliases = edge.get("aliases", [])
|
||||||
e.edge_label = Reaction.objects.get(uuid=mapping[edge["edgeLabel"]["id"]])
|
e.edge_label = Reaction.objects.get(uuid=mapping[edge["edgeLabel"]["id"]])
|
||||||
e.save()
|
e.save()
|
||||||
|
|
||||||
|
|||||||
@ -300,6 +300,14 @@ def set_scenarios(current_user, attach_object, scenario_urls: List[str]):
|
|||||||
attach_object.set_scenarios(scens)
|
attach_object.set_scenarios(scens)
|
||||||
|
|
||||||
|
|
||||||
|
def set_aliases(current_user, attach_object, aliases: List[str]):
|
||||||
|
if aliases == [""]:
|
||||||
|
aliases = []
|
||||||
|
|
||||||
|
attach_object.aliases = aliases
|
||||||
|
attach_object.save()
|
||||||
|
|
||||||
|
|
||||||
def copy_object(current_user, target_package: "Package", source_object_url: str):
|
def copy_object(current_user, target_package: "Package", source_object_url: str):
|
||||||
# Ensures that source is readable
|
# Ensures that source is readable
|
||||||
source_package = PackageManager.get_package_by_url(current_user, source_object_url)
|
source_package = PackageManager.get_package_by_url(current_user, source_object_url)
|
||||||
@ -1160,10 +1168,19 @@ def package_compound(request, package_uuid, compound_uuid):
|
|||||||
|
|
||||||
if "selected-scenarios" in request.POST:
|
if "selected-scenarios" in request.POST:
|
||||||
selected_scenarios = request.POST.getlist("selected-scenarios")
|
selected_scenarios = request.POST.getlist("selected-scenarios")
|
||||||
|
|
||||||
set_scenarios(current_user, current_compound, selected_scenarios)
|
set_scenarios(current_user, current_compound, selected_scenarios)
|
||||||
return redirect(current_compound.url)
|
return redirect(current_compound.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_compound, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_compound.url})
|
||||||
|
|
||||||
new_compound_name = request.POST.get("compound-name", "").strip()
|
new_compound_name = request.POST.get("compound-name", "").strip()
|
||||||
new_compound_description = request.POST.get("compound-description", "").strip()
|
new_compound_description = request.POST.get("compound-description", "").strip()
|
||||||
|
|
||||||
@ -1311,6 +1328,16 @@ def package_compound_structure(request, package_uuid, compound_uuid, structure_u
|
|||||||
set_scenarios(current_user, current_structure, selected_scenarios)
|
set_scenarios(current_user, current_structure, selected_scenarios)
|
||||||
return redirect(current_structure.url)
|
return redirect(current_structure.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_structure, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_structure.url})
|
||||||
|
|
||||||
selected_database = request.POST.get("selected-database", "").strip()
|
selected_database = request.POST.get("selected-database", "").strip()
|
||||||
external_identifier = request.POST.get("identifier", "").strip()
|
external_identifier = request.POST.get("identifier", "").strip()
|
||||||
|
|
||||||
@ -1472,6 +1499,16 @@ def package_rule(request, package_uuid, rule_uuid):
|
|||||||
set_scenarios(current_user, current_rule, selected_scenarios)
|
set_scenarios(current_user, current_rule, selected_scenarios)
|
||||||
return redirect(current_rule.url)
|
return redirect(current_rule.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_rule, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_rule.url})
|
||||||
|
|
||||||
rule_name = request.POST.get("rule-name", "").strip()
|
rule_name = request.POST.get("rule-name", "").strip()
|
||||||
rule_description = request.POST.get("rule-description", "").strip()
|
rule_description = request.POST.get("rule-description", "").strip()
|
||||||
|
|
||||||
@ -1588,6 +1625,16 @@ def package_reaction(request, package_uuid, reaction_uuid):
|
|||||||
set_scenarios(current_user, current_reaction, selected_scenarios)
|
set_scenarios(current_user, current_reaction, selected_scenarios)
|
||||||
return redirect(current_reaction.url)
|
return redirect(current_reaction.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_reaction, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_reaction.url})
|
||||||
|
|
||||||
new_reaction_name = request.POST.get("reaction-name", "").strip()
|
new_reaction_name = request.POST.get("reaction-name", "").strip()
|
||||||
new_reaction_description = request.POST.get("reaction-description", "").strip()
|
new_reaction_description = request.POST.get("reaction-description", "").strip()
|
||||||
|
|
||||||
@ -1807,6 +1854,16 @@ def package_pathway(request, package_uuid, pathway_uuid):
|
|||||||
set_scenarios(current_user, current_pathway, selected_scenarios)
|
set_scenarios(current_user, current_pathway, selected_scenarios)
|
||||||
return redirect(current_pathway.url)
|
return redirect(current_pathway.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_pathway, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_pathway.url})
|
||||||
|
|
||||||
pathway_name = request.POST.get("pathway-name")
|
pathway_name = request.POST.get("pathway-name")
|
||||||
pathway_description = request.POST.get("pathway-description")
|
pathway_description = request.POST.get("pathway-description")
|
||||||
|
|
||||||
@ -1957,6 +2014,16 @@ def package_pathway_node(request, package_uuid, pathway_uuid, node_uuid):
|
|||||||
set_scenarios(current_user, current_node, selected_scenarios)
|
set_scenarios(current_user, current_node, selected_scenarios)
|
||||||
return redirect(current_node.url)
|
return redirect(current_node.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_node, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_node.url})
|
||||||
|
|
||||||
return HttpResponseBadRequest()
|
return HttpResponseBadRequest()
|
||||||
else:
|
else:
|
||||||
return HttpResponseNotAllowed(["GET", "POST"])
|
return HttpResponseNotAllowed(["GET", "POST"])
|
||||||
@ -2073,6 +2140,16 @@ def package_pathway_edge(request, package_uuid, pathway_uuid, edge_uuid):
|
|||||||
set_scenarios(current_user, current_edge, selected_scenarios)
|
set_scenarios(current_user, current_edge, selected_scenarios)
|
||||||
return redirect(current_edge.url)
|
return redirect(current_edge.url)
|
||||||
|
|
||||||
|
if "aliases" in request.POST:
|
||||||
|
aliases = request.POST.getlist("aliases")
|
||||||
|
|
||||||
|
try:
|
||||||
|
set_aliases(current_user, current_edge, aliases)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({"error": str(e)}, status=400)
|
||||||
|
|
||||||
|
return JsonResponse({"success": current_edge.url})
|
||||||
|
|
||||||
return HttpResponseBadRequest()
|
return HttpResponseBadRequest()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -3,6 +3,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#edit_compound_modal">
|
<a role="button" data-toggle="modal" data-target="#edit_compound_modal">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Edit Compound</a>
|
<i class="glyphicon glyphicon-edit"></i> Edit Compound</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#add_structure_modal">
|
<a role="button" data-toggle="modal" data-target="#add_structure_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Add Structure</a>
|
<i class="glyphicon glyphicon-plus"></i> Add Structure</a>
|
||||||
|
|||||||
@ -3,6 +3,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#edit_compound_structure_modal">
|
<a role="button" data-toggle="modal" data-target="#edit_compound_structure_modal">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Edit Compound Structure</a>
|
<i class="glyphicon glyphicon-edit"></i> Edit Compound Structure</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
{% if meta.can_edit %}
|
{% if meta.can_edit %}
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
|
|||||||
@ -3,6 +3,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#edit_node_modal">
|
<a role="button" data-toggle="modal" data-target="#edit_node_modal">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Edit Node</a>
|
<i class="glyphicon glyphicon-edit"></i> Edit Node</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
|
|||||||
@ -31,6 +31,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
{# <li>#}
|
{# <li>#}
|
||||||
{# <a class="button" data-toggle="modal" data-target="#add_pathway_edge_modal">#}
|
{# <a class="button" data-toggle="modal" data-target="#add_pathway_edge_modal">#}
|
||||||
{# <i class="glyphicon glyphicon-plus"></i> Calculate Compound Properties</a>#}
|
{# <i class="glyphicon glyphicon-plus"></i> Calculate Compound Properties</a>#}
|
||||||
|
|||||||
@ -3,6 +3,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#edit_reaction_modal">
|
<a role="button" data-toggle="modal" data-target="#edit_reaction_modal">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Edit Reaction</a>
|
<i class="glyphicon glyphicon-edit"></i> Edit Reaction</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
|
|||||||
@ -3,6 +3,10 @@
|
|||||||
<a role="button" data-toggle="modal" data-target="#edit_rule_modal">
|
<a role="button" data-toggle="modal" data-target="#edit_rule_modal">
|
||||||
<i class="glyphicon glyphicon-edit"></i> Edit Rule</a>
|
<i class="glyphicon glyphicon-edit"></i> Edit Rule</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a role="button" data-toggle="modal" data-target="#set_aliases_modal">
|
||||||
|
<i class="glyphicon glyphicon-plus"></i> Set Aliases</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
<a role="button" data-toggle="modal" data-target="#set_scenario_modal">
|
||||||
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
<i class="glyphicon glyphicon-plus"></i> Set Scenarios</a>
|
||||||
|
|||||||
@ -15,12 +15,12 @@
|
|||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<p>
|
<p>
|
||||||
<label class="btn btn-primary" for="jsonFile">
|
<label class="btn btn-primary" for="legacyJsonFile">
|
||||||
<input id="jsonFile" name="file" type="file" style="display:none;"
|
<input id="legacyJsonFile" name="file" type="file" style="display:none;"
|
||||||
onchange="$('#upload-file-info').html(this.files[0].name)">
|
onchange="$('#upload-legacy-file-info').html(this.files[0].name)">
|
||||||
Choose JSON File
|
Choose JSON File
|
||||||
</label>
|
</label>
|
||||||
<span class="label label-info" id="upload-file-info"></span>
|
<span class="label label-info" id="upload-legacy-file-info"></span>
|
||||||
<input type="hidden" value="import-legacy-package-json" name="hidden" readonly="">
|
<input type="hidden" value="import-legacy-package-json" name="hidden" readonly="">
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
169
templates/modals/objects/generic_set_aliases_modal.html
Normal file
169
templates/modals/objects/generic_set_aliases_modal.html
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.alias-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px 6px;
|
||||||
|
cursor: text;
|
||||||
|
min-height: 38px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alias {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #5bc0de;
|
||||||
|
color: white;
|
||||||
|
padding: 4px 8px;
|
||||||
|
margin: 3px 3px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alias .remove {
|
||||||
|
margin-left: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alias-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 120px;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
margin: 3px 3px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control.alias-container {
|
||||||
|
height: auto;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="modal fade bs-modal-lg" id="set_aliases_modal" tabindex="-1" aria-labelledby="set_aliases_modal"
|
||||||
|
aria-modal="true" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title">Set Aliases for {{ current_object.name }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form id="set_aliases_modal_form" accept-charset="UTF-8" action="{{ current_object.url }}"
|
||||||
|
data-remote="true" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<label for="alias-input">Aliases:</label>
|
||||||
|
<div class="form-control alias-container" id="alias-box">
|
||||||
|
{% for alias in current_object.aliases %}
|
||||||
|
<span class="alias">{{ alias|escape }}<span class="remove">×</span></span>
|
||||||
|
{% endfor %}
|
||||||
|
<input type="text" id="alias-input" class="alias-input" placeholder="Add Alias...">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="add-alias-error-message" class="alert alert-danger" role="alert" style="display: none">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary pull-left" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="set_aliases_modal_form_submit">Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
function addAlias(aliasText) {
|
||||||
|
aliasText = aliasText.trim();
|
||||||
|
if (aliasText === '') return;
|
||||||
|
|
||||||
|
// Avoid duplicate aliass
|
||||||
|
var exists = false;
|
||||||
|
$('#alias-box .alias').each(function () {
|
||||||
|
if ($(this).text().replace('×', '').trim().toLowerCase() === aliasText.toLowerCase()) {
|
||||||
|
exists = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
var aliasHtml = '<span class="alias">' + $('<div>').text(aliasText).html() +
|
||||||
|
'<span class="remove">×</span></span>';
|
||||||
|
$(aliasHtml).insertBefore('#alias-input');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#alias-input').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add alias when Enter is pressed
|
||||||
|
$('#alias-input').on('keypress', function (e) {
|
||||||
|
if (e.which === 13) {
|
||||||
|
e.preventDefault();
|
||||||
|
addAlias($(this).val());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add alias when input loses focus
|
||||||
|
$('#alias-input').on('blur', function () {
|
||||||
|
var val = $(this).val();
|
||||||
|
if (val.trim() !== '') {
|
||||||
|
addAlias(val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove alias when clicking ×
|
||||||
|
$('#alias-box').on('click', '.remove', function () {
|
||||||
|
$(this).closest('.alias').remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Focus input when clicking the container
|
||||||
|
$('#alias-box').on('click', function () {
|
||||||
|
$('#alias-input').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#set_aliases_modal_form_submit').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let aliases = [];
|
||||||
|
$('#alias-box .alias').each(function () {
|
||||||
|
aliases.push($(this).text().replace('×', '').trim())
|
||||||
|
});
|
||||||
|
|
||||||
|
if (aliases.length === 0) {
|
||||||
|
// Set empty string for deletion of all aliases
|
||||||
|
// If empty list is sent, its gets removed entirely from post data
|
||||||
|
aliases = ['']
|
||||||
|
}
|
||||||
|
|
||||||
|
formData = {
|
||||||
|
'aliases': aliases
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
data: formData,
|
||||||
|
url: '{{ current_object.url }}',
|
||||||
|
traditional: true,
|
||||||
|
success: function (data, textStatus) {
|
||||||
|
window.location.href = data.success;
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
$('#add-alias-error-message').append('<p>Setting aliases failed!</p>');
|
||||||
|
$('#add-alias-error-message').show(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@ -64,8 +64,8 @@
|
|||||||
|
|
||||||
$('#set_scenario_modal_form_submit').on('click', function (e) {
|
$('#set_scenario_modal_form_submit').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($('##scenario-select').val().length == 0) {
|
if ($('#scenario-select').val().length == 0) {
|
||||||
$('##scenario-select').val([''])
|
$('#scenario-select').val([''])
|
||||||
}
|
}
|
||||||
$('#set_scenario_modal_form').submit();
|
$('#set_scenario_modal_form').submit();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_rule_modal.html" %}
|
{% include "modals/objects/edit_rule_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_copy_object_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_delete_modal.html" %}
|
{% include "modals/objects/generic_copy_object_modal.html" %}
|
||||||
{% endblock action_modals %}
|
{% include "modals/objects/generic_delete_modal.html" %}
|
||||||
|
{% endblock action_modals %}
|
||||||
|
|
||||||
<div class="panel-group" id="rule-detail">
|
<div class="panel-group" id="rule-detail">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
@ -32,6 +33,23 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if rule.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="rule-aliases-link" data-toggle="collapse" data-parent="#rule-detail"
|
||||||
|
href="#rule-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="rule-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in rule.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Reaction Patterns -->
|
<!-- Reaction Patterns -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_compound_modal.html" %}
|
{% include "modals/objects/edit_compound_modal.html" %}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/add_structure_modal.html" %}
|
{% include "modals/objects/add_structure_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
||||||
@ -37,6 +38,23 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if compound.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="compound-aliases-link" data-toggle="collapse" data-parent="#compound-detail"
|
||||||
|
href="#compound-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="compound-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in compound.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Description -->
|
<!-- Description -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_compound_structure_modal.html" %}
|
{% include "modals/objects/edit_compound_structure_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_delete_modal.html" %}
|
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
||||||
{% endblock action_modals %}
|
{% include "modals/objects/generic_delete_modal.html" %}
|
||||||
|
{% endblock action_modals %}
|
||||||
|
|
||||||
<div class="panel-group" id="compound-structure-detail">
|
<div class="panel-group" id="compound-structure-detail">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
@ -33,34 +34,52 @@
|
|||||||
<!-- Image -->
|
<!-- Image -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a id="compound-image-link" data-toggle="collapse" data-parent="#compound-detail"
|
<a id="compound-structure-image-link" data-toggle="collapse" data-parent="#compound-structure-detail"
|
||||||
href="#compound-image">Image Representation</a>
|
href="#compound-structure-image">Image Representation</a>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="compound-image" class="panel-collapse collapse in">
|
<div id="compound-structure-image" class="panel-collapse collapse in">
|
||||||
<div class="panel-body list-group-item">
|
<div class="panel-body list-group-item">
|
||||||
<div id="image-div" align="center">
|
<div id="image-div" align="center">
|
||||||
{{ compound_structure.as_svg|safe }}
|
{{ compound_structure.as_svg|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- SMILES -->
|
<!-- SMILES -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a id="compound-smiles-link" data-toggle="collapse" data-parent="#compound-detail"
|
<a id="compound-structure-smiles-link" data-toggle="collapse" data-parent="#compound-structure-detail"
|
||||||
href="#compound-smiles">SMILES Representation</a>
|
href="#compound-structure-smiles">SMILES Representation</a>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="compound-smiles" class="panel-collapse collapse in">
|
<div id="compound-structure-smiles" class="panel-collapse collapse in">
|
||||||
<div class="panel-body list-group-item">
|
<div class="panel-body list-group-item">
|
||||||
{{ compound_structure.smiles }}
|
{{ compound_structure.smiles }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if compound_structure.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="compound-structure-aliases-link" data-toggle="collapse" data-parent="#compound-structure-detail"
|
||||||
|
href="#compound-structure-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="compound-structure-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in compound_structure.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if compound_structure.scenarios.all %}
|
{% if compound_structure.scenarios.all %}
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a id="compound_structure-scenario-link" data-toggle="collapse" data-parent="#compound-structure-detail"
|
<a id="compound-structure-scenario-link" data-toggle="collapse" data-parent="#compound-structure-detail"
|
||||||
href="#compound-structure-scenario">Scenarios</a>
|
href="#compound-structure-scenario">Scenarios</a>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{# {% include "modals/objects/edit_edge_modal.html" %}#}
|
{# {% include "modals/objects/edit_edge_modal.html" %}#}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_delete_modal.html" %}
|
{% include "modals/objects/generic_delete_modal.html" %}
|
||||||
{% endblock action_modals %}
|
{% endblock action_modals %}
|
||||||
@ -39,6 +40,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if edge.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="edge-aliases-link" data-toggle="collapse" data-parent="#edge-detail"
|
||||||
|
href="#edge-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="edge-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in edge.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Image -->
|
<!-- Image -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_node_modal.html" %}
|
{% include "modals/objects/edit_node_modal.html" %}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_delete_modal.html" %}
|
{% include "modals/objects/generic_delete_modal.html" %}
|
||||||
{% endblock action_modals %}
|
{% endblock action_modals %}
|
||||||
@ -42,6 +43,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if node.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="node-aliases-link" data-toggle="collapse" data-parent="#node-detail"
|
||||||
|
href="#node-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="node-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in node.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Image -->
|
<!-- Image -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -85,6 +85,7 @@
|
|||||||
{% include "modals/objects/download_pathway_image_modal.html" %}
|
{% include "modals/objects/download_pathway_image_modal.html" %}
|
||||||
{% include "modals/objects/generic_copy_object_modal.html" %}
|
{% include "modals/objects/generic_copy_object_modal.html" %}
|
||||||
{% include "modals/objects/edit_pathway_modal.html" %}
|
{% include "modals/objects/edit_pathway_modal.html" %}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/delete_pathway_node_modal.html" %}
|
{% include "modals/objects/delete_pathway_node_modal.html" %}
|
||||||
{% include "modals/objects/delete_pathway_edge_modal.html" %}
|
{% include "modals/objects/delete_pathway_edge_modal.html" %}
|
||||||
@ -210,6 +211,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if pathway.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="pathway-aliases-link" data-toggle="collapse" data-parent="#pathway-detail"
|
||||||
|
href="#pathway-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="pathway-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in pathway.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if pathway.scenarios.all %}
|
{% if pathway.scenarios.all %}
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_reaction_modal.html" %}
|
{% include "modals/objects/edit_reaction_modal.html" %}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_copy_object_modal.html" %}
|
{% include "modals/objects/generic_copy_object_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
{% include "modals/objects/generic_set_external_reference_modal.html" %}
|
||||||
@ -41,6 +42,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if reaction.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="reaction-aliases-link" data-toggle="collapse" data-parent="#reaction-detail"
|
||||||
|
href="#reaction-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="reaction-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in reaction.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Image -->
|
<!-- Image -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% block action_modals %}
|
{% block action_modals %}
|
||||||
{% include "modals/objects/edit_rule_modal.html" %}
|
{% include "modals/objects/edit_rule_modal.html" %}
|
||||||
|
{% include "modals/objects/generic_set_aliases_modal.html" %}
|
||||||
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
{% include "modals/objects/generic_set_scenario_modal.html" %}
|
||||||
{% include "modals/objects/generic_copy_object_modal.html" %}
|
{% include "modals/objects/generic_copy_object_modal.html" %}
|
||||||
{% include "modals/objects/generic_delete_modal.html" %}
|
{% include "modals/objects/generic_delete_modal.html" %}
|
||||||
@ -32,6 +33,23 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if rule.aliases %}
|
||||||
|
<!-- Aliases -->
|
||||||
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a id="rule-aliases-link" data-toggle="collapse" data-parent="#rule-detail"
|
||||||
|
href="#rule-aliases">Aliases</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="rule-aliases" class="panel-collapse collapse in">
|
||||||
|
<div class="panel-body list-group-item">
|
||||||
|
{% for alias in rule.aliases %}
|
||||||
|
<a class="list-group-item">{{ alias }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Representation -->
|
<!-- Representation -->
|
||||||
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
<div class="panel panel-default panel-heading list-group-item" style="background-color:silver">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
|
|||||||
@ -74,6 +74,7 @@ class MultiGenTest(TestCase):
|
|||||||
|
|
||||||
shallow_pathway = graph_from_pathway(SPathway.from_pathway(pathway))
|
shallow_pathway = graph_from_pathway(SPathway.from_pathway(pathway))
|
||||||
pathway = graph_from_pathway(pathway)
|
pathway = graph_from_pathway(pathway)
|
||||||
|
|
||||||
if not graphs_equal(shallow_pathway, pathway):
|
if not graphs_equal(shallow_pathway, pathway):
|
||||||
print("\n\nS", shallow_pathway.adj)
|
print("\n\nS", shallow_pathway.adj)
|
||||||
print("\n\nPW", pathway.adj)
|
print("\n\nPW", pathway.adj)
|
||||||
|
|||||||
@ -340,3 +340,57 @@ class CompoundViewTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(self.user1_default_package.compounds.count(), 0)
|
self.assertEqual(self.user1_default_package.compounds.count(), 0)
|
||||||
|
|
||||||
|
def test_set_aliases(self):
|
||||||
|
alias_1 = "Alias 1"
|
||||||
|
alias_2 = "Alias 2"
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("compounds"),
|
||||||
|
{
|
||||||
|
"compound-name": "1,2-Dichloroethane",
|
||||||
|
"compound-description": "Eawag BBD compound c0001",
|
||||||
|
"compound-smiles": "C(CCl)Cl",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
compound_url = response.url
|
||||||
|
|
||||||
|
c = Compound.objects.get(url=compound_url)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package compound detail",
|
||||||
|
kwargs={"package_uuid": str(c.package.uuid), "compound_uuid": str(c.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1, alias_2]},
|
||||||
|
)
|
||||||
|
|
||||||
|
c = Compound.objects.get(url=compound_url)
|
||||||
|
self.assertEqual(len(c.aliases), 2)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package compound detail",
|
||||||
|
kwargs={"package_uuid": str(c.package.uuid), "compound_uuid": str(c.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1]},
|
||||||
|
)
|
||||||
|
|
||||||
|
c = Compound.objects.get(url=compound_url)
|
||||||
|
self.assertEqual(len(c.aliases), 1)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package compound detail",
|
||||||
|
kwargs={"package_uuid": str(c.package.uuid), "compound_uuid": str(c.uuid)},
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# We have to set an empty string to avoid that the parameter is removed
|
||||||
|
"aliases": ""
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
c = Compound.objects.get(url=compound_url)
|
||||||
|
self.assertEqual(len(c.aliases), 0)
|
||||||
|
|||||||
@ -112,3 +112,57 @@ class PathwayViewTest(TestCase):
|
|||||||
predicted_nodes.add(n.default_node_label.smiles)
|
predicted_nodes.add(n.default_node_label.smiles)
|
||||||
|
|
||||||
self.assertEqual(first_level_nodes, predicted_nodes)
|
self.assertEqual(first_level_nodes, predicted_nodes)
|
||||||
|
|
||||||
|
def test_set_aliases(self):
|
||||||
|
alias_1 = "Alias 1"
|
||||||
|
alias_2 = "Alias 2"
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("package pathway list", kwargs={"package_uuid": str(self.package.uuid)}),
|
||||||
|
{
|
||||||
|
"name": "Test Pathway",
|
||||||
|
"description": "Just a Description",
|
||||||
|
"predict": "predict",
|
||||||
|
"smiles": "CCN(CC)C(=O)C1=CC(=CC=C1)CO",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
pathway_url = response.url
|
||||||
|
pw = Pathway.objects.get(url=pathway_url)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package pathway detail",
|
||||||
|
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1, alias_2]},
|
||||||
|
)
|
||||||
|
|
||||||
|
pw = Pathway.objects.get(url=pathway_url)
|
||||||
|
self.assertEqual(len(pw.aliases), 2)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package pathway detail",
|
||||||
|
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1]},
|
||||||
|
)
|
||||||
|
|
||||||
|
pw = Pathway.objects.get(url=pathway_url)
|
||||||
|
self.assertEqual(len(pw.aliases), 1)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package pathway detail",
|
||||||
|
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# We have to set an empty string to avoid that the parameter is removed
|
||||||
|
"aliases": ""
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
pw = Pathway.objects.get(url=pathway_url)
|
||||||
|
self.assertEqual(len(pw.aliases), 0)
|
||||||
|
|||||||
@ -335,3 +335,56 @@ class ReactionViewTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(self.user1_default_package.reactions.count(), 0)
|
self.assertEqual(self.user1_default_package.reactions.count(), 0)
|
||||||
|
|
||||||
|
def test_set_aliases(self):
|
||||||
|
alias_1 = "Alias 1"
|
||||||
|
alias_2 = "Alias 2"
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("reactions"),
|
||||||
|
{
|
||||||
|
"reaction-name": "Eawag BBD reaction r0001",
|
||||||
|
"reaction-description": "Description for Eawag BBD reaction r0001",
|
||||||
|
"reaction-smirks": "C(CCl)Cl>>C(CO)Cl",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
reaction_url = response.url
|
||||||
|
r = Reaction.objects.get(url=reaction_url)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package reaction detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "reaction_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1, alias_2]},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Reaction.objects.get(url=reaction_url)
|
||||||
|
self.assertEqual(len(r.aliases), 2)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package reaction detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "reaction_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1]},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Reaction.objects.get(url=reaction_url)
|
||||||
|
self.assertEqual(len(r.aliases), 1)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package reaction detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "reaction_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# We have to set an empty string to avoid that the parameter is removed
|
||||||
|
"aliases": ""
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Reaction.objects.get(url=reaction_url)
|
||||||
|
self.assertEqual(len(r.aliases), 0)
|
||||||
|
|||||||
@ -258,3 +258,57 @@ class RuleViewTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(self.user1_default_package.rules.count(), 0)
|
self.assertEqual(self.user1_default_package.rules.count(), 0)
|
||||||
|
|
||||||
|
def test_set_aliases(self):
|
||||||
|
alias_1 = "Alias 1"
|
||||||
|
alias_2 = "Alias 2"
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("rules"),
|
||||||
|
{
|
||||||
|
"rule-name": "Test Rule",
|
||||||
|
"rule-description": "Just a Description",
|
||||||
|
"rule-smirks": "[H:5][C:1]([#6:6])([#1,#9,#17,#35,#53:4])[#9,#17,#35,#53]>>[H:5][C:1]([#6:6])([#8])[#1,#9,#17,#35,#53:4]",
|
||||||
|
"rule-type": "SimpleAmbitRule",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
rule_url = response.url
|
||||||
|
r = Rule.objects.get(url=rule_url)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package rule detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "rule_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1, alias_2]},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Rule.objects.get(url=rule_url)
|
||||||
|
self.assertEqual(len(r.aliases), 2)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package rule detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "rule_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{"aliases": [alias_1]},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Rule.objects.get(url=rule_url)
|
||||||
|
self.assertEqual(len(r.aliases), 1)
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse(
|
||||||
|
"package rule detail",
|
||||||
|
kwargs={"package_uuid": str(r.package.uuid), "rule_uuid": str(r.uuid)},
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# We have to set an empty string to avoid that the parameter is removed
|
||||||
|
"aliases": ""
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
r = Rule.objects.get(url=rule_url)
|
||||||
|
self.assertEqual(len(r.aliases), 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user