aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-11-12 15:21:05 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-11-12 15:21:05 +0000
commitf1d7b9300fbb06495c6087f975cdbb68a894da37 (patch)
tree199e79931f14cdc581e7e04b1c8a9c04e4fa5004
parent28bbaf66df33c82abdf0f24755a570813edd1bbf (diff)
parent1c68f210bdbe231ef2d993e9bb85e543af3470f8 (diff)
Merge "Allow public marked grb and configs to be shown"
-rw-r--r--src/resource_inventory/migrations/0011_auto_20191106_2024.py33
-rw-r--r--src/resource_inventory/models.py4
-rw-r--r--src/workflow/booking_workflow.py5
3 files changed, 40 insertions, 2 deletions
diff --git a/src/resource_inventory/migrations/0011_auto_20191106_2024.py b/src/resource_inventory/migrations/0011_auto_20191106_2024.py
new file mode 100644
index 0000000..bde9f9d
--- /dev/null
+++ b/src/resource_inventory/migrations/0011_auto_20191106_2024.py
@@ -0,0 +1,33 @@
+# Generated by Django 2.2 on 2019-11-06 20:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('resource_inventory', '0010_auto_20190430_1405'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='configbundle',
+ name='hidden',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name='configbundle',
+ name='public',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name='genericresourcebundle',
+ name='hidden',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name='genericresourcebundle',
+ name='public',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index b9f2c44..031ccce 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -113,6 +113,8 @@ class GenericResourceBundle(models.Model):
owner = models.ForeignKey(User, null=True, on_delete=models.SET_NULL)
lab = models.ForeignKey(Lab, null=True, on_delete=models.SET_NULL)
description = models.CharField(max_length=1000, default="")
+ public = models.BooleanField(default=False)
+ hidden = models.BooleanField(default=False)
def getHosts(self):
return_hosts = []
@@ -241,6 +243,8 @@ class ConfigBundle(models.Model):
name = models.CharField(max_length=200, unique=True)
description = models.CharField(max_length=1000, default="")
bundle = models.ForeignKey(GenericResourceBundle, null=True, on_delete=models.CASCADE)
+ public = models.BooleanField(default=False)
+ hidden = models.BooleanField(default=False)
def __str__(self):
return self.name
diff --git a/src/workflow/booking_workflow.py b/src/workflow/booking_workflow.py
index 3698164..c96e1b9 100644
--- a/src/workflow/booking_workflow.py
+++ b/src/workflow/booking_workflow.py
@@ -15,6 +15,7 @@ from booking.models import Booking
from workflow.models import WorkflowStep, AbstractSelectOrCreate
from workflow.forms import ResourceSelectorForm, SWConfigSelectorForm, BookingMetaForm, OPNFVSelectForm
from resource_inventory.models import GenericResourceBundle, ConfigBundle, OPNFVConfig
+from django.db.models import Q
"""
@@ -43,7 +44,7 @@ class Abstract_Resource_Select(AbstractSelectOrCreate):
def get_form_queryset(self):
user = self.repo_get(self.repo.SESSION_USER)
- qs = GenericResourceBundle.objects.filter(owner=user)
+ qs = GenericResourceBundle.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True)))
return qs
def get_page_context(self):
@@ -82,7 +83,7 @@ class SWConfig_Select(AbstractSelectOrCreate):
def get_form_queryset(self):
user = self.repo_get(self.repo.SESSION_USER)
grb = self.repo_get(self.repo.SELECTED_GRESOURCE_BUNDLE)
- qs = ConfigBundle.objects.filter(owner=user).filter(bundle=grb)
+ qs = ConfigBundle.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True))).filter(bundle=grb)
return qs
def put_confirm_info(self, bundle):