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
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ WORKDIR /sge
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apt update && apt -y install cron && apt -y install nano

COPY . .
RUN apt update && apt -y install cron && apt -y install vim

# COPY ./application .
COPY ./application/requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install -r /requirements.txt

COPY ./cron /etc/cron.d/cron
RUN chmod 0644 /etc/cron.d/cron
RUN crontab /etc/cron.d/cron
# COPY ./application/cron /etc/cron.d/cron
# RUN chmod 0644 /etc/cron.d/cron
# RUN crontab /etc/cron.d/cron

EXPOSE 8000

CMD cron ; python manage.py migrate && python manage.py runserver 0.0.0.0:8000
#CMD tail -f /dev/null
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions app/settings.py → application/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'inflows',
'outflows',
'ai',
'costumers',
]

LOGIN_URL = 'login'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
</a>
</li>
{% endif %}
{% if perms.costumers.view_costumer %}
<li>
<a href="{% url 'costumer_list' %}" class="nav-link px-0 align-middle">
<i class="bi bi-people fs-4"></i>
<span class="ms-1">Clientes</span>
</a>
</li>
{% endif %}
{% if perms.brands.view_brand %}
<li>
<a href="{% url 'brand_list' %}" class="nav-link px-0 align-middle">
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions app/urls.py → application/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

path('', views.home, name='home'),
path('', include('suppliers.urls')),
path('', include('costumers.urls')),
path('', include('brands.urls')),
path('', include('categories.urls')),
path('', include('products.urls')),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions application/costumers/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin
from . import models


class CostumerAdmin(admin.ModelAdmin):
list_display = ('name', 'mail', 'phone', 'document_id', 'social_media','address', 'city' , 'state' , 'zip_code')
search_fields = ('name',)


admin.site.register(models.Costumer, CostumerAdmin)
6 changes: 6 additions & 0 deletions application/costumers/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CostumersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'costumers'
31 changes: 31 additions & 0 deletions application/costumers/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django import forms
from . import models


class CostumerForm(forms.ModelForm):

class Meta:
model = models.Costumer
fields = ['name', 'mail', 'phone', 'document_id', 'social_media', 'address', 'city' , 'state' , 'zip_code']
widgets = {
'name': forms.TextInput(attrs={'class': 'form-control'}),
'mail': forms.TextInput(attrs={'class': 'form-control'}),
'phone': forms.TextInput(attrs={'class': 'form-control'}),
'document_id': forms.TextInput(attrs={'class': 'form-control'}),
'social_media': forms.TextInput(attrs={'class': 'form-control'}),
'address': forms.TextInput(attrs={'class': 'form-control'}),
'city': forms.TextInput(attrs={'class': 'form-control'}),
'state': forms.TextInput(attrs={'class': 'form-control', 'maxlength': '2'}),
'zip_code': forms.TextInput(attrs={'class': 'form-control'}),
}
labels = {
'name': 'Nome',
'mail': 'E-mail',
'phone': 'Telefone',
'document_id': 'CPF/CNPJ',
'social_media': 'Site/MediaSocial',
'address': 'Endereço',
'city': 'Cidade',
'state': 'Estado',
'zip_code': 'CEP',
}
34 changes: 34 additions & 0 deletions application/costumers/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 5.0.1 on 2025-11-08 13:29

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Costumer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('mail', models.TextField(blank=True, null=True)),
('phone', models.CharField(blank=True, max_length=15)),
('document_id', models.CharField(blank=True, max_length=15)),
('address', models.CharField(blank=True, max_length=300)),
('city', models.CharField(blank=True, max_length=100)),
('state', models.CharField(blank=True, max_length=2)),
('zip_code', models.CharField(blank=True, max_length=10)),
('active', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'ordering': ['name'],
},
),
]
18 changes: 18 additions & 0 deletions application/costumers/migrations/0002_costumer_social_media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.1 on 2025-11-08 15:26

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='costumer',
name='social_media',
field=models.CharField(blank=True, max_length=15),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.1 on 2025-11-08 15:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('costumers', '0002_costumer_social_media'),
]

operations = [
migrations.AlterField(
model_name='costumer',
name='social_media',
field=models.CharField(blank=True, max_length=100),
),
]
22 changes: 22 additions & 0 deletions application/costumers/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.db import models


class Costumer(models.Model):
name = models.CharField(max_length=50)
mail = models.TextField(null=True, blank=True)
phone = models.CharField(max_length=15, blank=True)
document_id = models.CharField(max_length=15, blank=True)
social_media = models.CharField(max_length=100, blank=True)
address = models.CharField(max_length=300, blank=True)
city = models.CharField(max_length=100, blank=True)
state = models.CharField(max_length=2, blank=True)
zip_code = models.CharField(max_length=10, blank=True)
active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
ordering = ['name']

def __str__(self):
return self.name
9 changes: 9 additions & 0 deletions application/costumers/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers
from costumers.models import Costumer


