From 5d58897848cb33da01a7a6117964640be3835be0 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Fri, 12 Mar 2010 10:59:48 +0000 Subject: [PATCH] SeviceAccountForn will only present services that the user isn't registered for --- sso/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sso/forms.py b/sso/forms.py index fcadeeb..1678715 100644 --- a/sso/forms.py +++ b/sso/forms.py @@ -41,7 +41,11 @@ class ServiceUsernameField(forms.CharField): def UserServiceAccountForm(user): """ Generate a Service Account form based on the user's permissions """ - services = Service.objects.filter(groups__in=user.groups.all()) + current_services = [] + for sa in ServiceAccount.objects.filter(user=user): + current_services.append(sa.service) + + services = set(Service.objects.filter(groups__in=user.groups.all())) - set(current_services) class ServiceAccountForm(forms.Form): """ Service Account Form """