diff options
Diffstat (limited to 'src/account')
-rw-r--r-- | src/account/forms.py | 5 | ||||
-rw-r--r-- | src/account/migrations/0007_userprofile_pulic_user.py | 18 | ||||
-rw-r--r-- | src/account/migrations/0008_auto_20210324_2106.py | 18 | ||||
-rw-r--r-- | src/account/migrations/0009_auto_20210324_2107.py | 18 | ||||
-rw-r--r-- | src/account/models.py | 4 | ||||
-rw-r--r-- | src/account/urls.py | 13 | ||||
-rw-r--r-- | src/account/views.py | 7 |
7 files changed, 78 insertions, 5 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 40de4d8..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' @@ -237,7 +239,7 @@ class Lab(models.Model): def get_available_resources(self): # Cannot import model normally due to ciruclar import Server = apps.get_model('resource_inventory', 'Server') # TODO: Find way to import ResourceQuery - resources = [str(resource.profile) for resource in Server.objects.filter(lab=self, booked=False)] + resources = [str(resource.profile) for resource in Server.objects.filter(lab=self, working=True, booked=False)] return dict(Counter(resources)) def __str__(self): diff --git a/src/account/urls.py b/src/account/urls.py index 0c01ee0..97d8c77 100644 --- a/src/account/urls.py +++ b/src/account/urls.py @@ -32,6 +32,7 @@ from account.views import ( AccountSettingsView, JiraAuthenticatedView, JiraLoginView, + OIDCLoginView, JiraLogoutView, UserListView, account_resource_view, @@ -45,11 +46,21 @@ from account.views import ( configuration_delete_view ) +from laas_dashboard import settings + + +def get_login_view(): + if (settings.AUTH_SETTING == 'LFID'): + return OIDCLoginView.as_view() + else: + return JiraLoginView.as_view() + + app_name = "account" urlpatterns = [ url(r'^settings/', AccountSettingsView.as_view(), name='settings'), url(r'^authenticated/$', JiraAuthenticatedView.as_view(), name='authenticated'), - url(r'^login/$', JiraLoginView.as_view(), name='login'), + url(r'^login/$', get_login_view(), name='login'), url(r'^logout/$', JiraLogoutView.as_view(), name='logout'), url(r'^users/$', UserListView.as_view(), name='users'), url(r'^my/resources/$', account_resource_view, name="my-resources"), diff --git a/src/account/views.py b/src/account/views.py index 08da918..b74126e 100644 --- a/src/account/views.py +++ b/src/account/views.py @@ -128,6 +128,11 @@ class JiraLoginView(RedirectView): return url +class OIDCLoginView(RedirectView): + def get_redirect_url(self, *args, **kwargs): + return reverse('oidc_authentication_init') + + class JiraLogoutView(LoginRequiredMixin, RedirectView): def get_redirect_url(self, *args, **kwargs): logout(self.request) @@ -204,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 |