From d007fa661e2faf77e70cb75c8d520941e907ebf7 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Wed, 24 Mar 2021 17:22:54 -0400 Subject: Remove exposure of users on dashboard Signed-off-by: Sean Smith Change-Id: I83b93d9247a7eafb54e4a5761d1423a504d86400 --- src/account/forms.py | 5 +++-- src/account/migrations/0007_userprofile_pulic_user.py | 18 ++++++++++++++++++ src/account/migrations/0008_auto_20210324_2106.py | 18 ++++++++++++++++++ src/account/migrations/0009_auto_20210324_2107.py | 18 ++++++++++++++++++ src/account/models.py | 2 ++ src/account/views.py | 2 +- src/booking/forms.py | 2 +- src/booking/lib.py | 2 +- 8 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 src/account/migrations/0007_userprofile_pulic_user.py create mode 100644 src/account/migrations/0008_auto_20210324_2106.py create mode 100644 src/account/migrations/0009_auto_20210324_2107.py 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 2a8784f..b2df799 100644 --- a/src/booking/forms.py +++ b/src/booking/forms.py @@ -40,7 +40,7 @@ class QuickBookingForm(forms.Form): ) 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() 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 = { -- cgit 1.2.3-korg