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
banner_form = BannerForm(self.request.POST, files=self.request.FILES) | |
documents_formset = self.get_documents_formset(data=self.request.POST, files=self.request.FILES) | |
if banner_form.is_valid() and documents_formset.is_valid(): | |
banner = banner_form.save(commit=False) | |
banner.tenant = self.request.user.tenant | |
banner.save() | |
documents_formset.instance = banner | |
documents_formset.save() |
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 Categoria(models.Model): | |
nome = models.CharField(max_length=50, unique=True) | |
categoria = models.CharField('self', related_name='subcategorias', on_delete=models.CASCADE, null=True) | |
def __str__(self): | |
return self.name |
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 PlanoAulaTurmaForm(forms.Form): | |
disciplinas = forms.ModelChoiceField( | |
label='<b>Disciplinas:</b>', | |
queryset=Disciplina.objects.none(), | |
widget=autocomplete.ModelSelect2( | |
attrs={ | |
'class': 'form-control select2bs4 select2-gray', | |
'id': 'drop-disciplinas', | |
'style': 'width: 100% !important', | |
'data-minimum-results-for-search': 10, |
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 BaseSecaoSerializer(serializers.Serializer): | |
rotulo = serializers.CharField() | |
indice = serializers.CharField() | |
conteudo = serializers.SerializerMethodField() | |
valoracao = serializers.SerializerMethodField() | |
def get_conteudo(self, obj): | |
laudo = self.root.instance | |
return [ |
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
"files.associations": { | |
"**/*.html": "html", | |
"**/templates/**/*.html": "django-html", | |
"**/templates/**/*": "django-txt", | |
"**/requirements{/**,*}.{txt,in}": "pip-requirements" | |
}, | |
"beautify.language": { | |
"js": { | |
"type": ["javascript", "json"], | |
"filename": [".jshintrc", ".jsbeautifyrc"] |
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
RELATED_SERIALIZERS = { | |
'semoventes': SemoventeLaudoSerializer, | |
'b_reprodutivas': BReprodutivaLaudoSerializer, | |
'bn_reprodutivas': BnReprodutivaLaudoSerializer, | |
'mobiliarios': MobiliarioLaudoSerializer, | |
'eletrodomesticos': EletrodomesticoLaudoSerializer, | |
'maq_equipamentos': MaqImplEquipLaudoSerializer, | |
'atividades_economicas': AtividadeEconomicaLaudoSerializer | |
} |
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 deve_gerar_laudo(self): | |
"""Verifica se deve gerar o laudo.""" | |
if not self.pk: | |
return False | |
return self.deve_avancar() and self.fluxo_atual.gera_laudo | |
def deve_avancar(self): | |
"""Verifica se o laudo deve avançar uma etapa""" | |
return self.substatus.tipo_substatus == SubStatusEtapaProjeto.AVANCAR |
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.models import Value as V | |
qs1 = ( | |
self | |
.maq_equipamentos | |
.annotate(descricao=F('item__nome')) | |
.values('marca', 'modelo', 'ano', 'valor_unitario', 'valor_reposicao', 'descricao', 'qtd') | |
) |
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 serializers | |
from .models import Music | |
class MusicSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Music | |
fields = ['name', 'genre'] | |
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 criar_extratores_atividades_economicas(modelo_importacao): | |
mapeadores = ( | |
MapeamentoAtividadeEconomicaCampo | |
.objects | |
.filter(contexto__modelo_importacao=modelo_importacao) | |
) | |
extratores = [] | |
for i, m in enumerate(mapeadores): | |
Extrator = type( |