aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/account/forms.py5
-rw-r--r--src/account/migrations/0007_userprofile_pulic_user.py18
-rw-r--r--src/account/migrations/0008_auto_20210324_2106.py18
-rw-r--r--src/account/migrations/0009_auto_20210324_2107.py18
-rw-r--r--src/account/models.py2
-rw-r--r--src/account/views.py2
-rw-r--r--src/booking/forms.py14
-rw-r--r--src/booking/lib.py2
-rw-r--r--src/dashboard/admin_utils.py2
-rw-r--r--src/static/js/dashboard.js12
10 files changed, 83 insertions, 10 deletions
diff --git a/src/account/forms.py b/src/account/forms.py
index dd1a0a9..28cb27d 100644
--- a/src/account/forms.py
+++ b/src/account/forms.py
@@ -18,11 +18,12 @@ from account.models import UserProfile
class AccountSettingsForm(forms.ModelForm):
class Meta:
model = UserProfile
- fields = ['company', 'email_addr', 'ssh_public_key', 'pgp_public_key', 'timezone']
+ fields = ['company', 'email_addr', 'public_user', 'ssh_public_key', 'pgp_public_key', 'timezone']
labels = {
'email_addr': _('Email Address'),
'ssh_public_key': _('SSH Public Key'),
- 'pgp_public_key': _('PGP Public Key')
+ 'pgp_public_key': _('PGP Public Key'),
+ 'public_user': _('Public User')
}
timezone = forms.ChoiceField(choices=[(x, x) for x in pytz.common_timezones], initial='UTC')
diff --git a/src/account/migrations/0007_userprofile_pulic_user.py b/src/account/migrations/0007_userprofile_pulic_user.py
new file mode 100644
index 0000000..6a229e6
--- /dev/null
+++ b/src/account/migrations/0007_userprofile_pulic_user.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2 on 2021-03-24 21:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('account', '0006_auto_20201109_1947'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='userprofile',
+ name='pulic_user',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/src/account/migrations/0008_auto_20210324_2106.py b/src/account/migrations/0008_auto_20210324_2106.py
new file mode 100644
index 0000000..9ff513d
--- /dev/null
+++ b/src/account/migrations/0008_auto_20210324_2106.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2 on 2021-03-24 21:06
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('account', '0007_userprofile_pulic_user'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='userprofile',
+ old_name='pulic_user',
+ new_name='public_user',
+ ),
+ ]
diff --git a/src/account/migrations/0009_auto_20210324_2107.py b/src/account/migrations/0009_auto_20210324_2107.py
new file mode 100644
index 0000000..baa7382
--- /dev/null
+++ b/src/account/migrations/0009_auto_20210324_2107.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2 on 2021-03-24 21:07
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('account', '0008_auto_20210324_2106'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='userprofile',
+ name='public_user',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/src/account/models.py b/src/account/models.py
index 2a7b017..b71f0ac 100644
--- a/src/account/models.py
+++ b/src/account/models.py
@@ -54,6 +54,8 @@ class UserProfile(models.Model):
full_name = models.CharField(max_length=100, null=True, blank=True, default='')
booking_privledge = models.BooleanField(default=False)
+ public_user = models.BooleanField(default=False)
+
class Meta:
db_table = 'user_profile'
diff --git a/src/account/views.py b/src/account/views.py
index 2e1ab94..b74126e 100644
--- a/src/account/views.py
+++ b/src/account/views.py
@@ -209,7 +209,7 @@ class UserListView(TemplateView):
template_name = "account/user_list.html"
def get_context_data(self, **kwargs):
- users = User.objects.all()
+ users = UserProfile.objects.filter(public_user=True).select_related('user')
context = super(UserListView, self).get_context_data(**kwargs)
context.update({'title': "Dashboard Users", 'users': users})
return context
diff --git a/src/booking/forms.py b/src/booking/forms.py
index e7be70f..cbc3407 100644
--- a/src/booking/forms.py
+++ b/src/booking/forms.py
@@ -35,12 +35,20 @@ class QuickBookingForm(forms.Form):
super(QuickBookingForm, self).__init__(data=data, **kwargs)
+ image_help_text = 'Image can be set only for single-node bookings. For multi-node bookings set image through Design a POD.'
self.fields["image"] = forms.ModelChoiceField(
Image.objects.filter(public=True) | Image.objects.filter(owner=user), required=False
)
+ self.fields['image'].widget.attrs.update({
+ 'class': 'has-popover',
+ 'data-content': image_help_text,
+ 'data-placement': 'bottom',
+ 'data-container': 'body'
+ })
+
self.fields['users'] = SearchableSelectMultipleField(
- queryset=UserProfile.objects.select_related('user').exclude(user=user),
+ queryset=UserProfile.objects.filter(public_user=True).select_related('user').exclude(user=user),
items=get_user_items(exclude=user),
required=False,
**get_user_field_opts()
@@ -59,10 +67,10 @@ class QuickBookingForm(forms.Form):
self.fields['filter_field'] = MultipleSelectFilterField(widget=MultipleSelectFilterWidget(**lab_data))
- help_text = 'Hostname can be set only for single-node bookings. For multi-node bookings set hostname through Design a POD.'
+ hostname_help_text = 'Hostname can be set only for single-node bookings. For multi-node bookings set hostname through Design a POD.'
self.fields['hostname'].widget.attrs.update({
'class': 'has-popover',
- 'data-content': help_text,
+ 'data-content': hostname_help_text,
'data-placement': 'top',
'data-container': 'body'
})
diff --git a/src/booking/lib.py b/src/booking/lib.py
index 8132c75..7a4c261 100644
--- a/src/booking/lib.py
+++ b/src/booking/lib.py
@@ -23,7 +23,7 @@ def get_user_field_opts():
def get_user_items(exclude=None):
- qs = UserProfile.objects.select_related('user').exclude(user=exclude)
+ qs = UserProfile.objects.filter(public_user=True).select_related('user').exclude(user=exclude)
items = {}
for up in qs:
item = {
diff --git a/src/dashboard/admin_utils.py b/src/dashboard/admin_utils.py
index 186a64f..b105e96 100644
--- a/src/dashboard/admin_utils.py
+++ b/src/dashboard/admin_utils.py
@@ -281,7 +281,7 @@ def booking_for_host(host_labid: str, lab_username="unh_iol"):
@lab_username: param of the form `unh_iol` or similar
"""
- server = Server.objects.get(lab__lab_user__username=lab_username, lab_username=host_labid)
+ server = Server.objects.get(lab__lab_user__username=lab_username, labid=host_labid)
booking = server.bundle.booking_set.first()
print_div()
print(booking)
diff --git a/src/static/js/dashboard.js b/src/static/js/dashboard.js
index dfbb157..85a337b 100644
--- a/src/static/js/dashboard.js
+++ b/src/static/js/dashboard.js
@@ -409,6 +409,7 @@ class MultipleSelectFilterWidget {
reserveResource(node){
const required_resources = JSON.parse(node['required_resources']);
let hostname = document.getElementById('id_hostname');
+ let image = document.getElementById('id_image');
let cnt = 0
@@ -417,8 +418,10 @@ class MultipleSelectFilterWidget {
cnt += required_resources[resource];
}
- if (cnt > 1)
+ if (cnt > 1 && hostname && image) {
hostname.readOnly = true;
+ image.disabled = true;
+ }
this.updateAvailibility();
}
@@ -426,12 +429,17 @@ class MultipleSelectFilterWidget {
releaseResource(node){
const required_resources = JSON.parse(node['required_resources']);
let hostname = document.getElementById('id_hostname');
+ let image = document.getElementById('id_image');
for(let resource in required_resources){
this.available_resources[resource] += required_resources[resource];
}
- hostname.readOnly = false;
+ if (hostname && image) {
+ hostname.readOnly = false;
+ image.disabled = false;
+ }
+
this.updateAvailibility();
}