Browse Source

Fix creating machine check, adding profile to check

master
Joshua Rubingh 6 months ago
parent
commit
ba2cdd58e2
  1. 8
      VRE/apps/vre_apps/signals.py

8
VRE/apps/vre_apps/signals.py

@ -19,9 +19,13 @@ def create_VRE_app(sender, instance, created, **kwargs): @@ -19,9 +19,13 @@ def create_VRE_app(sender, instance, created, **kwargs):
created (bool): Is it a create or update action
"""
# check if the current researcher does have enough rights and does not have already a virtual machine
if created and instance.contributor.role in [StudyRoleNames.ADMIN, StudyRoleNames.CONTRIBUTOR] and VirtualMachine.objects.filter(researcher=instance.contributor.researcher, study=instance.contributor.study).count() == 0:
# Create a new virtual machine on premium profile
if created and \
instance.contributor.role in [StudyRoleNames.ADMIN, StudyRoleNames.CONTRIBUTOR] and \
VirtualMachine.objects.filter(researcher=instance.contributor.researcher,
study=instance.contributor.study,
profile=instance.version.content_object).count() == 0:
# Create a new virtual machine
virtual_machine = VirtualMachine.objects.create(
name=f'VM of {instance.contributor.researcher.display_name} for study {instance.contributor.study.name}',
researcher=instance.contributor.researcher,

Loading…
Cancel
Save