Skip to content

Commit

Permalink
refa: finalizando refatoracao das views
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocpv committed Sep 26, 2024
1 parent 01dd0a9 commit 784ddca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/tupan/estacoes/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.1 on 2024-09-23 13:45
# Generated by Django 5.1.1 on 2024-09-26 22:15

import django.db.models.deletion
from django.db import migrations, models
Expand Down Expand Up @@ -59,7 +59,7 @@ class Migration(migrations.Migration):
('nome', models.CharField(max_length=127)),
('topico', models.CharField(help_text='Tópico do broker MQTT', max_length=127)),
('ativo', models.BooleanField(default=True)),
('endereco', models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='estacoes.endereco')),
('endereco', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='estacoes.endereco')),
('parametros', models.ManyToManyField(blank=True, to='estacoes.parametro')),
],
options={
Expand Down
4 changes: 2 additions & 2 deletions src/tupan/estacoes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get(self, request, *args, **kwargs):
serializer = EstacaoSerializer(estacoes, many=True)
return Response(serializer.data)
def post(self, request, *args, **kwargs):
serializer = EstacaoSerializer(data=request.body)
serializer = EstacaoSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
Expand All @@ -32,7 +32,7 @@ def put(self, request, pk, *args, **kwargs):
estacao = Estacao.objects.get(pk=pk)
except Estacao.DoesNotExist:
return Response(status=status.HTTP_404_NOT_FOUND)
serializer = EstacaoSerializer(estacao, data=request.body)
serializer = EstacaoSerializer(estacao, data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
Expand Down

0 comments on commit 784ddca

Please sign in to comment.