This file contains 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 collections import defaultdict | |
from typing import Callable | |
# Store all event listeners | |
LISTENERS_REGISTRY = defaultdict(list) | |
# events | |
PAYMENT_STATUS_CHANGED = 'payment_status_changed' | |
CONTACT_INFO = 'contact_info' |
This file contains 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 Analisador(models.Model): | |
nome = models.CharField(max_length=50) | |
def __str__(self): | |
return self.nome | |
def diretorio_anexo(instance, filename): | |
return f'anexos/{instance.analisador_id}/{filename}' |
This file contains 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 collections import defaultdict | |
from typing import Callable | |
REGISTRY: defaultdict = defaultdict(list) | |
def channel_handler(channel: str) -> Callable: | |
def decorator(func: Callable) -> Callable: | |
REGISTRY[channel].append(func) |
This file contains 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
const serialize = function (data) { | |
const formData = new FormData(); | |
for ([key, value] of Object.entries(data)) { | |
Array.isArray(value) | |
? value.forEach(v => formData.append(key, v)) | |
: formData.append(key, value); | |
} | |
return formData; |
This file contains 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 client_create(request): | |
if request.method == "POST": | |
user_form = UserForm(request.POST) | |
client_form = ClientForm(request.POST) | |
if user_form.is_valid() and client_form.is_valid(): | |
user = user_form.save() | |
client = client_form.save(commit=False) | |
client.user = user | |
client.save() |
This file contains 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 BancoImoveisFilterView(FilterView): | |
model = Imovel | |
filterset_class = ImovelFilter | |
template_name = "imovel/imovel/banco_de_imoveis.html" | |
def get_queryset(self): | |
return ( | |
Imovel | |
.objects | |
.select_related( |
This file contains 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 shutil | |
from pathlib import Path | |
FILENAMES_TXT = Path("/home/walison/arquivos.txt") | |
SRC = Path("/home/walison/") | |
DEST = Path("/home/walison/arquivos-copiados/") | |
if not DEST.exists(): |
This file contains 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
<ul class="pagination"> | |
{% if page_obj.has_previous %} | |
<li> | |
<a href="?page={{ page_obj.previous_page_number }}"> | |
<i class="fa fa-chevron-left" aria-hidden="true"></i> | |
</a> | |
</li> | |
{% else %} | |
<li class="disabled"> | |
<span><i class="fa fa-chevron-left" aria-hidden="true"></i></span> |
This file contains 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 | |
from django.conf import settings | |
class Cliente(models.Model) | |
# outros campos | |
cadastrado_por = models.ForeignKey(settings.USER_MODEL, on_delete=models.PROTECT) | |
This file contains 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 | |
from django.conf import settings | |
class Cliente(models.Model) | |
# outros campos | |
cadastrado_por = models.ForeignKey(settings.USER_MODEL, on_delete=models.PROTECT) | |