CARGA
CARGA
This commit is contained in:
28
SERVER.txt
Normal file
28
SERVER.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
.\cdsalud\Scripts\activate
|
||||||
|
.\cdsalud\scripts\activate.ps1
|
||||||
|
& s:/CDSALUD/cdsalud/Scripts/Activate.ps1
|
||||||
|
|
||||||
|
django-admin startproject project
|
||||||
|
python manage.py startapp app
|
||||||
|
|
||||||
|
pip3 install django
|
||||||
|
pip3 install mysqlclient
|
||||||
|
pip3 install django-mysql
|
||||||
|
pip3 install django-crispy-forms
|
||||||
|
|
||||||
|
pip3 install django-ckeditor
|
||||||
|
pip3 install Pillow
|
||||||
|
pip3 install django-tinymce
|
||||||
|
pip3 install xhtml2pdf
|
||||||
|
pip3 install django-model-utils
|
||||||
|
pip3 install openpyxl
|
||||||
|
|
||||||
|
|
||||||
|
python manage.py makemigrations
|
||||||
|
python manage.py migrate
|
||||||
|
python manage.py migrate auth
|
||||||
|
|
||||||
|
python manage.py runserver 0.0.0.0:8000
|
||||||
|
|
||||||
|
mxsigco1_cdsalud
|
||||||
|
jU4sc%KUMj8&
|
||||||
0
autenticacion/__init__.py
Normal file
0
autenticacion/__init__.py
Normal file
BIN
autenticacion/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
autenticacion/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
autenticacion/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
autenticacion/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
autenticacion/__pycache__/forms.cpython-310.pyc
Normal file
BIN
autenticacion/__pycache__/forms.cpython-310.pyc
Normal file
Binary file not shown.
BIN
autenticacion/__pycache__/forms.cpython-39.pyc
Normal file
BIN
autenticacion/__pycache__/forms.cpython-39.pyc
Normal file
Binary file not shown.
BIN
autenticacion/__pycache__/views.cpython-310.pyc
Normal file
BIN
autenticacion/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
autenticacion/__pycache__/views.cpython-39.pyc
Normal file
BIN
autenticacion/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
3
autenticacion/admin.py
Normal file
3
autenticacion/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
autenticacion/apps.py
Normal file
5
autenticacion/apps.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AutenticacionConfig(AppConfig):
|
||||||
|
name = 'autenticacion'
|
||||||
16
autenticacion/forms.py
Normal file
16
autenticacion/forms.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
|
||||||
|
class UserForm(UserCreationForm):
|
||||||
|
first_name = forms.CharField()
|
||||||
|
last_name = forms.CharField()
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ('first_name','last_name', 'username', 'password1' ,'password2' )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0
autenticacion/migrations/__init__.py
Normal file
0
autenticacion/migrations/__init__.py
Normal file
3
autenticacion/models.py
Normal file
3
autenticacion/models.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
autenticacion/tests.py
Normal file
3
autenticacion/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
76
autenticacion/views.py
Normal file
76
autenticacion/views.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from django.views.generic import View
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth import login, logout, authenticate
|
||||||
|
from .forms import UserForm
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
|
||||||
|
def acceder(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = AuthenticationForm(request, data=request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
nombre_usuario = form.cleaned_data.get("username")
|
||||||
|
password = form.cleaned_data.get("password")
|
||||||
|
usuario = authenticate(username=nombre_usuario, password=password)
|
||||||
|
if usuario is not None:
|
||||||
|
login(request, usuario)
|
||||||
|
messages.success(request, F"Bienvenid@ de nuevo {nombre_usuario}")
|
||||||
|
return redirect("index")
|
||||||
|
else:
|
||||||
|
messages.error(request, "Los datos son incorrectos")
|
||||||
|
else:
|
||||||
|
messages.error(request, "Los datos son incorrectos")
|
||||||
|
|
||||||
|
form = AuthenticationForm()
|
||||||
|
return render(request, "acceder.html", {"form": form})
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
class VistaRegistro(View):
|
||||||
|
def get(self, request):
|
||||||
|
form = UserForm()
|
||||||
|
return render(request, "registro.html", {"form": form})
|
||||||
|
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
form = UserForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
post = form.save(commit=False)
|
||||||
|
post.save()
|
||||||
|
return redirect("usuarios")
|
||||||
|
else:
|
||||||
|
for field, items in form.errors.items():
|
||||||
|
for item in items:
|
||||||
|
messages.error(request, '{}: {}'.format(field, item))
|
||||||
|
return render(request, "registro.html", {"form": form})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def salir(request):
|
||||||
|
logout(request)
|
||||||
|
messages.success(request, F"Tu sesion se ha cerrado correctamente")
|
||||||
|
return redirect("index")
|
||||||
|
|
||||||
|
|
||||||
|
def usuarios(request):
|
||||||
|
datos = User.objects.all()
|
||||||
|
return render(request, 'usuarios.html', {"datos": datos})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def userupdate(request, id):
|
||||||
|
instance= get_object_or_404(User, pk=id)
|
||||||
|
form = UserForm(request.POST or None, instance=instance)
|
||||||
|
context= {'form': form}
|
||||||
|
if form.is_valid():
|
||||||
|
obj= form.save(commit= False)
|
||||||
|
obj.save()
|
||||||
|
messages.success(request, "El usuario fue actualizado")
|
||||||
|
return redirect("usuarios")
|
||||||
|
|
||||||
|
else:
|
||||||
|
context= {'form': form, 'error': 'Error al actualizar'}
|
||||||
|
return render(request,'usuariosupdate.html' , context)
|
||||||
0
bitacora/__init__.py
Normal file
0
bitacora/__init__.py
Normal file
BIN
bitacora/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/admin.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/admin.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/apps.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/apps.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/forms.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/forms.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/forms.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/forms.cpython-39.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/models.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/models.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/views.cpython-310.pyc
Normal file
BIN
bitacora/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/__pycache__/views.cpython-39.pyc
Normal file
BIN
bitacora/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
5
bitacora/admin.py
Normal file
5
bitacora/admin.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from .models import bitreporte
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
admin.site.register(bitreporte)
|
||||||
6
bitacora/apps.py
Normal file
6
bitacora/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class BitacoraConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'bitacora'
|
||||||
26
bitacora/forms.py
Normal file
26
bitacora/forms.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import bitreporte
|
||||||
|
|
||||||
|
|
||||||
|
class FormBitReporte(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(FormBitReporte, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['n_year'].widget.attrs['readonly'] = True
|
||||||
|
self.fields['hora'].widget.attrs['readonly'] = True
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = bitreporte
|
||||||
|
fields = ('n_reporte', 'n_year', 'area', 'reporte', 'quien_reporta', 'asignado', 'recibido_por', 'hora', 'pendiente', 'control_bit')
|
||||||
|
|
||||||
|
|
||||||
|
class FormBitReporteEnv(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(FormBitReporteEnv, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = bitreporte
|
||||||
|
fields = ('area', 'reporte', 'quien_reporta', 'asignado', 'recibido_por')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
bitacora/migrations/0001_initial.py
Normal file
38
bitacora/migrations/0001_initial.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-08 10:08
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventarioalmacen', '0008_alter_equipo_options'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='bitreporte',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('n_reporte', models.IntegerField(verbose_name='No. Reporte')),
|
||||||
|
('fecha', models.DateField(auto_now_add=True, verbose_name='Fecha')),
|
||||||
|
('reporte', models.CharField(max_length=250, verbose_name='Reporte')),
|
||||||
|
('quien_reporta', models.CharField(max_length=250, verbose_name='Quien Reporta')),
|
||||||
|
('realizado', models.CharField(max_length=250, unique=True, verbose_name='Realizado')),
|
||||||
|
('pendiente', models.CharField(choices=[('Realizado', 'Realizado'), ('Pendiente', 'Pendiente')], default='Pendiente', max_length=20, verbose_name='Pendiente')),
|
||||||
|
('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventarioalmacen.area', verbose_name='Area')),
|
||||||
|
('asignado', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Asignado', to=settings.AUTH_USER_MODEL, verbose_name='Asignado A')),
|
||||||
|
('recibido_por', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Recibio', to=settings.AUTH_USER_MODEL, verbose_name='Recibido Por')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Bitacora Reporte',
|
||||||
|
'verbose_name_plural': 'Bitacora Reportes',
|
||||||
|
'ordering': ['-id'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
28
bitacora/migrations/0002_auto_20211008_0528.py
Normal file
28
bitacora/migrations/0002_auto_20211008_0528.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-08 10:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='hora',
|
||||||
|
field=models.CharField(default='05:28:00', max_length=50, verbose_name='05:28:00'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='n_year',
|
||||||
|
field=models.CharField(default='21', max_length=4, verbose_name='21'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='realizado',
|
||||||
|
field=models.CharField(max_length=250, verbose_name='Realizado'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
bitacora/migrations/0003_alter_bitreporte_hora.py
Normal file
18
bitacora/migrations/0003_alter_bitreporte_hora.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-10 07:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0002_auto_20211008_0528'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='hora',
|
||||||
|
field=models.CharField(default='02:03:31', max_length=50, verbose_name='02:03:31'),
|
||||||
|
),
|
||||||
|
]
|
||||||
23
bitacora/migrations/0004_auto_20211010_0540.py
Normal file
23
bitacora/migrations/0004_auto_20211010_0540.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-10 10:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0003_alter_bitreporte_hora'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='hora',
|
||||||
|
field=models.CharField(default='05:40:25', max_length=50, verbose_name='Hora'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='n_year',
|
||||||
|
field=models.CharField(max_length=4, verbose_name='Año'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
bitacora/migrations/0005_alter_bitreporte_hora.py
Normal file
18
bitacora/migrations/0005_alter_bitreporte_hora.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-10 21:51
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0004_auto_20211010_0540'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='hora',
|
||||||
|
field=models.CharField(max_length=50, verbose_name='Hora'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
bitacora/migrations/0006_bitreporte_control_bit.py
Normal file
18
bitacora/migrations/0006_bitreporte_control_bit.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-11-04 04:33
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0005_alter_bitreporte_hora'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='control_bit',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Control Bitacora'),
|
||||||
|
),
|
||||||
|
]
|
||||||
23
bitacora/migrations/0007_auto_20211105_1526.py
Normal file
23
bitacora/migrations/0007_auto_20211105_1526.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-11-05 21:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0006_bitreporte_control_bit'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='pendiente',
|
||||||
|
field=models.CharField(blank=True, choices=[('Realizado', 'Realizado'), ('Pendiente', 'Pendiente')], default='Pendiente', max_length=20, null=True, verbose_name='Pendiente'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='realizado',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Realizado'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
bitacora/migrations/0008_alter_bitreporte_control_bit.py
Normal file
18
bitacora/migrations/0008_alter_bitreporte_control_bit.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-11-08 08:29
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bitacora', '0007_auto_20211105_1526'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='control_bit',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, unique=True, verbose_name='Control Bitacora'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
bitacora/migrations/0009_alter_bitreporte_pendiente.py
Normal file
18
bitacora/migrations/0009_alter_bitreporte_pendiente.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 = [
|
||||||
|
('bitacora', '0008_alter_bitreporte_control_bit'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bitreporte',
|
||||||
|
name='pendiente',
|
||||||
|
field=models.CharField(blank=True, choices=[('Bitacora', 'Bitacora'), ('Pendiente', 'Pendiente'), ('Realizado', 'Realizado')], default='Bitacora', max_length=20, null=True, verbose_name='Bitacora'),
|
||||||
|
),
|
||||||
|
]
|
||||||
0
bitacora/migrations/__init__.py
Normal file
0
bitacora/migrations/__init__.py
Normal file
BIN
bitacora/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
BIN
bitacora/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
BIN
bitacora/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bitacora/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
bitacora/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
bitacora/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
bitacora/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
36
bitacora/models.py
Normal file
36
bitacora/models.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
import os
|
||||||
|
from tinymce import models as tinymce_models
|
||||||
|
from model_utils import Choices
|
||||||
|
from inventarioalmacen.models import *
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
class bitreporte(models.Model):
|
||||||
|
STATUS = Choices('Bitacora', 'Pendiente', 'Realizado')
|
||||||
|
n_reporte = models.IntegerField(verbose_name='No. Reporte')
|
||||||
|
n_year = models.CharField(max_length=4, null=False, verbose_name='Año')
|
||||||
|
fecha = models.DateField(auto_now_add=True, verbose_name='Fecha')
|
||||||
|
area = models.ForeignKey(area, on_delete=models.CASCADE, null=False, blank=False, verbose_name='Area')
|
||||||
|
reporte = models.CharField(max_length=250, null=False, verbose_name='Reporte')
|
||||||
|
quien_reporta = models.CharField(max_length=250, null=False, verbose_name='Quien Reporta')
|
||||||
|
asignado = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True, related_name='Asignado', verbose_name='Asignado A')
|
||||||
|
recibido_por = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True, related_name='Recibio', verbose_name='Recibido Por')
|
||||||
|
hora = models.CharField(max_length=50, null=False, verbose_name='Hora')
|
||||||
|
realizado = models.CharField(max_length=250, null=True, blank=True, verbose_name='Realizado')
|
||||||
|
pendiente = models.CharField(choices=STATUS, null=True, blank=True, default=STATUS.Bitacora, max_length=20, verbose_name='Bitacora')
|
||||||
|
control_bit = models.CharField(max_length=250, unique=True, null=True, blank=True, verbose_name='Control Bitacora')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.n_reporte)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Bitacora Reporte'
|
||||||
|
verbose_name_plural = 'Bitacora Reportes'
|
||||||
|
ordering = ['-id']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3
bitacora/tests.py
Normal file
3
bitacora/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
166
bitacora/views.py
Normal file
166
bitacora/views.py
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
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 .models import bitreporte
|
||||||
|
from .forms import FormBitReporte, FormBitReporteEnv
|
||||||
|
from inventarioalmacen.models import area
|
||||||
|
from datetime import datetime
|
||||||
|
import datetime
|
||||||
|
from servicios.models import serviciorealizado, accesorios
|
||||||
|
from openpyxl import Workbook
|
||||||
|
from django.http.response import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
year = date.strftime('%y')
|
||||||
|
h = date.strftime("%H:%M:%S")
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def bitacora(request):
|
||||||
|
datos = bitreporte.objects.filter(pendiente='Bitacora')
|
||||||
|
servicios = serviciorealizado.objects.all()
|
||||||
|
usuarios = User.objects.all()
|
||||||
|
accesorio = accesorios.objects.all()
|
||||||
|
return render(request, "bitacora.html", {"datos": datos, "servicios": servicios, "usuarios": usuarios, "accesorio": accesorio})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def crear_bitacora(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = FormBitReporte(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
post = form.save(commit=False)
|
||||||
|
post.save()
|
||||||
|
titulo = form.cleaned_data.get("n_reporte")
|
||||||
|
messages.success(request, f"El reporte {titulo} se ha creado correctamente")
|
||||||
|
return redirect("bitacora")
|
||||||
|
else:
|
||||||
|
for field, items in form.errors.items():
|
||||||
|
for item in items:
|
||||||
|
messages.error(request, '{}: {}'.format(field, item))
|
||||||
|
reporte = bitreporte.objects.latest('id')
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
year = date.strftime('%y')
|
||||||
|
h = date.strftime("%H:%M:%S")
|
||||||
|
dato_rep = reporte.n_reporte + 1
|
||||||
|
dato_year = reporte.n_year
|
||||||
|
if year != dato_year :
|
||||||
|
new_year = year
|
||||||
|
dato_rep = 1
|
||||||
|
hora = h
|
||||||
|
form = FormBitReporteEnv()
|
||||||
|
return render(request, "crear_bitacora.html", {"form": form, "dato_rep":dato_rep, "new_year":new_year, "hora":hora})
|
||||||
|
new_year = dato_year
|
||||||
|
hora = h
|
||||||
|
form = FormBitReporteEnv()
|
||||||
|
return render(request, "crear_bitacora.html", {"form": form, "dato_rep":dato_rep, "new_year":new_year, "hora":hora})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def ActualizarBitacora(request, id):
|
||||||
|
instance= get_object_or_404(bitreporte, pk=id)
|
||||||
|
form = FormBitReporte(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 fue actualizada")
|
||||||
|
return redirect("bitacora")
|
||||||
|
|
||||||
|
else:
|
||||||
|
context= {'form': form, 'error': 'Error al actualizar'}
|
||||||
|
return render(request,'actualizar_bitacora.html' , context)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def ReporteExcelBitacora(request):
|
||||||
|
bitacoras = bitreporte.objects.all()
|
||||||
|
ibs = User.objects.all()
|
||||||
|
bitareas = area.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'] = 'AREA'
|
||||||
|
ws['E3'] = 'REPORTE'
|
||||||
|
ws['F3'] = 'QUIEN REPORTA'
|
||||||
|
ws['G3'] = 'ASIGNADO'
|
||||||
|
ws['H3'] = 'RECIBIO'
|
||||||
|
ws['I3'] = 'HORA'
|
||||||
|
ws['J3'] = 'SERVICIOS'
|
||||||
|
ws['K3'] = 'ACCESORIOS'
|
||||||
|
|
||||||
|
|
||||||
|
cont = 4
|
||||||
|
|
||||||
|
for bitacora in bitacoras:
|
||||||
|
for ib in ibs:
|
||||||
|
if bitacora.recibido_por_id == ib.id:
|
||||||
|
recibido = ib.username
|
||||||
|
for ib in ibs:
|
||||||
|
if bitacora.asignado_id == ib.id:
|
||||||
|
asignado = ib.username
|
||||||
|
|
||||||
|
for bitarea in bitareas:
|
||||||
|
if bitacora.area_id == bitarea.id:
|
||||||
|
datoarea = bitarea.nombre
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
serreali = ""
|
||||||
|
for datoservicio in datosservicio:
|
||||||
|
if bitacora.control_bit == 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 bitacora.control_bit == 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 = bitacora.control_bit
|
||||||
|
ws.cell(row=cont, column=3).value = bitacora.fecha
|
||||||
|
ws.cell(row=cont, column=4).value = datoarea
|
||||||
|
ws.cell(row=cont, column=5).value = bitacora.reporte
|
||||||
|
ws.cell(row=cont, column=6).value = bitacora.quien_reporta
|
||||||
|
ws.cell(row=cont, column=7).value = asignado
|
||||||
|
ws.cell(row=cont, column=8).value = recibido
|
||||||
|
ws.cell(row=cont, column=9).value = bitacora.hora
|
||||||
|
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
|
||||||
|
|
||||||
0
inventario/__init__.py
Normal file
0
inventario/__init__.py
Normal file
BIN
inventario/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/admin.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/admin.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/apps.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/apps.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/forms.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/forms.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/forms.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/forms.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/models.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/models.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/views.cpython-310.pyc
Normal file
BIN
inventario/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/__pycache__/views.cpython-39.pyc
Normal file
BIN
inventario/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
6
inventario/admin.py
Normal file
6
inventario/admin.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from .models import invequipo
|
||||||
|
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
admin.site.register(invequipo)
|
||||||
6
inventario/apps.py
Normal file
6
inventario/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class InventarioConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'inventario'
|
||||||
9
inventario/forms.py
Normal file
9
inventario/forms.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import invequipo
|
||||||
|
|
||||||
|
|
||||||
|
class Formularioinvequipo(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = invequipo
|
||||||
|
fields = ('n_control', 'estado_funcional', 'obsoleto', 'localizado', 'equipo', 'area', 'marca', 'modelo', 'n_serie', 'descripcion', 'n_act_fijo', 'accesorios', 'accesorios2', 'accesorios3', 'accesorios4', 'accesorios5', 'provedor', 'c_basico', 'fecha_inst', 'inventariado')
|
||||||
|
|
||||||
44
inventario/migrations/0001_initial.py
Normal file
44
inventario/migrations/0001_initial.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-06 12:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import tinymce.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventarioalmacen', '0007_area'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='invequipo',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('estado_funcional', models.CharField(choices=[('Funcionando', 'Funcionando'), ('No Funcionando', 'No Funcionando')], default='Funcionando', max_length=20, verbose_name='Estado Funcional')),
|
||||||
|
('n_control', models.IntegerField(unique=True, verbose_name='No Control')),
|
||||||
|
('descripcion', tinymce.models.HTMLField(verbose_name='Descripción')),
|
||||||
|
('modelo', models.CharField(blank=True, max_length=250, null=True, verbose_name='Modelo')),
|
||||||
|
('n_serie', models.CharField(max_length=250, unique=True, verbose_name='No Serie')),
|
||||||
|
('accesorios', models.CharField(blank=True, max_length=250, null=True, verbose_name='Accesorios')),
|
||||||
|
('obsoleto', models.CharField(blank=True, max_length=250, null=True, verbose_name='Obsoleto')),
|
||||||
|
('inventariado', models.CharField(blank=True, max_length=250, null=True, verbose_name='Inventariado')),
|
||||||
|
('n_act_fijo', models.CharField(blank=True, max_length=250, null=True, verbose_name='Numero Activo Fijo')),
|
||||||
|
('provedor', models.CharField(blank=True, max_length=250, null=True, verbose_name='Provedor')),
|
||||||
|
('c_basico', models.CharField(blank=True, max_length=250, null=True, verbose_name='Clave de cuadro basico')),
|
||||||
|
('fecha_alta', models.DateField(auto_now_add=True, verbose_name='Fecha alta')),
|
||||||
|
('fecha_actualizacion', models.DateField(auto_now=True, verbose_name='Fecha de Actualización')),
|
||||||
|
('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventarioalmacen.area', verbose_name='Area')),
|
||||||
|
('equipo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventarioalmacen.equipo', verbose_name='Equipo')),
|
||||||
|
('marca', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventarioalmacen.marca', verbose_name='Marca')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Equipo',
|
||||||
|
'verbose_name_plural': 'Equipos',
|
||||||
|
'ordering': ['n_control'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# Generated by Django 4.0.2 on 2022-03-10 22:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventario', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios2',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Accesorios 2'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios3',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Accesorios 3'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios4',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Accesorios 4'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios5',
|
||||||
|
field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Accesorios 5'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='fecha_inst',
|
||||||
|
field=models.DateField(default='2022-12-31', verbose_name='Fecha Instalacion'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='localizado',
|
||||||
|
field=models.CharField(choices=[('SI', 'SI'), ('NO', 'NO')], default='SI', max_length=20, verbose_name='Localizado'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='estado_funcional',
|
||||||
|
field=models.CharField(choices=[('Dañado', 'Dañado'), ('Marginal', 'Marginal'), ('Funcional', 'Funcional')], default='Funcional', max_length=20, verbose_name='Estatus'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='obsoleto',
|
||||||
|
field=models.CharField(choices=[('SI', 'SI'), ('NO', 'NO')], default='NO', max_length=20, verbose_name='Obsoleto'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Generated by Django 4.0.5 on 2022-07-09 07:18
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import tinymce.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventario', '0002_invequipo_accesorios2_invequipo_accesorios3_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios',
|
||||||
|
field=tinymce.models.HTMLField(blank=True, null=True, verbose_name='Accesorios'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios2',
|
||||||
|
field=tinymce.models.HTMLField(blank=True, null=True, verbose_name='Accesorios 2'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios3',
|
||||||
|
field=tinymce.models.HTMLField(blank=True, null=True, verbose_name='Accesorios 3'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios4',
|
||||||
|
field=tinymce.models.HTMLField(blank=True, null=True, verbose_name='Accesorios 4'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='accesorios5',
|
||||||
|
field=tinymce.models.HTMLField(blank=True, null=True, verbose_name='Accesorios 5'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
inventario/migrations/0004_alter_invequipo_fecha_inst.py
Normal file
18
inventario/migrations/0004_alter_invequipo_fecha_inst.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.0.5 on 2022-09-28 15:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventario', '0003_alter_invequipo_accesorios_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invequipo',
|
||||||
|
name='fecha_inst',
|
||||||
|
field=models.DateField(blank=True, default='2022-12-31', null=True, verbose_name='Fecha Instalacion'),
|
||||||
|
),
|
||||||
|
]
|
||||||
0
inventario/migrations/__init__.py
Normal file
0
inventario/migrations/__init__.py
Normal file
BIN
inventario/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
BIN
inventario/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
BIN
inventario/migrations/__pycache__/0001_initial.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
inventario/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
inventario/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventario/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
inventario/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
44
inventario/models.py
Normal file
44
inventario/models.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
import os
|
||||||
|
from tinymce import models as tinymce_models
|
||||||
|
from model_utils import Choices
|
||||||
|
from inventarioalmacen.models import *
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class invequipo(models.Model):
|
||||||
|
STATUS1 = Choices('Dañado', 'Marginal', 'Funcional')
|
||||||
|
STATUS2 = Choices('SI', 'NO')
|
||||||
|
STATUS3 = Choices('SI', 'NO')
|
||||||
|
estado_funcional = models.CharField(choices=STATUS1, default=STATUS1.Funcional, max_length=20, verbose_name='Estatus')
|
||||||
|
n_control = models.IntegerField(unique=True, null=False, verbose_name='No Control')
|
||||||
|
equipo = models.ForeignKey(equipo, on_delete=models.CASCADE, null=False, blank=False, verbose_name='Equipo')
|
||||||
|
area = models.ForeignKey(area, on_delete=models.CASCADE, null=False, blank=False, verbose_name='Area')
|
||||||
|
descripcion = tinymce_models.HTMLField(null=False, verbose_name='Descripción')
|
||||||
|
marca = models.ForeignKey(marca, on_delete=models.CASCADE, null=False, blank=False, verbose_name='Marca')
|
||||||
|
modelo = models.CharField(max_length=250, null=True, blank=True, verbose_name='Modelo')
|
||||||
|
n_serie = models.CharField(max_length=250, unique=True, null=False, verbose_name='No Serie')
|
||||||
|
accesorios = tinymce_models.HTMLField( null=True, blank=True, verbose_name='Accesorios')
|
||||||
|
obsoleto = models.CharField(choices=STATUS2, default=STATUS2.NO, max_length=20, verbose_name='Obsoleto')
|
||||||
|
inventariado = models.CharField(max_length=250, null=True, blank=True, verbose_name='Inventariado')
|
||||||
|
n_act_fijo = models.CharField(max_length=250, null=True, blank=True, verbose_name='Numero Activo Fijo')
|
||||||
|
provedor = models.CharField(max_length=250, null=True, blank=True, verbose_name='Provedor')
|
||||||
|
c_basico = models.CharField(max_length=250, null=True, blank=True, verbose_name='Clave de cuadro basico')
|
||||||
|
fecha_alta = models.DateField(auto_now_add=True, verbose_name='Fecha alta')
|
||||||
|
fecha_actualizacion = models.DateField(auto_now=True, verbose_name='Fecha de Actualización')
|
||||||
|
localizado = models.CharField(choices=STATUS3, default=STATUS3.SI, max_length=20, verbose_name='Localizado')
|
||||||
|
accesorios2 = tinymce_models.HTMLField(null=True, blank=True, verbose_name='Accesorios 2')
|
||||||
|
accesorios3 = tinymce_models.HTMLField(null=True, blank=True, verbose_name='Accesorios 3')
|
||||||
|
accesorios4 = tinymce_models.HTMLField(null=True, blank=True, verbose_name='Accesorios 4')
|
||||||
|
accesorios5 = tinymce_models.HTMLField(null=True, blank=True, verbose_name='Accesorios 5')
|
||||||
|
fecha_inst = models.DateField(default='2022-12-31', null=True, blank=True, verbose_name='Fecha Instalacion')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.n_control
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Equipo'
|
||||||
|
verbose_name_plural = 'Equipos'
|
||||||
|
ordering = ['n_control']
|
||||||
|
|
||||||
3
inventario/tests.py
Normal file
3
inventario/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
58
inventario/views.py
Normal file
58
inventario/views.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
|
from .forms import Formularioinvequipo
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.http.response import HttpResponse
|
||||||
|
from .models import invequipo
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
def inv_equipo(request):
|
||||||
|
datos = invequipo.objects.all()
|
||||||
|
return render(request, 'invequipo.html', {"datos": datos})
|
||||||
|
|
||||||
|
def ConsultaEquipo(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
equipo = request.POST.get("n_control2")
|
||||||
|
datos = invequipo.objects.filter(id=equipo)
|
||||||
|
return render(request, 'invequipo.html', {"datos": datos})
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def crear_invequipo(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = Formularioinvequipo(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
post = form.save(commit=False)
|
||||||
|
post.save()
|
||||||
|
titulo = form.cleaned_data.get("n_control")
|
||||||
|
messages.success(request, f"El equipo {titulo} se ha creado correctamente")
|
||||||
|
return redirect("inv_equipo")
|
||||||
|
else:
|
||||||
|
for field, items in form.errors.items():
|
||||||
|
for item in items:
|
||||||
|
messages.error(request, '{}: {}'.format(field, item))
|
||||||
|
|
||||||
|
form = Formularioinvequipo()
|
||||||
|
return render(request, "crear_invequipo.html", {"form": form})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/acceder')
|
||||||
|
def Actualizarinvequipo(request, equipo_id):
|
||||||
|
instance= get_object_or_404(invequipo, pk=equipo_id)
|
||||||
|
form = Formularioinvequipo(request.POST or None, instance=instance)
|
||||||
|
context= {'form': form}
|
||||||
|
if form.is_valid():
|
||||||
|
obj= form.save(commit= False)
|
||||||
|
obj.save()
|
||||||
|
refex = form.cleaned_data.get("equipo_id")
|
||||||
|
dateact = date.today()
|
||||||
|
update = invequipo.objects.values('fecha_actualizacion').filter(id=refex).update(fecha_actualizacion=dateact)
|
||||||
|
messages.success(request, "El equipo fue actualizado")
|
||||||
|
return redirect("inv_equipo")
|
||||||
|
|
||||||
|
else:
|
||||||
|
context= {'form': form, 'error': 'Error al actualizar'}
|
||||||
|
return render(request,'actualizar_equipo.html' , context)
|
||||||
0
inventarioalmacen/__init__.py
Normal file
0
inventarioalmacen/__init__.py
Normal file
BIN
inventarioalmacen/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
inventarioalmacen/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventarioalmacen/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
inventarioalmacen/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventarioalmacen/__pycache__/admin.cpython-310.pyc
Normal file
BIN
inventarioalmacen/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
inventarioalmacen/__pycache__/admin.cpython-39.pyc
Normal file
BIN
inventarioalmacen/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
inventarioalmacen/__pycache__/apps.cpython-310.pyc
Normal file
BIN
inventarioalmacen/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user