Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

```bash
$ # Get the code
$ git clone https://github.com/creativetimofficial/material-dashboard-django.git
$ cd material-dashboard-django
$ git clone https://github.com/imorlxs/django-ddsi
$ cd django-ddsi
$
$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
Expand Down
4 changes: 4 additions & 0 deletions apps/home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
from django.contrib import admin

# Register your models here.

from .models import Campana

admin.site.register(Campana)
31 changes: 31 additions & 0 deletions apps/home/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django import forms
from .models import Ingreso, Gasto # Importa los modelos
from .models import Campana

class IngresoForm(forms.ModelForm):
class Meta:
model = Ingreso
fields = ['monto_ingreso']
widgets = {
'monto_ingreso': forms.NumberInput(attrs={'class': 'form-control'}),
}

class GastoForm(forms.ModelForm):
class Meta:
model = Gasto
fields = ['monto_gasto']
widgets = {
'monto_gasto': forms.NumberInput(attrs={'class': 'form-control'}),
}

class CampanaForm(forms.ModelForm):
class Meta:
model = Campana
fields = ['id_campana', 'nombre_campana', 'tipo', 'estado', 'precio']
widgets = {
'id_campana': forms.TextInput(attrs={'class': 'form-control'}),
'nombre_campana': forms.TextInput(attrs={'class': 'form-control'}),
'tipo': forms.TextInput(attrs={'class': 'form-control'}),
'estado': forms.Select(attrs={'class': 'form-control'}),
'precio': forms.NumberInput(attrs={'class': 'form-control'}),
}
117 changes: 117 additions & 0 deletions apps/home/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Generated by Django 3.2.6 on 2024-12-05 10:50

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


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Campaña',
fields=[
('id_campaña', models.CharField(max_length=10, primary_key=True, serialize=False)),
('nombre_campaña', models.CharField(max_length=20)),
('tipo', models.CharField(max_length=20)),
('estado', models.CharField(choices=[('activa', 'Activa'), ('pendiente', 'Pendiente'), ('finalizada', 'Finalizada')], max_length=10)),
('precio', models.DecimalField(decimal_places=2, max_digits=10)),
('motivo_bajaCampaña', models.CharField(blank=True, max_length=50, null=True)),
],
),
migrations.CreateModel(
name='Empleado',
fields=[
('DNIEmpleado', models.CharField(max_length=9, primary_key=True, serialize=False)),
('nombreEmpleado', models.CharField(max_length=20)),
('apellidosEmpleado', models.CharField(max_length=40)),
('cargo', models.CharField(max_length=20)),
('telefonoEmpleado', models.CharField(max_length=20)),
('emailEmpleado', models.CharField(max_length=40)),
('direccionEmpleado', models.CharField(max_length=40)),
('fecha_nacEmpleado', models.DateField()),
('motivo_bajaEmpleado', models.CharField(blank=True, max_length=20, null=True)),
('fecha_bajaEmpleado', models.DateField(blank=True, null=True)),
('contraseña', models.CharField(max_length=4)),
],
),
migrations.CreateModel(
name='Gasto',
fields=[
('id_gasto', models.AutoField(primary_key=True, serialize=False)),
('monto_gasto', models.DecimalField(decimal_places=2, max_digits=10)),
],
),
migrations.CreateModel(
name='Ingreso',
fields=[
('id_ingreso', models.AutoField(primary_key=True, serialize=False)),
('monto_ingreso', models.DecimalField(decimal_places=2, max_digits=10)),
],
),
migrations.CreateModel(
name='Producto',
fields=[
('ID_producto', models.CharField(max_length=13, primary_key=True, serialize=False)),
('nombre_producto', models.CharField(max_length=24)),
('cantidad', models.IntegerField()),
('precio', models.DecimalField(decimal_places=2, max_digits=10)),
('tallas', models.CharField(max_length=60)),
('proveedor', models.CharField(max_length=24)),
],
),
migrations.CreateModel(
name='Socio',
fields=[
('DNISocio', models.CharField(max_length=9, primary_key=True, serialize=False)),
('nombreSocio', models.CharField(max_length=24)),
('apellidosSocio', models.CharField(max_length=24)),
('emailSocio', models.CharField(max_length=40)),
('telefonoSocio', models.CharField(max_length=9)),
('direccionSocio', models.CharField(max_length=40)),
('fecha_nacSocio', models.DateField()),
('motivo_bajaSocio', models.CharField(blank=True, max_length=60, null=True)),
('fecha_bajaSocio', models.DateField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='Ordena',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('fecha_gasto', models.DateField()),
('hora_gasto', models.DateTimeField()),
('id_gasto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.gasto')),
('id_producto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.producto')),
],
options={
'unique_together': {('id_producto', 'id_gasto')},
},
),
migrations.CreateModel(
name='Genera',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_campaña', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.campaña')),
('id_gasto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.gasto')),
],
options={
'unique_together': {('id_campaña', 'id_gasto')},
},
),
migrations.CreateModel(
name='Compra',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('fecha_compra', models.DateField()),
('dnisocio', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.socio')),
('id_producto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.producto')),
],
options={
'unique_together': {('id_producto', 'dnisocio')},
},
),
]
46 changes: 46 additions & 0 deletions apps/home/migrations/0002_auto_20241211_1801.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 3.2.6 on 2024-12-11 17:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('home', '0001_initial'),
]

operations = [
migrations.RenameModel(
old_name='Campaña',
new_name='Campana',
),
migrations.RenameField(
model_name='campana',
old_name='id_campaña',
new_name='id_campana',
),
migrations.RenameField(
model_name='campana',
old_name='motivo_bajaCampaña',
new_name='motivo_bajaCampana',
),
migrations.RenameField(
model_name='campana',
old_name='nombre_campaña',
new_name='nombre_campana',
),
migrations.RenameField(
model_name='empleado',
old_name='contraseña',
new_name='contrasena',
),
migrations.RenameField(
model_name='genera',
old_name='id_campaña',
new_name='id_campana',
),
migrations.AlterUniqueTogether(
name='genera',
unique_together={('id_campana', 'id_gasto')},
),
]
18 changes: 18 additions & 0 deletions apps/home/migrations/0003_alter_campana_id_campana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2025-01-06 18:46

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='campana',
name='id_campana',
field=models.AutoField(max_length=10, primary_key=True, serialize=False),
),
]
17 changes: 17 additions & 0 deletions apps/home/migrations/0004_remove_campana_motivo_bajacampana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.6 on 2025-01-08 10:48

from django.db import migrations


class Migration(migrations.Migration):

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

operations = [
migrations.RemoveField(
model_name='campana',
name='motivo_bajaCampana',
),
]
110 changes: 110 additions & 0 deletions apps/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,114 @@
from django.contrib.auth.models import User

# Create your models here.
# Empleado
class Empleado(models.Model):
DNIEmpleado = models.CharField(max_length=9, primary_key=True)
nombreEmpleado = models.CharField(max_length=20)
apellidosEmpleado = models.CharField(max_length=40)
cargo = models.CharField(max_length=20)
telefonoEmpleado = models.CharField(max_length=20)
emailEmpleado = models.CharField(max_length=40)
direccionEmpleado = models.CharField(max_length=40)
fecha_nacEmpleado = models.DateField()
motivo_bajaEmpleado = models.CharField(max_length=20, null=True, blank=True)
fecha_bajaEmpleado = models.DateField(null=True, blank=True)
contrasena = models.CharField(max_length=4)

def _str_(self):
return f'{self.nombreEmpleado} {self.apellidosEmpleado}'


# Socio
class Socio(models.Model):
DNISocio = models.CharField(max_length=9, primary_key=True)
nombreSocio = models.CharField(max_length=24)
apellidosSocio = models.CharField(max_length=24)
emailSocio = models.CharField(max_length=40)
telefonoSocio = models.CharField(max_length=9)
direccionSocio = models.CharField(max_length=40)
fecha_nacSocio = models.DateField()
motivo_bajaSocio = models.CharField(max_length=60, null=True, blank=True)
fecha_bajaSocio = models.DateField(null=True, blank=True)

def _str_(self):
return f'{self.nombreSocio} {self.apellidosSocio}'


# Producto
class Producto(models.Model):
ID_producto = models.CharField(max_length=13, primary_key=True)
nombre_producto = models.CharField(max_length=24)
cantidad = models.IntegerField()
precio = models.DecimalField(max_digits=10, decimal_places=2)
tallas = models.CharField(max_length=60)
proveedor = models.CharField(max_length=24)

def _str_(self):
return self.nombre_producto


# Ingreso
class Ingreso(models.Model):
id_ingreso = models.AutoField(primary_key=True)
monto_ingreso = models.DecimalField(max_digits=10, decimal_places=2)

def _str_(self):
return f'Ingreso {self.id_ingreso}'


# Gasto
class Gasto(models.Model):
id_gasto = models.AutoField(primary_key=True)
monto_gasto = models.DecimalField(max_digits=10, decimal_places=2)

def _str_(self):
return f'Gasto {self.id_gasto}'


# Campana
class Campana(models.Model):
ESTADO_CHOICES = [
('activa', 'Activa'),
('pendiente', 'Pendiente'),
('finalizada', 'Finalizada')
]

id_campana = models.AutoField(max_length=10, primary_key=True)
nombre_campana = models.CharField(max_length=20)
tipo = models.CharField(max_length=20)
estado = models.CharField(max_length=10, choices=ESTADO_CHOICES)
precio = models.DecimalField(max_digits=10, decimal_places=2)

def _str_(self):
return f'Campana {self.id_campana}'

# Genera
class Genera(models.Model):
id_campana = models.ForeignKey(Campana, on_delete=models.CASCADE)
id_gasto = models.ForeignKey(Gasto, on_delete=models.CASCADE)

class Meta:
unique_together = ('id_campana', 'id_gasto')


# Ordena
class Ordena(models.Model):
id_producto = models.ForeignKey(Producto, on_delete=models.CASCADE)
id_gasto = models.ForeignKey(Gasto, on_delete=models.CASCADE)
fecha_gasto = models.DateField()
hora_gasto = models.DateTimeField()

class Meta:
unique_together = ('id_producto', 'id_gasto')


# Compra
class Compra(models.Model):
id_producto = models.ForeignKey(Producto, on_delete=models.CASCADE)
dnisocio = models.ForeignKey(Socio, on_delete=models.CASCADE)
fecha_compra = models.DateField()

class Meta:
unique_together = ('id_producto', 'dnisocio')

16 changes: 16 additions & 0 deletions apps/home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,24 @@

# The home page
path('', views.index, name='home'),

#path('contabilidad', views.contabilidad_view, name='contabilidad'),
path('ingresos', views.ingresos_view, name='ingresos'),
path('gastos', views.gastos_view, name='gastos'),
path('contabilidad', views.contabilidad_view, name='contabilidad'),
path('eliminar_ingreso/<int:ingreso_id>/', views.eliminar_ingreso, name='eliminar_ingreso'),
path('eliminar_gasto/<int:gasto_id>/', views.eliminar_gasto, name='eliminar_gasto'),


path('campanas', views.campanas_view, name='campanas'), # Vista principal de campañas
path('eliminar_campana/<int:id_campana>/', views.eliminar_campana, name='eliminar_campana'), # Eliminar campaña
#path('editar_campana/<int:campana_id>/', views.editar_campana, name='editar_campana'), # Editar campaña


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



]

Loading