This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" MODEL """ | |
class Agendas (models.Model): | |
id = models.AutoField(primary_key=True) | |
pessoa = models.ForeignKey( | |
Medicos, related_name='Medicos', on_delete=models.CASCADE) | |
dia = models.DateField() | |
horario = models.ManyToManyField('Horas') | |
class Meta: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" MODELS """ | |
class Horas (models.Model): | |
id = models.AutoField(primary_key=True) | |
hora = models.TimeField() | |
status = models.BooleanField(default=True) | |
class Meta: | |
verbose_name_plural = "Horas" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PessoasFilter(BaseFilterBackend): | |
def filter_queryset(self, request, queryset, view): | |
return queryset.filter(departamentos__id__in=request.query_params.getlist('departamentos')) | |
class PessoasViewSet(viewsets.ModelViewSet): | |
queryset = Pessoas.objects.all() | |
serializer_class = Pessoaserializer | |
filter_backends = [SearchFilter, DjangoFilterBackend] | |
search_fields = ['nome'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarcacaoSerializer(serializers.ModelSerializer): | |
agenda = AgendasSerializer() | |
class Meta: | |
model = Consultas | |
fields = ['id', 'agenda', 'horario', 'data_agendamento'] | |
def create(self, validated_data): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_representation(self, instance): | |
data = super(AgendasSerializer, self).to_representation(instance) | |
def validata_datas(dia, hora, agenda_id): | |
if Validators().data_expirada(dia, hora): | |
return False | |
return True | |
data['horario'] = list(filter(lambda hora: validata_datas(data['dia'], hora, data['id']), data['horario'])) | |
if not data['horario']: | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AgendasSerializer(serializers.ModelSerializer): | |
horario = serializers.SlugRelatedField( | |
many=True, | |
read_only=True, | |
slug_field='hora', | |
) | |
def to_representation(self, instance): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MODELS | |
class Horas (models.Model): | |
id = models.AutoField(primary_key=True) | |
hora = models.TimeField() | |
status = models.BooleanField(default=True) | |
#class Meta... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.db import models | |
from django.utils import timezone | |
class Setor (models.Model): | |
id = models.AutoField(primary_key=True) | |
nome = models.CharField(max_length=255, unique=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table style="width:100%"> | |
<tr> | |
<td> <input type="radio" name="radio" checked id="boolean"> | |
<label></label> | |
</td> | |
</tr> | |
</table> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from "styled-components"; | |
import colors from "@/styles/colors"; | |
export const sizes = { | |
minimun: '0.563rem', | |
xxs: '0.625rem', | |
xs: '0.75rem', | |
small: '0.875rem', | |
medium: '1rem', | |
large: '1.125rem', |