filter 2 page remove from filter page
This commit is contained in:
@@ -3,12 +3,24 @@ from .models import Clientes
|
||||
from datetime import datetime
|
||||
|
||||
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:
|
||||
model = Clientes
|
||||
fields = ('RFC','Nombre','Activo','fecha_baja')
|
||||
|
||||
def clean(self):
|
||||
super(ClienteForm,self).clean()
|
||||
Activo = self.cleaned_data.get("Activo")
|
||||
fecha_baja = self.cleaned_data.get("fecha_baja")
|
||||
|
||||
if Activo and fecha_baja:
|
||||
self._errors['fecha_baja'] = self.error_class(["El parametro activo no puede estar seleccionado si hay fecha de baja"])
|
||||
return self.cleaned_data
|
||||
@@ -37,7 +37,7 @@ class Clientes(models.Model):
|
||||
Nombre = models.CharField(max_length=100)
|
||||
|
||||
|
||||
Activo = models.BooleanField(default=True)
|
||||
Activo = models.BooleanField(default=False)
|
||||
fecha_baja = models.DateField(blank=True,null=True)
|
||||
|
||||
@property
|
||||
@@ -47,6 +47,6 @@ class Clientes(models.Model):
|
||||
year = today.year
|
||||
return Timbres.objects.filter(rfcc=self.RFC, created_at__year=str(year),created_at__month=str(month)).count()
|
||||
class Meta:
|
||||
ordering = ('RFC',)
|
||||
ordering = ('-Activo','RFC',)
|
||||
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ def timbres_cliente(request, RFC):
|
||||
tipo = request.GET.get('tipo',None)
|
||||
|
||||
|
||||
filters = {key:value for (key,value) in dict(request.GET).items() if value !=None}
|
||||
|
||||
filters = {key:value[0] for (key,value) in dict(request.GET).items() if value !=[""]}
|
||||
filters.pop('page', '')
|
||||
if tipo:
|
||||
lista = lista.filter(Q(tipo__icontains=search))
|
||||
|
||||
@@ -113,12 +113,15 @@ def timbres_cliente(request, RFC):
|
||||
|
||||
conteo = lista.count()
|
||||
perPage = conteo // 2
|
||||
if perPage == 0 :
|
||||
perPage = conteo
|
||||
lista =pageFunc(page,lista,perPage)
|
||||
|
||||
context ={
|
||||
'lista':lista,
|
||||
'conteo':conteo,
|
||||
'RFC':RFC
|
||||
'RFC':RFC,
|
||||
'filters':filters
|
||||
}
|
||||
return render(request, 'Clientes/timbres_cliente.html', context)
|
||||
|
||||
|
||||
@@ -12,12 +12,10 @@
|
||||
<label for="{{form.RFC.name}}"><strong> {{form.RFC.label|capfirst}} </strong></label>
|
||||
{% render_field form.RFC id+="add" id+=form.RFC.name placeholder=form.RFC.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{form.Nombre.name}}"><strong> {{form.Nombre.label|capfirst}} </strong></label>
|
||||
{% render_field form.Nombre id+="add" id+=form.Nombre.name placeholder=form.Nombre.label class="form-control" type="text" autocomplete="off" %}
|
||||
</div>
|
||||
|
||||
<div class="form-group form-check">
|
||||
{% render_field form.Activo class+="form-checkbox" type="checkbox" %}
|
||||
<label class="form-check-label" for="{{form.Activo.label}}">Activo</label>
|
||||
@@ -32,6 +30,7 @@
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
|
||||
window.addEventListener("load", (event)=>{
|
||||
if(!id_Activo.checked){
|
||||
id_fecha_baja.setAttribute('required','')
|
||||
|
||||
@@ -20,17 +20,27 @@ Timbres disponibles Comercio Digital: {{saldo.saldo}}
|
||||
</th>
|
||||
<th>Nombre</th>
|
||||
<th>Totales Mes {{fecha|date:"F"}}</th>
|
||||
<th>Estado</th>
|
||||
<th scope="col">actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for obj in lista %}
|
||||
<tr class="">
|
||||
<tr class="{% if not obj.Activo %}table-danger{% endif %}">
|
||||
<td>
|
||||
<a href="{% url 'update_cliente' obj.pk %}">{{obj.RFC}}</a>
|
||||
</td>
|
||||
<td>{{obj.Nombre}}</td>
|
||||
<td>{{obj.Nombre}} </td>
|
||||
<td>{{obj.timbres_mes_count}}</td>
|
||||
|
||||
<td>
|
||||
{% if obj.Activo %}
|
||||
Activo
|
||||
{% else %}
|
||||
Inactivo
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{% if request.user.is_staff %}
|
||||
<a href="{% url 'timbres_cliente' obj.RFC %}" class="btn btn-info">Ver Timbres</a>
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
{% block content %}
|
||||
<h1>Timbres <strong>{{RFC}}</strong> </h1>
|
||||
<h2>Timbres totales: <strong></strong>{{conteo}}</strong></h2>
|
||||
<span class="navbar-text mr-2">
|
||||
{% if filters.datepicker%}
|
||||
De fecha: <strong>"{{filters.datepicker}}"</strong>
|
||||
{% endif %}
|
||||
|
||||
{% if filters.datepickerFin %}
|
||||
A fecha: <strong>"{{filters.datepickerFin}}"</strong>
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
<div class="container-fluid">
|
||||
{% include 'sidebar.html' %}
|
||||
<h1>{% block titlePage %}{% endblock titlePage %}</h1>
|
||||
{% include 'partials/messages.html' %}
|
||||
{% block content %}{% endblock content %}
|
||||
|
||||
{% include 'paginator.html' %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
{% if lista.has_other_pages %}
|
||||
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center">
|
||||
{% if lista.has_previous %}
|
||||
@@ -17,7 +19,7 @@
|
||||
{% if lista.number == p %}
|
||||
<li class="page-item"><a class="page-link" style="color: red;" href="#">{{ p }}</a></li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="?page={{ p }}">{{ p }}</a></li>
|
||||
<li class="page-item"><a class="page-link" href="?page={{ p }}{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}">{{ p }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
13
Templates/partials/messages.html
Normal file
13
Templates/partials/messages.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% if form.errors %}
|
||||
{% for field in form %}
|
||||
{% for error in field.errors %}
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<strong>-{{field.name}}</strong><br>
|
||||
<strong>{{ error|escape }}</strong> <br>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user