CARGA
CARGA
This commit is contained in:
0
pendientes/__init__.py
Normal file
0
pendientes/__init__.py
Normal file
BIN
pendientes/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/admin.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/admin.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/apps.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/apps.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/forms.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/forms.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/forms.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/forms.cpython-39.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/models.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/models.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/views.cpython-310.pyc
Normal file
BIN
pendientes/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/__pycache__/views.cpython-39.pyc
Normal file
BIN
pendientes/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
6
pendientes/admin.py
Normal file
6
pendientes/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from .models import bitpendientes
|
||||
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(bitpendientes)
|
||||
6
pendientes/apps.py
Normal file
6
pendientes/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PendientesConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'pendientes'
|
||||
17
pendientes/forms.py
Normal file
17
pendientes/forms.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from django import forms
|
||||
from .models import bitpendientes
|
||||
|
||||
|
||||
|
||||
class FormularioPendiente(forms.ModelForm):
|
||||
class Meta:
|
||||
model = bitpendientes
|
||||
fields = ('n_reporte', 'fecha', 'reporta_ib', 'n_control', 'falla', 'contrato', 'reprovedor', 'refacciones')
|
||||
|
||||
|
||||
class FormularioPendienteEnv(forms.ModelForm):
|
||||
class Meta:
|
||||
model = bitpendientes
|
||||
fields = ('n_control', 'contrato', 'reprovedor', 'refacciones')
|
||||
|
||||
|
||||
38
pendientes/migrations/0001_initial.py
Normal file
38
pendientes/migrations/0001_initial.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Generated by Django 3.2.8 on 2021-10-20 10:20
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import tinymce.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='bitpendientes',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('n_reporte', models.CharField(max_length=50, verbose_name='NUM. DE REPORTE')),
|
||||
('fecha', models.DateField(verbose_name='FECHA')),
|
||||
('n_control', models.IntegerField(verbose_name='NO. DE CONTROL DEL EQUIPO')),
|
||||
('falla', models.CharField(blank=True, max_length=250, null=True, verbose_name='FALLA PRESENTADA')),
|
||||
('contrato', models.CharField(choices=[('SI', 'SI'), ('NO', 'NO')], default='SI', max_length=5, verbose_name='CON CONTRATO')),
|
||||
('reprovedor', models.CharField(blank=True, max_length=250, null=True, verbose_name='NO. DE REPORTE PROVEDOR')),
|
||||
('refacciones', tinymce.models.HTMLField(blank=True, null=True, verbose_name='REFACCIONES PARA EQUIPOS SIN CONTRATO')),
|
||||
('concluido', models.CharField(choices=[('SI', 'SI'), ('NO', 'NO')], default='NO', max_length=5, verbose_name='CONCLUIDO')),
|
||||
('reporta_ib', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='REPORTA IB')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Bitacora Pendientes',
|
||||
'verbose_name_plural': 'Bitacora Pendientes',
|
||||
'ordering': ['-id'],
|
||||
},
|
||||
),
|
||||
]
|
||||
18
pendientes/migrations/0002_alter_bitpendientes_concluido.py
Normal file
18
pendientes/migrations/0002_alter_bitpendientes_concluido.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.2 on 2022-03-10 17:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pendientes', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='bitpendientes',
|
||||
name='concluido',
|
||||
field=models.CharField(choices=[('Bitacora', 'Bitacora'), ('Pendiente', 'Pendiente'), ('Realizado', 'Realizado')], default='Pendiente', max_length=20, verbose_name='Pendiente'),
|
||||
),
|
||||
]
|
||||
0
pendientes/migrations/__init__.py
Normal file
0
pendientes/migrations/__init__.py
Normal file
BIN
pendientes/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
BIN
pendientes/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
BIN
pendientes/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
pendientes/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
pendientes/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pendientes/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
pendientes/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
31
pendientes/models.py
Normal file
31
pendientes/models.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from tinymce import models as tinymce_models
|
||||
from model_utils import Choices
|
||||
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class bitpendientes(models.Model):
|
||||
STATUS = Choices('Bitacora', 'Pendiente', 'Realizado')
|
||||
STATUS1 = Choices('SI', 'NO')
|
||||
n_reporte = models.CharField(max_length=50, null=False, verbose_name='NUM. DE REPORTE')
|
||||
fecha = models.DateField(verbose_name='FECHA')
|
||||
reporta_ib = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True, verbose_name='REPORTA IB')
|
||||
n_control = models.IntegerField(null=False, blank=False, verbose_name='NO. DE CONTROL DEL EQUIPO')
|
||||
falla = models.CharField(max_length=250, null=True, blank=True, verbose_name='FALLA PRESENTADA')
|
||||
contrato = models.CharField(choices=STATUS1, default=STATUS1.SI, max_length=5, verbose_name='CON CONTRATO')
|
||||
reprovedor = models.CharField(max_length=250, null=True, blank=True, verbose_name='NO. DE REPORTE PROVEDOR')
|
||||
refacciones = tinymce_models.HTMLField(null=True, blank=True, verbose_name='REFACCIONES PARA EQUIPOS SIN CONTRATO')
|
||||
concluido = models.CharField(choices=STATUS, default=STATUS.Pendiente, max_length=20, verbose_name='Pendiente')
|
||||
|
||||
def __str__(self):
|
||||
return self.n_reporte
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Bitacora Pendientes'
|
||||
verbose_name_plural = 'Bitacora Pendientes'
|
||||
ordering = ['-id']
|
||||
|
||||
|
||||
|
||||
3
pendientes/tests.py
Normal file
3
pendientes/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
148
pendientes/views.py
Normal file
148
pendientes/views.py
Normal file
@@ -0,0 +1,148 @@
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.models import User
|
||||
from inventario.views import inv_equipo
|
||||
from .models import bitpendientes
|
||||
from .forms import FormularioPendiente, FormularioPendienteEnv
|
||||
from servicios.models import serviciorealizado, accesorios
|
||||
from inventario.models import invequipo
|
||||
from bitacora.models import bitreporte
|
||||
from django.http.response import HttpResponse
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def pendientes(request):
|
||||
datos = bitpendientes.objects.filter(concluido='Pendiente')
|
||||
equipo = invequipo.objects.all()
|
||||
servicios = serviciorealizado.objects.all()
|
||||
usuarios = User.objects.all()
|
||||
accesorio = accesorios.objects.all()
|
||||
return render(request, 'pendientes.html', {"datos": datos, "servicios": servicios, "equipo": equipo, "usuarios": usuarios, "accesorio": accesorio})
|
||||
|
||||
|
||||
@login_required(login_url='/acceder')
|
||||
def crear_pendiente(request, cb):
|
||||
if request.method == "POST":
|
||||
form = FormularioPendiente(request.POST)
|
||||
if form.is_valid():
|
||||
post = form.save(commit=False)
|
||||
post.save()
|
||||
titulo = form.cleaned_data.get("n_reporte")
|
||||
update = bitreporte.objects.values('pendiente').filter(control_bit=titulo).update(pendiente='Pendiente')
|
||||
messages.success(request, f"La bitacora con el reporte {titulo} se ha creado correctamente")
|
||||
return redirect("pendientes")
|
||||
else:
|
||||
for field, items in form.errors.items():
|
||||
for item in items:
|
||||
messages.error(request, '{}: {}'.format(field, item))
|
||||
|
||||
ccontrolb = cb
|
||||
dato = bitreporte.objects.filter(control_bit=ccontrolb)
|
||||
falla = dato[0].reporte
|
||||
reporta_ib_1 = dato[0].asignado
|
||||
reporta_ib = dato[0].asignado.id
|
||||
form = FormularioPendienteEnv()
|
||||
return render(request, "crear_pendiente.html", {"form": form, "ccontrolb": ccontrolb, "falla": falla, "reporta_ib": reporta_ib, "reporta_ib_1": reporta_ib_1})
|
||||
|
||||
|
||||
@login_required(login_url='/acceder')
|
||||
def ActualizarPendientes(request, id):
|
||||
instance= get_object_or_404(bitpendientes, pk=id)
|
||||
form = FormularioPendiente(request.POST or None, instance=instance)
|
||||
context= {'form': form}
|
||||
if form.is_valid():
|
||||
obj= form.save(commit= False)
|
||||
obj.save()
|
||||
messages.success(request, "La Bitacora de Pendientes fue actualizada")
|
||||
return redirect("pendientes")
|
||||
|
||||
else:
|
||||
context= {'form': form, 'error': 'Error al actualizar'}
|
||||
return render(request,'crear_pendiente2.html' , context)
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='/acceder')
|
||||
def ReporteExcelPendietes(request):
|
||||
datospendientes = bitpendientes.objects.all()
|
||||
ibs = User.objects.all()
|
||||
datosservicio = serviciorealizado.objects.all()
|
||||
datosaccesorios = accesorios.objects.all()
|
||||
fecha = datetime.datetime.now()
|
||||
fe = str(fecha)
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws['B1'] = 'REPORTE DE SERVICIOS CONCLUIDOS'
|
||||
|
||||
ws.merge_cells('B1:L1')
|
||||
|
||||
ws['B2'] = datetime.datetime.now()
|
||||
|
||||
ws.merge_cells('B2:D2')
|
||||
|
||||
ws['B3'] = 'No. REPORTE'
|
||||
ws['C3'] = 'FECHA'
|
||||
ws['D3'] = 'REPORTA IB'
|
||||
ws['E3'] = 'No. CONTROL'
|
||||
ws['F3'] = 'FALLA PRESENTADA'
|
||||
ws['G3'] = 'CON CONTRATO'
|
||||
ws['H3'] = 'PROVEEDOR'
|
||||
ws['I3'] = 'REFACCIONES PENDENTES'
|
||||
ws['J3'] = 'SERVICIOS'
|
||||
ws['K3'] = 'ACCESORIOS'
|
||||
|
||||
cont = 4
|
||||
for datopendientes in datospendientes:
|
||||
for ib in ibs:
|
||||
if datopendientes.reporta_ib_id == ib.id:
|
||||
reporta = ib.username
|
||||
|
||||
count = 0
|
||||
serreali = ""
|
||||
for datoservicio in datosservicio:
|
||||
if datopendientes.n_reporte == datoservicio.control_bit:
|
||||
count = count + 1
|
||||
realizado = str(count) + " - " + datoservicio.descripcion
|
||||
serreali = serreali + " // " + realizado
|
||||
if count == 0 :
|
||||
serreali = ""
|
||||
count = 0
|
||||
|
||||
count1 = 0
|
||||
seracce = ""
|
||||
for datoaccesorios in datosaccesorios:
|
||||
if datopendientes.n_reporte == datoaccesorios.control_bit:
|
||||
count1 = count1 + 1
|
||||
acceso = str(count1) + " - " + datoaccesorios.n_parte + " | " + datoaccesorios.descripcion
|
||||
seracce = seracce + " // " + acceso
|
||||
if count1 == 0 :
|
||||
seracce = ""
|
||||
|
||||
ws.cell(row=cont, column=2).value = datopendientes.n_reporte
|
||||
ws.cell(row=cont, column=3).value = datopendientes.fecha
|
||||
ws.cell(row=cont, column=4).value = reporta
|
||||
ws.cell(row=cont, column=5).value = datopendientes.n_control
|
||||
ws.cell(row=cont, column=6).value = datopendientes.falla
|
||||
ws.cell(row=cont, column=7).value = datopendientes.contrato
|
||||
ws.cell(row=cont, column=8).value = datopendientes.reprovedor
|
||||
ws.cell(row=cont, column=9).value = datopendientes.refacciones
|
||||
ws.cell(row=cont, column=10).value = serreali
|
||||
ws.cell(row=cont, column=11).value = seracce
|
||||
|
||||
cont += 1
|
||||
serreali = ""
|
||||
seracce = ""
|
||||
|
||||
|
||||
nombre_archivo = "ReporteServicioConcluidos "+fe+".xlsx"
|
||||
response = HttpResponse(content_type="application/ms-excel")
|
||||
content = "attachment; filename = {0}".format(nombre_archivo)
|
||||
response['Content-Disposition'] = content
|
||||
wb.save(response)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user