index and paginator added
This commit is contained in:
@@ -12,7 +12,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
SECRET_KEY = 'django-insecure-5*mm&uf5zq@t6nrs_5z8-_qtyapm^3&yz^wqqkc_a!v(!ulj-^'
|
SECRET_KEY = 'django-insecure-5*mm&uf5zq@t6nrs_5z8-_qtyapm^3&yz^wqqkc_a!v(!ulj-^'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,24 @@ from django.shortcuts import render
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from .models import Timbres
|
from .models import Timbres
|
||||||
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
return HttpResponse('hello')
|
timbres_list = Timbres.objects.all()
|
||||||
|
page = request.GET.get('page', 1)
|
||||||
|
paginator = Paginator(timbres_list, 1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
timbres = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
timbres = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
timbres = paginator.page(paginator.num_pages)
|
||||||
|
context = {
|
||||||
|
'timbres':timbres,
|
||||||
|
}
|
||||||
|
return render(request,'Clientes/index.html',context)
|
||||||
|
|
||||||
|
|
||||||
def add_timbre(request):
|
def add_timbre(request):
|
||||||
@@ -24,8 +39,6 @@ def add_timbre(request):
|
|||||||
'tipo':tipo,
|
'tipo':tipo,
|
||||||
'rfcp':rfcp
|
'rfcp':rfcp
|
||||||
}
|
}
|
||||||
p = Timbres.objects.all()
|
|
||||||
p.delete()
|
|
||||||
try:
|
try:
|
||||||
obj = Timbres.objects.create(**obj)
|
obj = Timbres.objects.create(**obj)
|
||||||
return HttpResponse('ok')
|
return HttpResponse('ok')
|
||||||
|
|||||||
31
Templates/Clientes/index.html
Normal file
31
Templates/Clientes/index.html
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">UUID</th>
|
||||||
|
<th scope="col">
|
||||||
|
<input id="table_name" name="name" value="True" type="checkbox" class="form-check-input" >
|
||||||
|
RFC Cliente
|
||||||
|
</th>
|
||||||
|
<th scope="col">actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for obj in timbres %}
|
||||||
|
<tr class="">
|
||||||
|
<th scope="row">{{obj.uuid}}</th>
|
||||||
|
<td>{{obj.rfcc}}</td>
|
||||||
|
<td>
|
||||||
|
{% if request.user.is_staff %}
|
||||||
|
<a href="#" class="btn btn-info">View</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
56
Templates/base.html
Normal file
56
Templates/base.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
{% block title %}{% endblock title %}
|
||||||
|
</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% include 'sidebar.html' %}
|
||||||
|
<div class="container-fluid">
|
||||||
|
<h1>{% block titlePage %}{% endblock titlePage %}</h1>
|
||||||
|
|
||||||
|
<div class="">
|
||||||
|
{% comment %}
|
||||||
|
{% include "Profiles/partials/messages.html" %}
|
||||||
|
{% endcomment %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% include 'paginator.html' %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Optional JavaScript -->
|
||||||
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.3/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load', (event) => {
|
||||||
|
setTimeout(()=>{
|
||||||
|
//console.log('page is fully loaded');
|
||||||
|
let ale = document.getElementsByClassName("alert")
|
||||||
|
if(ale.length> 0 )
|
||||||
|
{
|
||||||
|
$(ale).alert('close')
|
||||||
|
$(ale).alert('dispose')
|
||||||
|
}
|
||||||
|
},5000)
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% block scripts %}
|
||||||
|
|
||||||
|
{% endblock scripts %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
38
Templates/paginator.html
Normal file
38
Templates/paginator.html
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{% if timbres.has_other_pages %}
|
||||||
|
<nav>
|
||||||
|
<ul class="pagination justify-content-center">
|
||||||
|
{% if timbres.has_previous %}
|
||||||
|
<li class="page-item">
|
||||||
|
<a class="page-link" href="?page={{ timbres.previous_page_number }}" aria-label="Previous">
|
||||||
|
<span aria-hidden="true">«</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled">
|
||||||
|
<span class="page-link" aria-hidden="true">«</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for p in timbres.paginator.page_range %}
|
||||||
|
{% if timbres.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>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if timbres.has_next %}
|
||||||
|
<li class="page-item">
|
||||||
|
<a class="page-link" href="?page={{ timbres.next_page_number }}" aria-label="Next">
|
||||||
|
<span aria-hidden="true">»</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled">
|
||||||
|
<span class="page-link" aria-hidden="true">»</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
44
Templates/sidebar.html
Normal file
44
Templates/sidebar.html
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="/"><img height="25px" class="center" src="https://aduanasoft.com/wp-content/uploads/2019/01/aslogo-1.png" id="icon" alt="User Icon" /></a>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
||||||
|
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
|
||||||
|
<li class="nav-item active">
|
||||||
|
<a class="nav-link" href="/">Timbres<span class="sr-only">(current)</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Contacts</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">List</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">#</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">List</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">List</a>
|
||||||
|
</li>
|
||||||
|
{% if request.user.is_superuser %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/admin" target="_blank">Admin site</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link disabled" href="#">Disabled</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
{% include "Profiles/partials/search_form.html" %}
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
Reference in New Issue
Block a user