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
<template> | |
<div class="q-pa-md"> | |
<q-breadcrumbs class="q-pl-sm q-mb-md"> | |
<q-breadcrumbs-el label="Dashboard" to="/" /> | |
<q-breadcrumbs-el label="Cadastros" /> | |
<q-breadcrumbs-el label="Departamentos" /> | |
</q-breadcrumbs> | |
<div class="q-pb-md"> | |
<q-btn label="Novo" icon="r_add_circle" color="green-5" @click="abrir()" /> | |
</div> |
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
#!/bin/python | |
# Dependencies: | |
# pip install flask | |
# pip install redis | |
from flask import Flask | |
from flask import request | |
import flask | |
import redis |
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
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
const axios = require('axios'); // promised based requests - like fetch() | |
function getCoffee() { | |
return new Promise(resolve => { | |
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
}); | |
} |
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
@roles_accepted('admin','criacao_tipos') | |
def novo_tipo(): | |
obj = Tipo() | |
form = TipoForm(request.form,obj=obj) | |
if form.validate_on_submit(): | |
form.populate_obj(obj) | |
try: | |
db.session.add(obj) | |
db.session.commit() | |
flash('{0} criada com sucesso.'.format('Tipo'), 'info') |
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 wtforms.validators import ValidationError | |
class Unique(object): | |
def __init__(self, model, field, message=u'Ja existe um registro'): | |
self.model = model | |
self.field = field | |
self.message = message | |
def __call__(self, form, field): | |
check = self.model.query.filter(self.field == field.data).first() |
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
// sending to sender-client only | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
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 Base(BaseModels): | |
id = db.Column(db.Integer, primary_key=True) | |
tipo_cadastro = db.Column(db.Integer()) | |
parent_id = db.Column(db.Integer, db.ForeignKey('base.id')) | |
produtos = db.relationship('ProdutoBase', backref='produtos', lazy=True) | |
produtos_individuais = db.relationship('ProdutoIndividual', backref='produtos_individual', lazy=True) | |
parent = db.relationship('Base', remote_side=[id], backref='filhos',lazy=True) | |
class ProdutoBaseModel(BaseModels): |
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
# -*- coding: utf-8 -*- | |
from flask import Flask, request, render_template, current_app | |
from flask_wtf import Form | |
from wtforms.validators import DataRequired | |
from wtforms import SelectField, SelectMultipleField, SubmitField | |
app = Flask(__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
<form method="post" action=""> | |
{{ form.name}} | |
{{ form.hidden_tag() }} | |
<br/> | |
{% for entry in form.hours %} | |
{{ loop.index0|dow }} | |
{{ entry() }} | |
{% endfor %} | |
<input type="submit"/> | |
</form> |
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
// JavaScript Document | |
//adiciona mascara de cnpj | |
function MascaraCNPJ(cnpj){ | |
if(mascaraInteiro(cnpj)==false){ | |
event.returnValue = false; | |
} | |
return formataCampo(cnpj, '00.000.000/0000-00', event); | |
} | |
//adiciona mascara de cep |