Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CRUD Animais da Fazenda
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O Bar da Lora
CRUD Animais da Fazenda
Commits
9172991b
You need to sign in or sign up before continuing.
Commit
9172991b
authored
Apr 16, 2026
by
Natã Frederico Sangalletti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nova funcão editar e deletar e ccs reformado
parent
90b40f1e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
394 additions
and
88 deletions
+394
-88
app.py
app/app.py
+22
-0
relatorio.md
relatorio.md
+4
-9
style.css
static/style.css
+248
-53
cadastrar.html
templates/cadastrar.html
+29
-8
editar.html
templates/editar.html
+46
-0
index.html
templates/index.html
+45
-18
No files found.
app/app.py
View file @
9172991b
...
...
@@ -85,6 +85,28 @@ def cadastrar():
return
render_template
(
'cadastrar.html'
)
@app.route
(
'/editar/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
editar
(
id
):
animal
=
Animal
.
query
.
get_or_404
(
id
)
if
request
.
method
==
'POST'
:
try
:
animal
.
nome
=
request
.
form
[
'nome'
]
animal
.
especie
=
request
.
form
[
'especie'
]
animal
.
idade
=
int
(
request
.
form
[
'idade'
])
animal
.
peso
=
float
(
request
.
form
[
'peso'
])
db
.
session
.
commit
()
gerar_markdown
()
return
redirect
(
url_for
(
'index'
))
except
Exception
as
e
:
db
.
session
.
rollback
()
return
f
"Erro ao editar: {str(e)}"
return
render_template
(
'editar.html'
,
animal
=
animal
)
@app.route
(
'/delete/<int:id>'
)
def
delete
(
id
):
animal
=
Animal
.
query
.
get_or_404
(
id
)
...
...
relatorio.md
View file @
9172991b
# Relatório de Animais
## Mimosa
-
Espécie: Vaca
-
Idade: 2 anos
-
Peso: 300.0 kg
## Pintadinha
-
Espécie: Galinha
-
Idade: 4 anos
-
Peso: 1.5 kg
## Marcos
-
Espécie: Pitcher
-
Idade: 17 anos
-
Peso: 67.0 kg
static/style.css
View file @
9172991b
html
{
*
{
margin
:
0
;
padding
:
0
;
box-sizing
:
border-box
;
}
body
{
font-family
:
"Lexend"
,
sans-serif
;
background
:
linear-gradient
(
135deg
,
#f8fafc
,
#eef2f7
);
color
:
#1f2937
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
padding-top
:
100px
;
font-family
:
'Lexend'
,
sans-serif
;
background
:
linear-gradient
(
135deg
,
#667eea
0%
,
#764ba2
100%
);
min-height
:
100vh
;
padding
:
20px
;
}
.container
{
max-width
:
1000px
;
margin
:
0
auto
;
background
:
white
;
border-radius
:
12px
;
box-shadow
:
0
10px
40px
rgba
(
0
,
0
,
0
,
0.15
);
padding
:
40px
;
}
/* Header */
header
{
text-align
:
center
;
margin-bottom
:
30px
;
}
header
h1
{
color
:
#333
;
font-size
:
2.5rem
;
margin-bottom
:
10px
;
}
.subtitle
{
color
:
#666
;
font-size
:
1.1rem
;
font-weight
:
300
;
}
/* Headings */
h1
{
font-size
:
26px
;
color
:
#333
;
font-size
:
2rem
;
margin-bottom
:
30px
;
text-align
:
center
;
}
/* Actions */
.actions
{
display
:
flex
;
gap
:
10px
;
margin-bottom
:
30px
;
flex-wrap
:
wrap
;
}
/* Buttons */
.btn
{
display
:
inline-block
;
padding
:
12px
24px
;
border-radius
:
6px
;
text-decoration
:
none
;
font-weight
:
600
;
margin-bottom
:
35px
;
color
:
#111827
;
letter-spacing
:
-0.5px
;
border
:
none
;
cursor
:
pointer
;
transition
:
all
0.3s
ease
;
font-size
:
0.95rem
;
}
.btn-primary
{
background
:
linear-gradient
(
135deg
,
#667eea
0%
,
#764ba2
100%
);
color
:
white
;
}
form
{
background
:
#ffffff
;
padding
:
32px
28px
;
border-radius
:
14px
;
width
:
340px
;
box-shadow
:
0
15px
35px
rgba
(
0
,
0
,
0
,
0.08
);
border
:
1px
solid
#e5e7eb
;
line-height
:
2.2
;
transition
:
0.3s
;
.btn-primary
:hover
{
transform
:
translateY
(
-2px
);
box-shadow
:
0
5px
15px
rgba
(
102
,
126
,
234
,
0.4
);
}
.btn-secondary
{
background
:
#f0f0f0
;
color
:
#333
;
border
:
1px
solid
#ddd
;
}
form
:hover
{
transform
:
translateY
(
-3px
);
box-shadow
:
0
20px
45px
rgba
(
0
,
0
,
0
,
0.12
);
.btn-secondary
:hover
{
background
:
#e5e5e5
;
}
.btn-edit
{
background
:
#3498db
;
color
:
white
;
padding
:
8px
16px
;
font-size
:
0.9rem
;
}
input
{
width
:
100%
;
padding
:
10px
12px
;
margin-top
:
6px
;
margin-bottom
:
14px
;
.btn-edit
:hover
{
background
:
#2980b9
;
}
.btn-delete
{
background
:
#e74c3c
;
color
:
white
;
padding
:
8px
16px
;
font-size
:
0.9rem
;
}
.btn-delete
:hover
{
background
:
#c0392b
;
}
/* Table */
.table-responsive
{
overflow-x
:
auto
;
border-radius
:
8px
;
border
:
1px
solid
#d1d5db
;
font-size
:
14px
;
background
:
#f9fafb
;
transition
:
all
0.2s
ease
;
border
:
1px
solid
#eee
;
}
.animals-table
{
width
:
100%
;
border-collapse
:
collapse
;
background
:
white
;
}
.animals-table
thead
{
background
:
linear-gradient
(
135deg
,
#667eea
0%
,
#764ba2
100%
);
color
:
white
;
}
.animals-table
th
{
padding
:
16px
;
text-align
:
left
;
font-weight
:
600
;
font-size
:
1rem
;
}
.animals-table
td
{
padding
:
14px
16px
;
border-bottom
:
1px
solid
#f0f0f0
;
}
.animals-table
tbody
tr
{
transition
:
background-color
0.2s
ease
;
}
.animals-table
tbody
tr
:hover
{
background-color
:
#f9f9f9
;
}
.animals-table
tbody
tr
:last-child
td
{
border-bottom
:
none
;
}
.actions-column
{
display
:
flex
;
gap
:
8px
;
flex-wrap
:
wrap
;
}
/* Forms */
.form
{
max-width
:
600px
;
margin
:
0
auto
;
}
.form-group
{
margin-bottom
:
20px
;
display
:
flex
;
flex-direction
:
column
;
}
.form-group
label
{
color
:
#333
;
font-weight
:
600
;
margin-bottom
:
8px
;
font-size
:
1rem
;
}
input
:focus
{
.form-group
input
{
padding
:
12px
;
border
:
2px
solid
#ddd
;
border-radius
:
6px
;
font-family
:
'Lexend'
,
sans-serif
;
font-size
:
1rem
;
transition
:
border-color
0.3s
ease
;
}
.form-group
input
:focus
{
outline
:
none
;
border-color
:
#6b7280
;
background
:
#ffffff
;
box-shadow
:
0
0
0
3px
rgba
(
107
,
114
,
128
,
0.15
);
border-color
:
#667eea
;
box-shadow
:
0
0
0
3px
rgba
(
102
,
126
,
234
,
0.1
);
}
.form-group
input
::placeholder
{
color
:
#999
;
}
button
{
width
:
100%
;
padding
:
11px
;
border
:
none
;
border-radius
:
8px
;
background
:
#111827
;
color
:
#ffffff
;
font-size
:
14px
;
font-weight
:
500
;
cursor
:
pointer
;
transition
:
all
0.25s
ease
;
.form-actions
{
display
:
flex
;
gap
:
12px
;
margin-top
:
30px
;
justify-content
:
center
;
}
/* Empty State */
.empty-state
{
text-align
:
center
;
padding
:
60px
20px
;
color
:
#666
;
}
.empty-state
p
{
font-size
:
1.2rem
;
margin-bottom
:
20px
;
}
/* Responsive */
@media
(
max-width
:
768px
)
{
.container
{
padding
:
20px
;
}
header
h1
{
font-size
:
2rem
;
}
.actions-column
{
flex-direction
:
column
;
}
.btn-edit
,
.btn-delete
{
width
:
100%
;
text-align
:
center
;
}
.form-actions
{
flex-direction
:
column
;
}
.form-actions
.btn
{
width
:
100%
;
text-align
:
center
;
}
.animals-table
th
,
.animals-table
td
{
padding
:
10px
;
font-size
:
0.9rem
;
}
}
@media
(
max-width
:
480px
)
{
body
{
padding
:
10px
;
}
.container
{
padding
:
15px
;
border-radius
:
8px
;
}
header
h1
{
font-size
:
1.5rem
;
}
.subtitle
{
font-size
:
0.95rem
;
}
.btn
{
padding
:
10px
16px
;
font-size
:
0.85rem
;
}
button
:hover
{
background
:
#1f2937
;
transform
:
translateY
(
-1px
)
;
box-shadow
:
0
6px
15px
rgba
(
0
,
0
,
0
,
0.15
);
.animals-table
th
,
.animals-table
td
{
padding
:
8px
;
}
}
templates/cadastrar.html
View file @
9172991b
...
...
@@ -12,14 +12,35 @@
</head>
<body>
<h1>
Novo Animal
</h1>
<form
method=
"POST"
>
Nome:
<input
type=
"text"
name=
"nome"
required
><br>
Especie:
<input
type=
"text"
name=
"especie"
required
><br>
Idade:
<input
type=
"number"
name=
"idade"
required
><br>
Peso:
<input
type=
"number"
step=
"any"
name=
"peso"
required
><br>
<button
type=
"submit"
>
Salvar
</button>
</form>
<div
class=
"container"
>
<h1>
Novo Animal
</h1>
<form
method=
"POST"
class=
"form"
>
<div
class=
"form-group"
>
<label
for=
"nome"
>
Nome:
</label>
<input
type=
"text"
id=
"nome"
name=
"nome"
required
placeholder=
"Digite o nome do animal"
>
</div>
<div
class=
"form-group"
>
<label
for=
"especie"
>
Espécie:
</label>
<input
type=
"text"
id=
"especie"
name=
"especie"
required
placeholder=
"Ex: Galinha, Vaca, Ovelha"
>
</div>
<div
class=
"form-group"
>
<label
for=
"idade"
>
Idade (anos):
</label>
<input
type=
"number"
id=
"idade"
name=
"idade"
required
placeholder=
"0"
min=
"0"
>
</div>
<div
class=
"form-group"
>
<label
for=
"peso"
>
Peso (kg):
</label>
<input
type=
"number"
id=
"peso"
name=
"peso"
step=
"0.01"
required
placeholder=
"0.00"
min=
"0"
>
</div>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Salvar
</button>
<a
href=
"/"
class=
"btn btn-secondary"
>
Cancelar
</a>
</div>
</form>
</div>
</body>
</html>
templates/editar.html
0 → 100644
View file @
9172991b
<!DOCTYPE html>
<html
lang=
"PT-br"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='style.css') }}"
>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
href=
"https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap"
rel=
"stylesheet"
>
<title>
Editar Animal
</title>
</head>
<body>
<div
class=
"container"
>
<h1>
Editar Animal
</h1>
<form
method=
"POST"
class=
"form"
>
<div
class=
"form-group"
>
<label
for=
"nome"
>
Nome:
</label>
<input
type=
"text"
id=
"nome"
name=
"nome"
value=
"{{ animal.nome }}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"especie"
>
Espécie:
</label>
<input
type=
"text"
id=
"especie"
name=
"especie"
value=
"{{ animal.especie }}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"idade"
>
Idade (anos):
</label>
<input
type=
"number"
id=
"idade"
name=
"idade"
value=
"{{ animal.idade }}"
required
>
</div>
<div
class=
"form-group"
>
<label
for=
"peso"
>
Peso (kg):
</label>
<input
type=
"number"
id=
"peso"
name=
"peso"
step=
"0.01"
value=
"{{ animal.peso }}"
required
>
</div>
<div
class=
"form-actions"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Salvar Alterações
</button>
<a
href=
"/"
class=
"btn btn-secondary"
>
Cancelar
</a>
</div>
</form>
</div>
</body>
</html>
templates/index.html
View file @
9172991b
...
...
@@ -12,24 +12,51 @@
</head>
<body>
<h1>
Animais Cadastrados
</h1>
<a
href=
"/cadastrar"
><button>
Novo Cadastro
</button></a>
<table
border=
"1"
>
<tr>
<th>
Nome
</th>
<th>
Espécie
</th>
<th>
Idade
</th>
<th>
Peso
</th>
</tr>
{% for a in animais %}
<tr>
<td>
{{ a.nome }}
</td>
<td>
{{ a.especie }}
</td>
<td>
{{ a.idade }}
</td>
<td>
{{ a.peso }}
</td>
</tr>
{% endfor %}
</table>
<div
class=
"container"
>
<header>
<h1>
🐄 Animais da Fazenda
</h1>
<p
class=
"subtitle"
>
Gerenciamento de animais cadastrados
</p>
</header>
<div
class=
"actions"
>
<a
href=
"/cadastrar"
class=
"btn btn-primary"
>
➕ Novo Cadastro
</a>
</div>
{% if animais %}
<div
class=
"table-responsive"
>
<table
class=
"animals-table"
>
<thead>
<tr>
<th>
Nome
</th>
<th>
Espécie
</th>
<th>
Idade
</th>
<th>
Peso (kg)
</th>
<th>
Ações
</th>
</tr>
</thead>
<tbody>
{% for a in animais %}
<tr>
<td><strong>
{{ a.nome }}
</strong></td>
<td>
{{ a.especie }}
</td>
<td>
{{ a.idade }} anos
</td>
<td>
{{ a.peso }}
</td>
<td
class=
"actions-column"
>
<a
href=
"/editar/{{ a.id }}"
class=
"btn btn-edit"
>
✏️ Editar
</a>
<a
href=
"/delete/{{ a.id }}"
class=
"btn btn-delete"
onclick=
"return confirm('Tem certeza que deseja deletar?')"
>
🗑️ Deletar
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div
class=
"empty-state"
>
<p>
Nenhum animal cadastrado ainda.
</p>
<a
href=
"/cadastrar"
class=
"btn btn-primary"
>
Cadastre o primeiro animal
</a>
</div>
{% endif %}
</div>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment