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
5 changes: 4 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from pathlib import Path

import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand Down Expand Up @@ -124,6 +124,9 @@

STATIC_URL = 'static/'

STATICFILES_DIRS = ['static',]
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

Expand Down
32 changes: 28 additions & 4 deletions app/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
{% load static %}

<!DOCTYPE html>
<html lang="pt-br" data-bs-theme="dark">
<html lang="pt-br" data-bs-theme="light">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">

<!-- Bloco de es estilos individuais de cada página -->
{% block styles %}
{% endblock %}
</head>

<body>
{% include 'components/_header.html' %}

<div class="container-fluid">
<div class="row flex-nowrap">
<div class="col-auto col-md-0 col-xl-0 px-0 bg-dark">
<div class="d-flex flex-column align-items-center align-items-sm-start px-3 pt-2 text-white">
<div class="col-auto col-md-0 col-xl-0 px-0 ">
<hr class="m-3"/>
<div class="d-flex flex-column align-items-center align-items-sm-start px-3 pt-2">
<div class="form-check form-switch">
<label class="form-check-label" for="checkDarkMode">Modo Escuro</label>
<input class="form-check-input" type="checkbox" id="checkDarkMode" onclick="saveThemeMode(this)">
</div>
</div>
<hr class="m-3"/>
</div>
</div>
<div class="row flex-nowrap">
<div class="col-auto col-md-0 col-xl-0 px-0 ">
<div class="d-flex flex-column align-items-center align-items-sm-start px-3 pt-2">
<button class="btn btn-dark d-block d-sm-none mb-3" type="button" data-bs-toggle="collapse"
data-bs-target="#menuCollapse" aria-expanded="false" aria-controls="menuCollapse">
<i class="bi bi-list fs-4"></i>
Expand Down Expand Up @@ -86,4 +103,11 @@
{% include 'components/_footer.html' %}
</body>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="{% static 'js/themeMode.js' %}"></script>

<!-- Bloco para os scripts individuais de cada página -->
{% block scripts %}
{% endblock %}

</html>
93 changes: 93 additions & 0 deletions app/templates/components/_dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var dailySalesData = JSON.parse('{{ daily_sales_data|safe }}');
var dailySalesQuantityData = JSON.parse('{{ daily_sales_quantity_data|safe }}');

var ctxDailySales = document.getElementById('dailySalesChart').getContext('2d');
var dailySalesChart = new Chart(ctxDailySales, {
type: 'line',
data: {
labels: dailySalesData.dates,
datasets: [{
label: 'Valor em vendas',
data: dailySalesData.values,
fill: false,
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2,
tension: 0.5
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});

var ctxDailySalesQuantity = document.getElementById('dailySalesQuantityChart').getContext('2d');
var dailySalesQuantityChart = new Chart(ctxDailySalesQuantity, {
type: 'bar',
data: {
labels: dailySalesQuantityData.dates,
datasets: [{
label: 'Quantidade de Vendas',
data: dailySalesQuantityData.values,
backgroundColor: 'rgba(255, 99, 132, 0.6)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});

var productCountByCategory = JSON.parse('{{ product_count_by_category|safe }}');
var productCountByBrand = JSON.parse('{{ product_count_by_brand|safe }}');

var ctxCategory = document.getElementById('productByCategoryChart').getContext('2d');
var productByCategoryChart = new Chart(ctxCategory, {
type: 'doughnut',
data: {
labels: Object.keys(productCountByCategory),
datasets: [{
data: Object.values(productCountByCategory),
borderWidth: 1
}]
},
options: {
plugins: {
legend: {
display: false
},
}
}
});

var ctxBrand = document.getElementById('productByBrandChart').getContext('2d');
var productByBrandChart = new Chart(ctxBrand, {
type: 'doughnut',
data: {
labels: Object.keys(productCountByBrand),
datasets: [{
data: Object.values(productCountByBrand),
borderWidth: 1
}]
},
options: {
plugins: {
legend: {
display: false
},
}
}
});
});
</script>
4 changes: 2 additions & 2 deletions app/templates/components/_header.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nav class="navbar navbar-expand-lg navbar-light bg-dark">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<a class="navbar-brand text-white" href="{% url 'home' %}">Sistema de Gestão de Estoque (SGE)</a>
<a class="navbar-brand" href="{% url 'home' %}">Sistema de Gestão de Estoque (SGE)</a>
</div>
</nav>
96 changes: 4 additions & 92 deletions app/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'base.html' %}

{% load static %}

{% block title %}
SGE - Home
{% endblock %}
Expand Down Expand Up @@ -40,97 +42,7 @@ <h5 class="mb-3">Produtos por Marca</h5>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var dailySalesData = JSON.parse('{{ daily_sales_data|safe }}');
var dailySalesQuantityData = JSON.parse('{{ daily_sales_quantity_data|safe }}');

var ctxDailySales = document.getElementById('dailySalesChart').getContext('2d');
var dailySalesChart = new Chart(ctxDailySales, {
type: 'line',
data: {
labels: dailySalesData.dates,
datasets: [{
label: 'Valor em vendas',
data: dailySalesData.values,
fill: false,
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2,
tension: 0.5
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});

var ctxDailySalesQuantity = document.getElementById('dailySalesQuantityChart').getContext('2d');
var dailySalesQuantityChart = new Chart(ctxDailySalesQuantity, {
type: 'bar',
data: {
labels: dailySalesQuantityData.dates,
datasets: [{
label: 'Quantidade de Vendas',
data: dailySalesQuantityData.values,
backgroundColor: 'rgba(255, 99, 132, 0.6)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});

var productCountByCategory = JSON.parse('{{ product_count_by_category|safe }}');
var productCountByBrand = JSON.parse('{{ product_count_by_brand|safe }}');

var ctxCategory = document.getElementById('productByCategoryChart').getContext('2d');
var productByCategoryChart = new Chart(ctxCategory, {
type: 'doughnut',
data: {
labels: Object.keys(productCountByCategory),
datasets: [{
data: Object.values(productCountByCategory),
borderWidth: 1
}]
},
options: {
plugins: {
legend: {
display: false
},
}
}
});
{% include 'components/_dashboard.html' %}
<script src="{% static 'js/themeMode.js' %}"></script>

var ctxBrand = document.getElementById('productByBrandChart').getContext('2d');
var productByBrandChart = new Chart(ctxBrand, {
type: 'doughnut',
data: {
labels: Object.keys(productCountByBrand),
datasets: [{
data: Object.values(productCountByBrand),
borderWidth: 1
}]
},
options: {
plugins: {
legend: {
display: false
},
}
}
});
});
</script>
{% endblock %}
37 changes: 35 additions & 2 deletions brands/templates/brand_list.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
{% extends 'base.html' %}

{% load static %}

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

{% block content %}
{% block styles %}
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.7/dist/sweetalert2.min.css" rel="stylesheet">
{% endblock %}

{% block content %}
{% for msg in messages %}
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="check-circle-fill" fill="currentColor" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</symbol>
<symbol id="info-fill" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</symbol>
<symbol id="exclamation-triangle-fill" fill="currentColor" viewBox="0 0 16 16">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</symbol>
</svg>
{% if msg.tags == 'error' %}
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Danger:"><use xlink:href="#exclamation-triangle-fill"/></svg>
{% else %}
<div class="alert alert-{{msg.tags}} alert-dismissible fade show" role="alert">
<svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="{{msg.tags|capfirst}}:"><use xlink:href="#exclamation-triangle-fill"/></svg>
{% endif %}
<strong>{{ msg }}</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
<div class="row mb-3">
<div class="col-md-6">
<form method="get" action="{% url 'brand_list' %}">
Expand Down Expand Up @@ -51,7 +79,7 @@
<a href="{% url 'brand_update' brand.id %}" class="btn btn-warning btn-sm">
<i class="bi bi-pencil"></i>
</a>
<a href="{% url 'brand_delete' brand.id %}" class="btn btn-danger btn-sm btn-delete">
<a class="btn btn-danger btn-sm btn-delete" href="javascript:;" onClick="DeleteConfirm('{{ brand.pk }}')">
<i class="bi bi-trash"></i>
</a>
</td>
Expand All @@ -64,3 +92,8 @@
{% include 'components/_pagination.html' %}

{% endblock %}

{% block scripts %}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.7/dist/sweetalert2.all.min.js"></script>
<script src="{% static 'js/deleteConfirm.js' %}"></script>
{% endblock %}
10 changes: 7 additions & 3 deletions brands/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.urls import reverse_lazy
from django.views.generic import ListView, CreateView, DetailView, UpdateView, DeleteView
from . import models, forms
from django.shortcuts import get_object_or_404, redirect
from django.contrib import messages


class BrandListView(ListView):
Expand Down Expand Up @@ -39,6 +41,8 @@ class BrandUpdateView(UpdateView):


class BrandDeleteView(DeleteView):
model = models.Brand
template_name = 'brand_delete.html'
success_url = reverse_lazy('brand_list')
def get(self, request, pk):
object = get_object_or_404(models.Brand, pk=pk)
object.delete()
messages.success(request, 'Marca Deletada com Sucesso!')
return redirect('brand_list')
Loading