forked from enviPath/enviPy
[Feature] Leftovers after Release (#303)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#303
This commit is contained in:
@ -72,6 +72,7 @@ class User(AbstractUser):
|
||||
null=True,
|
||||
blank=False,
|
||||
)
|
||||
is_reviewer = models.BooleanField(default=False)
|
||||
|
||||
USERNAME_FIELD = "email"
|
||||
REQUIRED_FIELDS = ["username"]
|
||||
@ -1828,8 +1829,8 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
queue.append(prod)
|
||||
|
||||
# We shouldn't lose or make up nodes...
|
||||
assert len(nodes) == len(self.nodes)
|
||||
logger.debug(f"{self.name}: Num Nodes {len(nodes)} vs. DB Nodes {len(self.nodes)}")
|
||||
if len(nodes) != len(self.nodes):
|
||||
logger.debug(f"{self.name}: Num Nodes {len(nodes)} vs. DB Nodes {len(self.nodes)}")
|
||||
|
||||
links = [e.d3_json() for e in self.edges]
|
||||
|
||||
@ -1880,6 +1881,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
"source": pseudo_idx,
|
||||
"target": node_url_to_idx[target],
|
||||
"app_domain": link.get("app_domain", None),
|
||||
"multi_step": link["multi_step"],
|
||||
}
|
||||
adjusted_links.append(new_link)
|
||||
|
||||
@ -2146,6 +2148,7 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
@transaction.atomic
|
||||
def create(
|
||||
pathway: "Pathway",
|
||||
smiles: str,
|
||||
@ -2185,8 +2188,11 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
if data:
|
||||
rule_ids = defaultdict(list)
|
||||
for e in Edge.objects.filter(start_nodes__in=[self]):
|
||||
for r in e.edge_label.rules.all():
|
||||
rule_ids[str(r.uuid)].append(e.simple_json())
|
||||
# TODO While the Pathway is being predicted we sometimes
|
||||
# TODO receive 'NoneType' object has no attribute 'rules'
|
||||
if e.edge_label:
|
||||
for r in e.edge_label.rules.all():
|
||||
rule_ids[str(r.uuid)].append(e.simple_json())
|
||||
|
||||
for t in data["assessment"]["transformations"]:
|
||||
if t["rule"]["uuid"] in rule_ids:
|
||||
@ -2230,6 +2236,7 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
"reaction": {"name": self.edge_label.name, "url": self.edge_label.url}
|
||||
if self.edge_label
|
||||
else None,
|
||||
"multi_step": self.edge_label.multi_step if self.edge_label else False,
|
||||
"reaction_probability": self.kv.get("probability"),
|
||||
"start_node_urls": [x.url for x in self.start_nodes.all()],
|
||||
"end_node_urls": [x.url for x in self.end_nodes.all()],
|
||||
@ -2270,6 +2277,7 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin):
|
||||
return edge_json
|
||||
|
||||
@staticmethod
|
||||
@transaction.atomic
|
||||
def create(
|
||||
pathway,
|
||||
start_nodes: List[Node],
|
||||
@ -3819,6 +3827,11 @@ class Scenario(EnviPathModel):
|
||||
|
||||
yield inst
|
||||
|
||||
def related_pathways(self):
|
||||
return Pathway.objects.filter(
|
||||
scenarios__in=[self], package__reviewed=True, package=self.package
|
||||
).distinct()
|
||||
|
||||
|
||||
class UserSettingPermission(Permission):
|
||||
uuid = models.UUIDField(
|
||||
|
||||
Reference in New Issue
Block a user