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 | |
class ZipField(models.Field): | |
def __init__(self, length=8, *args, **kwargs): | |
self.length = length | |
super().__init__(*args, **kwargs) | |
def db_type(self, connection): | |
return f"char({self.length})" |
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 import management | |
from pathlib import Path | |
class Command(management.base.BaseCommand): | |
def handle(self, *args, **options): | |
apps = ["core"] | |
models = ["core.ModelA", "core.ModelB"] | |
fixture_name = "audit" |
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
if (PrimeFaces.widget.DataTable) { | |
PrimeFaces.widget.DataTable.prototype.tabCell = function(celula, frente){ | |
var celulaAlvo = frente ? celula.nextAll("td.ui-editable-column:first") : celula.prevAll("td.ui-editable-column:first"); | |
if (celulaAlvo.length == 0) { | |
var linha = frente ? celula.parent().next() : celula.parent().prev(); | |
celulaAlvo = frente ? linha.children("td.ui-editable-column:first") : linha.children("td.ui-editable-column:last"); | |
} |
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 masonite.providers import Provider | |
class ZeroMQProvider(Provider): | |
def __init__(self, application): | |
self.application = application | |
def register(self): | |
print("Starting zeromq") | |
import zmq |
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 MyProvider(Provider): | |
def __init__(self, application): | |
self.application = application | |
def register(self): | |
Gate.register_policies([(Project, ProjectPolicy)]) | |
def boot(self): | |
pass |
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
# api.py | |
from masonite.routes import Route | |
ROUTES = [ | |
Route.get('/podcasts', 'api.PodcastController@index') | |
] | |
# web.py |
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
public String toJson() throws JsonProcessingException { | |
ObjectMapper mapper = new ObjectMapper(); | |
return mapper.writeValueAsString(this); | |
} | |
public PessoaFisica toModel() { | |
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.setDateFormat(df); | |
return mapper.convertValue(this, OBJ.class); |
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
ITEM1 | 1 | 11 | COMPRA1 | 444444 | 00 | 3312 | 22 | |
---|---|---|---|---|---|---|---|---|
ITEM1 | 1 | 11 | COMPRA3 | 444444 | 00 | 3312 | 22 | |
ITEM1 | 1 | 13 | COMPRA2 | 444444 | 00 | 3312 | 22 | |
ITEM1 | 1 | 90 | COMPRA3 | 444444 | 00 | 3312 | 22 | |
ITEM2 | 1 | 20 | COMPRA2 | 444444 | 00 | 3312 | 22 | |
ITEM2 | 2 | 19 | COMPRA1 | 444444 | 00 | 3312 | 22 | |
ITEM2 | 1 | 11 | COMPRA1 | 444444 | 00 | 3312 | 22 | |
ITEM2 | 1 | 12 | COMPRA2 | 444444 | 00 | 3312 | 22 | |
ITEM3 | 1 | 11 | COMPRA1 | 444444 | 00 | 3312 | 22 | |
ITEM3 | 5 | 60 | COMPRA3 | 444444 | 00 | 3312 | 22 |
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 ModelA(models.Model): | |
a = models.CharField() | |
b = models.CharField() | |
c = models.CharField() | |
def save(self, *args, **kwargs): | |
c = self.a + self.b | |
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
def validate(self, attrs): | |
whatsapp = attrs.get('whatsapp', self.object.whatsapp) | |
whatsapp_h = attrs.get('whatsapp_h', self.object.whatsapp_h) | |
prontuario = attrs.get("prontuario", self.object.prontuario | |
try: | |
obj = tb_Paciente.objects.filter(whatsapp=whatsapp, whatsapp_h=whatsapp_h, prontuario=prontuario).exists | |
() |
NewerOlder