Dar de alta sistmeas en ajax popup

This commit is contained in:
fjrodriguez
2023-02-16 10:38:28 -06:00
parent 3aaa0cd909
commit 0de2d8a735
9 changed files with 401 additions and 68 deletions

View File

@@ -1,6 +1,30 @@
from django import forms
from .models import Sistema
from .models import Sistema,sistemas_por_cliente
class SistemaForm(forms.ModelForm):
class Meta:
model = Sistema
fields = ['nombre_sistema','version']
fields = ['nombre_sistema','version']
class sistemas_por_clienteForm(forms.ModelForm):
nombre_sistema = forms.CharField(max_length=100)
version = forms.CharField(max_length=25)
class Meta:
model = sistemas_por_cliente
fields = ['cliente', 'num_licencias']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['cliente'].empty_label = None
def save(self, commit=True):
sistema = Sistema.objects.create(
nombre_sistema=self.cleaned_data['nombre_sistema'],
version=self.cleaned_data['version'],
)
sistema_por_cliente = super().save(commit=False)
sistema_por_cliente.id_sistema = sistema
if commit:
sistema_por_cliente.save()
return sistema_por_cliente