class CostumerSerializer(serializers.ModelSerializer):

class Meta:
model = Costumer
fields = '__all__'
18 changes: 18 additions & 0 deletions application/costumers/templates/costumer_create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
<h3 class="display-4">Cadastrar Cliente</h3>

<div class="card">
<div class="card-body">
<form method="post" class="form">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Salvar Cliente</button>
</form>
</div>
</div>
<a href="{% url 'costumer_list' %}" class="btn btn-secondary mt-3">Cancelar e Voltar para a Lista de Clientes</a>
</div>
{% endblock %}
20 changes: 20 additions & 0 deletions application/costumers/templates/costumer_delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
<h3 class="display-4">Deletar Cliente</h3>

<div class="card">
<div class="card-body">
<p class="card-text">Tem certeza de que deseja excluir o fornecedor <strong>{{ object.name }}</strong>?</p>

<form method="post">
{% csrf_token %}
<button type="submit" class="btn btn-danger">Deletar</button>
</form>

<a href="{% url 'costumer_list' %}" class="btn btn-secondary mt-3">Cancelar e Voltar para a Lista de Clientes</a>
</div>
</div>
</div>
{% endblock %}
22 changes: 22 additions & 0 deletions application/costumers/templates/costumer_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
<h3 class="display-4">Detalhes do Cliente</h3>

<div class="card">
<div class="card-body">
<h3 class="card-title">{{ object.name }}</h3>
<p class="card-text">{{ object.mail }}</p>
<p class="card-text">{{ object.phone }}</p>
<p class="card-text">{{ object.document_id }}</p>
<p class="card-text">{{ object.address }}</p>
<p class="card-text">{{ object.city }}</p>
<p class="card-text">{{ object.state }}</p>
<p class="card-text">{{ object.zip_code }}</p>
</div>
</div>

<a href="{% url 'costumer_list' %}" class="btn btn-secondary mt-3">Voltar para a Lista de Clientes</a>
</div>
{% endblock %}
87 changes: 87 additions & 0 deletions application/costumers/templates/costumer_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{% extends 'base.html' %}

{% block title %}
SGE - Clientes
{% endblock %}

{% block content %}

<div class="row mb-3">
<div class="col-md-6">
<form method="get" action="{% url 'costumer_list' %}">
<div class="input-group">
<input type="text" class="form-control" name="name" placeholder="Nome" value="{{ request.GET.name }}">
<button type="submit" class="btn btn-primary">
<i class="bi bi-search"></i>
</button>
</div>
</form>
</div>
{% if perms.costumers.add_costumer %}
<div class="col-md-6">
<a href="{% url 'costumer_create' %}" class="btn btn-success float-end">
<i class="bi bi-plus"></i> Novo Cliente
<a href='{% url "costumers_export" %}' class='btn btn-secondary'>Exportar CSV</a>
</a>
</div>
{% endif %}
</div>

<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Nome</th>
<th>E-mail</th>
<th>Telefone</th>
<th>Site/MediaSocial</th>
<th>CPF/CNPJ</th>
<th>Endereço</th>
<th>Cidade</th>
<th>Estado</th>
<th>CEP</th>
</tr>
</thead>
<tbody>
{% for costumer in costumers %}
<tr>
<td>
<a href="{% url 'costumer_detail' costumer.id %}" class="text-primary fw-semibold">
{{ costumer.id }}
</a>
</td>
<td>{{ costumer.name }}</td>
<td>{{ costumer.mail }}</td>
<td>{{ costumer.phone }}</td>
<td>{{ costumer.document_id }}</td>
<td>{{ costumer.address }}</td>
<td>{{ costumer.city }}</td>
<td>{{ costumer.state }}</td>
<td>{{ costumer.zip_code }}</td>
<td>
<a href="{% url 'costumer_detail' costumer.id %}" class="btn btn-info btn-sm">
<i class="bi bi-eye"></i>
</a>

{% if perms.costumers.change_costumer %}
<a href="{% url 'costumer_update' costumer.id %}" class="btn btn-warning btn-sm">
<i class="bi bi-pencil"></i>
</a>
{% endif %}

{% if perms.costumers.delete_costumer %}
<a href="{% url 'costumer_delete' costumer.id %}" class="btn btn-danger btn-sm btn-delete">
<i class="bi bi-trash"></i>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

{% include 'components/_pagination.html' %}

{% endblock %}
19 changes: 19 additions & 0 deletions application/costumers/templates/costumer_update.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
<h3 class="display-4">Editar Cliente</h3>

<div class="card">
<div class="card-body">
<form method="post" class="form">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-primary">Salvar Cliente</button>
</form>
</div>
</div>

<a href="{% url 'costumer_list' %}" class="btn btn-secondary mt-3">Cancelar e Voltar para a Lista de Clientes</a>
</div>
{% endblock %}
Loading