-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11ed1bf
Showing
38 changed files
with
1,017 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
venv | ||
.DS_STORE | ||
|
||
# See the name for you IDE | ||
.idea | ||
# If you are using sqlite3 | ||
*.sqlite3 | ||
# Name of your virtuan env | ||
*pyc |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.contrib import admin | ||
from .models import ( | ||
Marca, | ||
Veiculo, | ||
Pessoa, | ||
Parametros, | ||
MovRotativo, | ||
Mensalista, | ||
MovMensalista | ||
) | ||
|
||
class MovRotativoAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
'data_entrada', 'data_saida', 'valor_hora', 'veiculo', 'situacao', 'total', | ||
'horas_total', 'veiculo') | ||
|
||
def veiculo(self,obj): | ||
return obj.veiculo | ||
|
||
class MensalistaAdmin(admin.ModelAdmin): | ||
list_display = ('veiculo', 'inicio', 'valor_mes') | ||
|
||
class MovMensalistaAdmin(admin.ModelAdmin): | ||
list_display = ('mensalista', 'data_pagamento', 'total_pagamento') | ||
|
||
admin.site.register(Marca) | ||
admin.site.register(Veiculo) | ||
admin.site.register(Pessoa) | ||
admin.site.register(Parametros) | ||
admin.site.register(MovRotativo, MovRotativoAdmin) | ||
admin.site.register(Mensalista, MensalistaAdmin) | ||
admin.site.register(MovMensalista, MovMensalistaAdmin) | ||
|
||
|
||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CoreConfig(AppConfig): | ||
name = 'core' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.forms import ModelForm | ||
from .models import Pessoa, Veiculo, MovRotativo, Mensalista, MovMensalista | ||
|
||
|
||
class PessoaForm(ModelForm): | ||
class Meta: | ||
model = Pessoa | ||
fields = '__all__' | ||
|
||
|
||
class VeiculoForm(ModelForm): | ||
class Meta: | ||
model = Veiculo | ||
fields = '__all__' | ||
|
||
|
||
class MovRotativoForm(ModelForm): | ||
class Meta: | ||
model = MovRotativo | ||
fields = '__all__' | ||
|
||
|
||
class MensalistaForm(ModelForm): | ||
class Meta: | ||
model = Mensalista | ||
fields = '__all__' | ||
|
||
class MovMensalistaForm(ModelForm): | ||
class Meta: | ||
model = MovMensalista | ||
fields = '__all__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 18:12 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Marca', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('nome', models.CharField(max_length=50)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Pessoa', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('nome', models.CharField(max_length=100)), | ||
('endereco', models.CharField(max_length=200)), | ||
('telefone', models.CharField(max_length=20)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Veiculo', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('placa', models.CharField(max_length=7)), | ||
('cor', models.CharField(max_length=15)), | ||
('observacoes', models.TextField()), | ||
('marca', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Marca')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 18:22 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='veiculo', | ||
name='proprietario', | ||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, to='core.Pessoa'), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 18:49 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0002_veiculo_proprietario'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Parametros', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('valor_hora', models.DecimalField(decimal_places=2, max_digits=5)), | ||
('valor_mes', models.DecimalField(decimal_places=2, max_digits=6)), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='veiculo', | ||
name='marca', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.Marca'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 19:02 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0003_auto_20200210_1549'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MovRotativo', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('data_entrada', models.DateTimeField()), | ||
('data_saida', models.DateTimeField(blank=True, null=True)), | ||
('valor_hora', models.DecimalField(decimal_places=2, max_digits=5)), | ||
('situacao', models.BooleanField(default=False)), | ||
('veiculo', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.Veiculo')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 19:06 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0004_movrotativo'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='movrotativo', | ||
name='situacao', | ||
field=models.CharField(choices=[('PG', 'PAGO'), ('PE', 'PENDENTE')], default='PENDENTE', max_length=2), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 19:23 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0005_auto_20200210_1606'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='movrotativo', | ||
name='situacao', | ||
field=models.CharField(choices=[('PG', 'Pago'), ('PE', 'Pendente')], default='PE', max_length=2), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 20:27 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0006_auto_20200210_1623'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Mensalista', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('inicio', models.DateTimeField()), | ||
('valor_mes', models.DecimalField(decimal_places=2, max_digits=5)), | ||
('veiculo', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.Veiculo')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 20:28 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0007_mensalista'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='mensalista', | ||
name='inicio', | ||
field=models.DateField(), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.0.3 on 2020-02-10 20:33 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0008_auto_20200210_1728'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MovMensalista', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('data_pagamento', models.DateField()), | ||
('total_pagamento', models.DecimalField(decimal_places=2, max_digits=6)), | ||
('mensalista', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.Mensalista')), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from django.db import models | ||
import math | ||
|
||
|
||
# Create your models here. | ||
|
||
|
||
class Pessoa(models.Model): | ||
nome = models.CharField(max_length=100) | ||
endereco = models.CharField(max_length=200) | ||
telefone = models.CharField(max_length=20) | ||
|
||
def __str__(self): | ||
return self.nome + " " + self.endereco + " " + self.telefone | ||
|
||
class Marca(models.Model): | ||
nome = models.CharField(max_length=50) | ||
|
||
def __str__(self): | ||
return self.nome | ||
|
||
|
||
class Veiculo(models.Model): | ||
marca = models.ForeignKey('Marca', on_delete=models.PROTECT) | ||
proprietario = models.ForeignKey('Pessoa', on_delete=models.PROTECT) | ||
placa = models.CharField(max_length=7) | ||
cor = models.CharField(max_length=15) | ||
observacoes = models.TextField() | ||
|
||
|
||
def __str__(self): | ||
return self.marca.nome + " " + self.placa + " " + self.cor + " " + self.proprietario.nome | ||
|
||
class Parametros(models.Model): | ||
valor_hora = models.DecimalField(max_digits=5, decimal_places=2) | ||
valor_mes = models.DecimalField(max_digits=6, decimal_places=2) | ||
|
||
def __str__(self): | ||
return "Parâmetros Gerais Sistema" | ||
|
||
class MovRotativo(models.Model): | ||
|
||
Pago = 'PG' | ||
Pendente = 'PE' | ||
|
||
SITUACAO = [(Pago, 'Pago'), (Pendente, 'Pendente'),] | ||
|
||
data_entrada = models.DateTimeField(auto_now=False) | ||
data_saida = models.DateTimeField(auto_now=False, null=True, blank=True) | ||
valor_hora = models.DecimalField(max_digits=5, decimal_places=2) | ||
veiculo = models.ForeignKey('Veiculo', on_delete=models.PROTECT) | ||
situacao = models.CharField( | ||
max_length=2, | ||
choices = SITUACAO, | ||
default=Pendente | ||
) | ||
|
||
def __str__(self): | ||
return self.veiculo.placa | ||
|
||
def horas_total(self): | ||
try: | ||
return math.ceil((self.data_saida - self.data_entrada).total_seconds() / 3600) | ||
except: | ||
pass | ||
|
||
def total(self): | ||
try: | ||
return self.valor_hora * self.horas_total() | ||
except: | ||
pass | ||
|
||
class Mensalista(models.Model): | ||
veiculo = models.ForeignKey('Veiculo', on_delete=models.PROTECT) | ||
inicio = models.DateField() | ||
valor_mes = models.DecimalField(max_digits=5, decimal_places=2) | ||
|
||
def __str__(self): | ||
return str(self.veiculo) + '-' + str(self.inicio) | ||
|
||
class MovMensalista(models.Model): | ||
mensalista = models.ForeignKey('Mensalista', on_delete=models.PROTECT) | ||
data_pagamento = models.DateField() | ||
total_pagamento = models.DecimalField(max_digits=6, decimal_places=2) | ||
|
||
|
||
def __str__(self): | ||
return str(self.mensalista) + ' - ' + str(self.total_pagamento) |
Oops, something went wrong.