mirror of
https://github.com/Nebucatnetzer/network_inventory.git
synced 2024-06-27 03:35:11 +02:00
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
|
import floppyforms.__future__ as forms
|
||||||
|
|
||||||
from .models import Computer
|
from .models import Computer
|
||||||
|
from customers.models import Customer
|
||||||
|
|
||||||
|
|
||||||
class ComputerCreateForm(forms.ModelForm):
|
class ComputerCreateForm(forms.ModelForm):
|
||||||
|
@ -11,6 +12,11 @@ class ComputerCreateForm(forms.ModelForm):
|
||||||
'customer',
|
'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 ComputerUpdateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user