Browse Source

Add logo to virtual machine profiles

master
Joshua Rubingh 8 months ago
parent
commit
a2fbdc708f
  1. 2
      .gitignore
  2. 3
      VRE/apps/virtual_machine/models.py
  3. 2
      VRE/lib/utils/general.py

2
.gitignore vendored

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
clouds.yaml
doc/_build/
doc/output/
.vscode/settings.json
.vscode/
# ---> Python
# Byte-compiled / optimized / DLL files

3
VRE/apps/virtual_machine/models.py

@ -12,6 +12,7 @@ from apps.study.models import Study @@ -12,6 +12,7 @@ from apps.study.models import Study
from math import pow
from lib.models.cloud import CloudBasicDataModel
from lib.utils.general import file_upload_to
# Create your models here.
@ -185,6 +186,8 @@ class VirtualMachineProfile(MetaDataModel, VirtualMachinePart): @@ -185,6 +186,8 @@ class VirtualMachineProfile(MetaDataModel, VirtualMachinePart):
name = models.CharField(max_length=50, help_text=_('Easy to remember name for this virtual machine profile.'))
logo = models.ImageField(_('Logo'), upload_to=file_upload_to, blank=True, null=True)
os = models.ForeignKey(VirtualMachineOperatingSystem, on_delete=models.CASCADE, limit_choices_to={'is_available': True}, help_text=_('Operating system'))
networks = models.ManyToManyField(VirtualMachineNetwork, blank=True, help_text=_('Select the networks that should be connected.'))

2
VRE/lib/utils/general.py

@ -44,6 +44,6 @@ def file_upload_to(model, filename): @@ -44,6 +44,6 @@ def file_upload_to(model, filename):
# Else use a general term
prefix = 'files'
id = model.pk if model.pk is not None else 'unknown'
id = f'general' if model.pk is None else model.pk
return f'{prefix}/{id}/{now:%Y%m%d%H%M%S}{extension}'

Loading…
Cancel
Save