add a comment to the Create forms

This commit is contained in:
Andreas Zweili 2020-05-01 16:11:47 +02:00
parent 78d5f4cea5
commit 30daf62383
2 changed files with 8 additions and 0 deletions

View File

@ -17,6 +17,10 @@ class ComputerCreateForm(forms.ModelForm):
)
def __init__(self, user=None, *args, **kwargs):
"""
If the user is not a superuser it's always assigned to a customer which
we can use to assign to the field.
"""
super(ComputerCreateForm, self).__init__(*args, **kwargs)
if not user.is_superuser:
self.fields['customer'].queryset = utils.get_customers(user)

View File

@ -15,6 +15,10 @@ class DeviceCreateForm(forms.ModelForm):
)
def __init__(self, user=None, *args, **kwargs):
"""
If the user is not a superuser it's always assigned to a customer which
we can use to assign to the field.
"""
super(DeviceCreateForm, self).__init__(*args, **kwargs)
if not user.is_superuser:
self.fields['customer'].queryset = utils.get_customers(user)