Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ht 01 #1

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ __pycache__/
# venv
env
venv
.idea/
*/migrations/*
!*/migrations/__init__.py
/apps/home/migrations/


# other
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions apps/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.urls import path
from .views import login_view, register_user
from django.contrib.auth.views import LogoutView
app_name = 'authentication'

urlpatterns = [
path('login/', login_view, name="login"),
Expand Down
2 changes: 1 addition & 1 deletion apps/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def login_view(request):
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return redirect("/")
return redirect("/inicio")
else:
msg = 'Invalid credentials'
else:
Expand Down
39 changes: 39 additions & 0 deletions apps/home/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from django import forms
from apps.home.models import Inventario, EventoCaledario


#crea formulario para registarr inventario
class RegistrarInventarioForm(forms.ModelForm):
class Meta:
model = Inventario
fields = ('nombre', 'descripcion', 'cantidad', 'precio', 'categoria', 'estado')
widgets = {
'nombre': forms.TextInput(attrs={'class': 'form-control'}),
'descripcion': forms.TextInput(attrs={'class': 'form-control'}),
'cantidad': forms.TextInput(attrs={'class': 'form-control'}),
'precio': forms.TextInput(attrs={'class': 'form-control'}),
'categoria': forms.TextInput(attrs={'class': 'form-control'}),
'estado': forms.Select(attrs={'class': 'form-control'}), # Usamos forms.Select para el campo "estado"
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['estado'].widget.attrs.update({'class': 'form-control'})

class EventoCalendarioForm(forms.ModelForm):

class Meta:
model = EventoCaledario
fields = ('titulo', 'descripcion', 'fecha_inicio' , 'fecha_fin')
widgets = {
'titulo': forms.TextInput(attrs={'class': 'form-control'}),
'descripcion': forms.TextInput(attrs={'class': 'form-control'}),
'fecha_inicio': forms.DateTimeInput(),
'fecha_fin': forms.DateTimeInput(),
}

def __init__(self, *args, **kwargs):
super(EventoCalendarioForm, self).__init__(*args, **kwargs)
self.fields['fecha_inicio'].widget.attrs.update({'class': 'form-control'})
self.fields['fecha_fin'].widget.attrs.update({'class': 'form-control'})

26 changes: 26 additions & 0 deletions apps/home/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.6 on 2023-07-26 22:37

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Producto',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nombre', models.CharField(max_length=50)),
('descripcion', models.CharField(max_length=50)),
('precio', models.CharField(max_length=50)),
('imagen', models.ImageField(blank=True, null=True, upload_to='productos')),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now_add=True)),
],
),
]
34 changes: 34 additions & 0 deletions apps/home/migrations/0002_auto_20230728_1654.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2023-07-28 16:54

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('home', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Inventario',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nombre', models.CharField(max_length=100)),
('descripcion', models.CharField(max_length=100)),
('cantidad', models.IntegerField()),
('precio', models.IntegerField()),
('categoria', models.CharField(max_length=100)),
('estado', models.CharField(max_length=100)),
('fecha_creacion', models.DateField()),
('fecha_actualizacion', models.DateField()),
('usuario', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.DeleteModel(
name='Producto',
),
]
18 changes: 18 additions & 0 deletions apps/home/migrations/0003_alter_inventario_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2023-07-28 16:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('home', '0002_auto_20230728_1654'),
]

operations = [
migrations.AlterField(
model_name='inventario',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]
18 changes: 18 additions & 0 deletions apps/home/migrations/0004_alter_inventario_estado.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2023-07-28 18:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('home', '0003_alter_inventario_id'),
]

operations = [
migrations.AlterField(
model_name='inventario',
name='estado',
field=models.IntegerField(choices=[(1, 'Activo'), (2, 'Inactivo')], default=1),
),
]
61 changes: 61 additions & 0 deletions apps/home/migrations/0005_auto_20230728_1900.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 3.2.6 on 2023-07-28 19:00

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('home', '0004_alter_inventario_estado'),
]

operations = [
migrations.AlterField(
model_name='inventario',
name='cantidad',
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='inventario',
name='categoria',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='inventario',
name='descripcion',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='inventario',
name='estado',
field=models.IntegerField(choices=[(1, 'Activo'), (2, 'Inactivo')]),
),
migrations.AlterField(
model_name='inventario',
name='fecha_actualizacion',
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name='inventario',
name='fecha_creacion',
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name='inventario',
name='nombre',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='inventario',
name='precio',
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='inventario',
name='usuario',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
26 changes: 26 additions & 0 deletions apps/home/migrations/0006_eventocaledario.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.6 on 2023-08-08 16:03

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('home', '0005_auto_20230728_1900'),
]

operations = [
migrations.CreateModel(
name='EventoCaledario',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('titulo', models.CharField(blank=True, max_length=100, null=True)),
('descripcion', models.CharField(blank=True, max_length=100, null=True)),
('fecha_inicio', models.DateField(blank=True, null=True)),
('usuario', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
34 changes: 34 additions & 0 deletions apps/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,37 @@

# Create your models here.


class Inventario(models.Model):

ACTIVO = 1
INACTIVO = 2

ESTADO_CHOICES = (
(ACTIVO, 'Activo'),
(INACTIVO, 'Inactivo'),
)

nombre = models.CharField(max_length=100, null=True, blank=True)
descripcion = models.CharField(max_length=100, null=True, blank=True)
cantidad = models.IntegerField(null=True, blank=True)
precio = models.IntegerField(null=True, blank=True)
categoria = models.CharField(max_length=100, null=True, blank=True)
estado = models.IntegerField(choices=ESTADO_CHOICES)
fecha_creacion = models.DateField(null=True, blank=True)
fecha_actualizacion = models.DateField(null=True, blank=True)
usuario = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)

def __str__(self):
return self.nombre

class EventoCaledario(models.Model):

titulo = models.CharField(max_length=100, null=True, blank=True)
descripcion = models.CharField(max_length=100, null=True, blank=True)
fecha_inicio = models.DateTimeField(null=True, blank=True)
fecha_fin = models.DateTimeField(null=True, blank=True)
usuario = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)

def __str__(self):
return self.titulo
7 changes: 7 additions & 0 deletions apps/home/templatetags/custom_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import template

register = template.Library()

@register.filter
def get_field_value(obj, field_name):
return getattr(obj, field_name, "")
8 changes: 0 additions & 8 deletions apps/home/tests.py

This file was deleted.

18 changes: 16 additions & 2 deletions apps/home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@
from django.urls import path, re_path
from apps.home import views

app_name = 'home'

urlpatterns = [

# The home page
path('', views.index, name='home'),
#Pagina de inicio
path('', views.StaticPageView.as_view(), name='static_page'),
path('inicio', views.index.as_view(), name='inicio'),
# Inventario
path('registrar-inventario', views.RegistrarInventarioView.as_view(), name='registrar_inventario'),
path('listar-inventario', views.ListarInventarioView.as_view(), name='listar_inventario'),
path('detalle-inventario/<int:pk>', views.DetalleInventarioView.as_view(), name='detalle_inventario'),

#DASHBOARD
path('inventario-chart', views.inventario_chart, name='inventario_chart'),

#CALENDARIO
path('calendario', views.Calendarioview.as_view(), name='calendario'),
path('actualizar-evento', views.UpdateCalendarioView.as_view(), name='actualizar_evento'),

# Matches any html file
re_path(r'^.*\.*', views.pages, name='pages'),
Expand Down
Loading