forked from enviPath/enviPy
wip
This commit is contained in:
@@ -581,6 +581,9 @@ class PackageManager(object):
|
|||||||
if caller_perm != Permission.ALL[0] and not caller.is_superuser:
|
if caller_perm != Permission.ALL[0] and not caller.is_superuser:
|
||||||
raise ValueError("Only owner are allowed to modify permissions")
|
raise ValueError("Only owner are allowed to modify permissions")
|
||||||
|
|
||||||
|
if isinstance(grantee, Group) and package.classification_level == package.Classification.SECRET:
|
||||||
|
raise ValueError("Cannot grant permissions to a Group on a secret package")
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"package": package,
|
"package": package,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2456,6 +2456,20 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
|||||||
else:
|
else:
|
||||||
return self.default_node_label.name
|
return self.default_node_label.name
|
||||||
|
|
||||||
|
def get_description(self, include_suffix=True):
|
||||||
|
default_desc = False
|
||||||
|
|
||||||
|
if self.description == "no description":
|
||||||
|
default_desc = True
|
||||||
|
|
||||||
|
if not default_desc:
|
||||||
|
return self.description
|
||||||
|
else:
|
||||||
|
if include_suffix:
|
||||||
|
return f"{self.default_node_label.description} (taken from underlying structure)"
|
||||||
|
else:
|
||||||
|
return self.default_node_label.description
|
||||||
|
|
||||||
def d3_json(self):
|
def d3_json(self):
|
||||||
app_domain_data = self.get_app_domain_assessment_data()
|
app_domain_data = self.get_app_domain_assessment_data()
|
||||||
|
|
||||||
@@ -2773,6 +2787,20 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
|||||||
else:
|
else:
|
||||||
return self.edge_label.name
|
return self.edge_label.name
|
||||||
|
|
||||||
|
def get_description(self, include_suffix=True):
|
||||||
|
default_desc = False
|
||||||
|
|
||||||
|
if self.description == "no description":
|
||||||
|
default_desc = True
|
||||||
|
|
||||||
|
if not default_desc:
|
||||||
|
return self.description
|
||||||
|
else:
|
||||||
|
if include_suffix:
|
||||||
|
return f"{self.edge_label.description} (taken from underlying reaction)"
|
||||||
|
else:
|
||||||
|
return self.edge_label.description
|
||||||
|
|
||||||
|
|
||||||
class EPModel(PolymorphicModel, EnviPathModel, AdditionalInformationMixin):
|
class EPModel(PolymorphicModel, EnviPathModel, AdditionalInformationMixin):
|
||||||
package = models.ForeignKey(
|
package = models.ForeignKey(
|
||||||
|
|||||||
+12
-1
@@ -1292,7 +1292,7 @@ def package(request, package_uuid):
|
|||||||
"user_id", flat=True
|
"user_id", flat=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
users = users.filter(is_active=True)
|
users = users.filter(is_active=True).exclude(username="anonymous")
|
||||||
|
|
||||||
group_perms = GroupPackagePermission.objects.filter(package=current_package)
|
group_perms = GroupPackagePermission.objects.filter(package=current_package)
|
||||||
groups = Group.objects.exclude(
|
groups = Group.objects.exclude(
|
||||||
@@ -1324,6 +1324,12 @@ def package(request, package_uuid):
|
|||||||
|
|
||||||
return redirect(s.SERVER_URL + "/package")
|
return redirect(s.SERVER_URL + "/package")
|
||||||
elif hidden == "publish-package":
|
elif hidden == "publish-package":
|
||||||
|
if current_package.classification_level == current_package.Classification.SECRET:
|
||||||
|
return error(
|
||||||
|
request,
|
||||||
|
"Cannot publish a secret package",
|
||||||
|
"You cannot publish a secret package.",
|
||||||
|
)
|
||||||
for g in Group.objects.filter(public=True):
|
for g in Group.objects.filter(public=True):
|
||||||
PackageManager.grant_read(current_user, current_package, g)
|
PackageManager.grant_read(current_user, current_package, g)
|
||||||
return redirect(current_package.url)
|
return redirect(current_package.url)
|
||||||
@@ -3314,6 +3320,11 @@ def jobs(request):
|
|||||||
"This Package was generated automatically for the batch prediction task.",
|
"This Package was generated automatically for the batch prediction task.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if current_user.default_package.classification_level == current_user.default_package.Classification.SECRET:
|
||||||
|
target_package.classification_level = current_user.default_package.Classification.SECRET
|
||||||
|
target_package.data_pool = current_user.default_package.data_pool
|
||||||
|
target_package.save()
|
||||||
|
|
||||||
from .tasks import batch_predict, dispatch
|
from .tasks import batch_predict, dispatch
|
||||||
|
|
||||||
res = dispatch(
|
res = dispatch(
|
||||||
|
|||||||
Reference in New Issue
Block a user