Limit the customer dropdown for normal users
This commit is contained in:
parent
df86ca19fa
commit
0c9b94be69
|
@ -1,6 +1,7 @@
|
|||
import floppyforms.__future__ as forms
|
||||
|
||||
from .models import Computer
|
||||
from customers.models import Customer
|
||||
|
||||
|
||||
class ComputerCreateForm(forms.ModelForm):
|
||||
|
@ -11,6 +12,11 @@ class ComputerCreateForm(forms.ModelForm):
|
|||
'customer',
|
||||
)
|
||||
|
||||
def __init__(self, pk=None, user=None, *args, **kwargs):
|
||||
super(ComputerCreateForm, self).__init__(*args, **kwargs)
|
||||
if not user.is_superuser:
|
||||
self.fields['customer'].queryset = (Customer.objects.filter(id=pk))
|
||||
|
||||
|
||||
class ComputerUpdateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in New Issue