Skip to content

Instantly share code, notes, and snippets.

View walison17's full-sized avatar

Walison Filipe walison17

View GitHub Profile
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'
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}'
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)
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;
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()
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(
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():
<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>
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)
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)