Active/inactive client functionality added
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from .models import Clientes
|
from .models import Clientes
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
class ClienteForm(forms.ModelForm):
|
class ClienteForm(forms.ModelForm):
|
||||||
|
fecha_baja = forms.DateField(
|
||||||
|
required=False,
|
||||||
|
initial=datetime.now(),
|
||||||
|
input_formats=["%Y-%m-%d"],
|
||||||
|
widget=forms.DateInput(attrs={'type':'date'},format="%Y-%m-%d")
|
||||||
|
)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Clientes
|
model = Clientes
|
||||||
fields = ('RFC','Nombre','Activo','fecha_baja')
|
fields = ('RFC','Nombre','Activo','fecha_baja')
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{% render_field form.fecha_baja.label %}
|
{% render_field form.fecha_baja.label %}
|
||||||
{% render_field form.fecha_baja placeholder=form.fecha_baja.label class+="form-control" type="date" %}
|
{% render_field form.fecha_baja placeholder=form.fecha_baja.label class+="form-control" type="date" %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -33,6 +32,14 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
|
window.addEventListener("load", (event)=>{
|
||||||
|
if(!id_Activo.checked){
|
||||||
|
id_fecha_baja.setAttribute('required','')
|
||||||
|
}else{
|
||||||
|
id_fecha_baja.removeAttribute('requied')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
id_fecha_baja.addEventListener('click',(event)=>{
|
id_fecha_baja.addEventListener('click',(event)=>{
|
||||||
|
|
||||||
if(id_Activo.checked){
|
if(id_Activo.checked){
|
||||||
@@ -41,6 +48,16 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
id_Activo.addEventListener('click', (event)=>{
|
||||||
|
|
||||||
|
if(id_Activo.checked){
|
||||||
|
id_fecha_baja.value=''
|
||||||
|
id_fecha_baja.removeAttribute('required')
|
||||||
|
|
||||||
|
}else{
|
||||||
|
id_fecha_baja.setAttribute('required','')
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
{% endblock scripts %}
|
{% endblock scripts %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user