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.dispatch import receiver | |
from django.db.models.signals import post_save | |
@receiver(post_save, sender=EvaluationSkill) | |
def atualizar_nota(sender, instance, created, **kwargs): | |
avaliacao = instance.evaluation | |
avaliacao.nota = avaliacao.evaluation_skills.aggregate(models.Avg('grade'))['grade__avg'] | |
avaliacao.save(update_fields=['nota']) |
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 save(self, *args, **kwargs): | |
campos = [ | |
self.nome_campo, | |
] | |
self.nota = sum(campos) / len(campos) | |
return super().save(*args, **kwargs) |
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.core.files.storage import default_storage | |
PHOTOS_FOLDER = 'FotosFuncionarios' | |
DEFAULT = 'default.jpg' | |
def get_photo_url(self): | |
path = f'{PHOTOS_FOLDER}/{self.re}.jpg' | |
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 save_model(self, request, obj, form, change): | |
obj = super().save_model(request, obj, form, change) | |
form.save_m2m() | |
total = obj.item_pedido.aggregate(total=Sum('valor_item_pedido_qtd'))['total'] | |
obj.valor_total = total | |
obj.save(update_fields=['total']) |
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
{% load financeiro_tags %} | |
{% for _, contas in contas_por_data %} | |
{% for conta in contas %} | |
<tr> | |
<td class="center-align"> | |
<a href="{% url 'core:person_client_home' pk=conta.pessoa.id %}"> | |
<i class="material-icons prefix">home</i> | |
</a> | |
</td> |
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 zeep import Client, xsd | |
wsdl = 'link.wsdl' | |
client = Client(wsdl) | |
header = xsd.Element( | |
f'{{wsdl}}AuthenticationInfo', | |
xsd.ComplexType([ | |
xsd.Element(f'{{wsdl}}userName', xsd.String()), |
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.db import models | |
q = ( | |
Lancamento | |
.objects | |
.annotate( | |
val=models.Case( | |
When(account_from=8, then=models.F('valor') * -1), | |
default_value=models.F('valor'), |
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 rest_framework import generics | |
class LaboratoryDetail(generics.RetrieveAPIView): | |
serializer_class = LaboratorySerializer | |
def get_quetyset(self): | |
return self.request.user.labs.all() |
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 | |
class PacientFilter(filters.FilterSet): | |
name = filters.CharFilter(lookup_expr='icontains') | |
document_id = filters.CharFilter(lookup_expr='icontains') | |
class Meta: | |
model = model.Pacient | |
fields = ['name', 'document_id'] | |
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 datetime import date | |
from django.db import models | |
class EmpresaContratada(models.Model): | |
nome_empresa = models.CharField(max_length=50, blank=False, null=True) | |
contrato_sap = models.CharField(max_length=20, blank=False, null=True) | |
data_inicio_contrato = models.DateField(blank=False, null=True) | |
data_termino_contrato = models.DateField(blank=False, null=True) |