Skip to content

Instantly share code, notes, and snippets.

View alisonamerico's full-sized avatar
🐍
💻 Working from 🏠

Alison Américo alisonamerico

🐍
💻 Working from 🏠
  • Recife, Brasil
View GitHub Profile
@alisonamerico
alisonamerico / descricao_problema.readme
Created October 19, 2020 02:09
descricao_problema
## Usando Django e Django REST framework desenvolva uma API REST que permita usuários gerenciar empréstimos.
Usuários devem ser capazes de inserir empréstimos e seus respectivos pagamentos
Usuários devem ser capazer de visualizar seus empréstimos e pagamentos
Usuários devem ser capazes de visualizar o saldo devedor de cada um dos seus empréstimos
Você pode decidir onde e como mostrar a informação
O saldo devedor nada mais é do que o quanto o cliente ainda deve para o banco
O saldo devedor deve considerar a taxa de juros do empréstimo e descontar o que já foi pago
Usuários não podem ver ou editar empréstimos ou pagamentos de outros usuários
A autenticação da API deve ser feita via token
# backend/api/models.py
from django.db import models
from phone_field import PhoneField
from django.contrib.auth import get_user_model
from datetime import date
# from rest_framework.exceptions import ValidationError
"""
A model is the single, definitive source of information about your data.
from django.db import models
from phone_field import PhoneField
from django.contrib.auth import get_user_model
from datetime import date
"""
A model is the single, definitive source of information about your data.
It contains the essential fields and behaviors of the data you’re storing.
Generally, each model maps to a single database table.
"""

Especificações técnicas de backend

Interface administrativa

Você deverá implementar uma interface administrativa na qual gestor da clínica (superusuário) poderá cadastrar especialidades, médicos e disponibilizar horários nos quais os clientes poderão marcar as consultas. Utilize a ferramenta de geração de interface administrativa automática do Django para criar esta interface (veja a documentação).

A interface administrativa deve conter as funcionalidades a seguir:

Cadastrar especialidades

Deve ser possível cadastrar as especialidades médicas (ex: CARDIOLOGIA, PEDIATRIA) que a clínica atende fornecendo as seguintes informações:

# from django.db import models
from django.contrib.auth import get_user_model
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
"""
A model is the single, definitive source of information about your data.
It contains the essential fields and behaviors of the data you’re storing.
Generally, each model maps to a single database table.
"""
# from django.db import models
from django.contrib.auth import get_user_model
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
"""
A model is the single, definitive source of information about your data.
It contains the essential fields and behaviors of the data you’re storing.
Generally, each model maps to a single database table.
"""
class Picture(models.Model):
picture = models.ImageField(upload_to='pic_folder/')
tourist_spot = models.ForeignKey('TouristSpot', on_delete=models.CASCADE)
owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
class Meta:
verbose_name = 'Picture'
verbose_name_plural = 'Pictures'
def __str__(self):
snowman on  126 is 📦 v0.1.0 via 🐍 v3.8.3
❯ docker-compose exec web pytest
========================================================================= test session starts =========================================================================
platform linux -- Python 3.8.5, pytest-6.0.0, py-1.9.0, pluggy-0.13.1
django: settings: touristspots.settings (from ini)
rootdir: /code, configfile: pytest.ini
plugins: cov-2.10.0, django-3.9.0
collected 18 items
touristspots/api/tests/test_api.py ......EE.. [ 55%]
touristspots_database | PostgreSQL Database directory appears to contain a database; Skipping initialization
touristspots_database |
touristspots_database | 2020-08-07 01:46:03.510 UTC [1] LOG: starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
touristspots_database | 2020-08-07 01:46:03.530 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
touristspots_database | 2020-08-07 01:46:03.530 UTC [1] LOG: listening on IPv6 address "::", port 5432
touristspots_database | 2020-08-07 01:46:03.737 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
touristspots_database | 2020-08-07 01:46:04.282 UTC [27] LOG: database system was interrupted; last known up at 2020-08-07 01:28:55 UTC
touristspots_database | 2020-08-07 01:46:08.861 UTC [27] LOG: database system was not properly shut down; automatic recovery in progress
touristspots_database | 2020-08-07 01:46:08.909 UTC [27] LOG: redo starts at 0/4E3DBE60
touris
touristspots_database | 2020-08-06 22:26:59.532 UTC [415] ERROR: null value in column "owner_id" violates not-null constraint
touristspots_database | 2020-08-06 22:26:59.532 UTC [415] DETAIL: Failing row contains (1, , 0101000020E610000000000000000000000000000000000000, , 2020-08-06 22:26:59.350643+00, 2020-08-06 22:26:59.350708+00, null).
touristspots_database | 2020-08-06 22:26:59.532 UTC [415] STATEMENT: INSERT INTO "api_touristspot" ("name", "geographical_location", "category", "owner_id", "created", "modified") VALUES ('', ST_GeogFromWKB('\x0101000020e610000000000000000000000000000000000000'::bytea), '', NULL, '2020-08-06T22:26:59.350643+00:00'::timestamptz, '2020-08-06T22:26:59.350708+00:00'::timestamptz) RETURNING "api_touristspot"."id"
touristspots_database | 2020-08-06 22:27:00.806 UTC [415] ERROR: null value in column "owner_id" violates not-null constraint
touristspots_database | 2020-08-06 22:27:00.806 UTC [415] DETAIL: Failing row contains (2, , 0101000020E61000000000000000000000000000000000