Skip to content

Instantly share code, notes, and snippets.

View CoutinhoElias's full-sized avatar

Elias Coutinho CoutinhoElias

View GitHub Profile
@CoutinhoElias
CoutinhoElias / MyDataCalendar.js
Created April 19, 2018 19:59
CRUD com FullCalendar e Django
(function (namespace, $) {
"use strict";
var DemoCalendar = function () {
// Create reference to this instance
var o = this;
// Initialize app when document is ready
$(document).ready(function () {
o.initialize();
});
@CoutinhoElias
CoutinhoElias / python_code.py
Created April 19, 2018 20:03
MeuCodigoPython
#View bookings_create
def bookings_create(request):
data = dict()
if request.method == 'POST':
form = BookingsForm(request.POST)
if form.is_valid():
form.save()
data['form_is_valid'] = True
else:
from kivy.network.urlrequest import UrlRequest
from kivy.app import App
from kivy.uix.button import Button
class reqApp(App):
def build(self):
bt = Button(text='Pegar Json do Bitcoin')
bt.bind(on_press=self.make_request)
@CoutinhoElias
CoutinhoElias / bashrc.bashrc
Created June 20, 2018 11:37
Problema no virtualenvwrapper
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@CoutinhoElias
CoutinhoElias / conection.py
Created June 20, 2018 22:39
Conexão python usando cookies para Logar d-já Vue
import urllib.parse, urllib.request
import http.client, http.cookiejar
cookie = http.cookiejar.CookieJar()
conn = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie))
#self._conn.addheaders = [('Content-Type', 'multipart/form-data')]
url = 'http://localhost/api/login'
url_todos = 'http://localhost/api/list_todos'
@CoutinhoElias
CoutinhoElias / arquivo.py
Created October 5, 2018 01:01
Problema com Bulkcreate
#Modelos
class Questions(models.Model):
LEVEL_CHOICES = (
('0', 'Indefinido'),
('1', 'Dependencia'),
('2', 'Confianca'),
('3', 'Comprometimento'),
('4', 'Preditiva'),
('5', 'Comprometimento'),
)
@CoutinhoElias
CoutinhoElias / gist_08102018_1903.py
Created October 8, 2018 22:08
A view não passa pelo meu manager
#Minha view
def addQuestions(self):
person = Person.objects.get(pk=1)
questions = Questions.objects.all()
for question in questions:
Pesquisa.objects.get_or_create(
search_key='092018',
person=person,
question=question,
@CoutinhoElias
CoutinhoElias / 08102018_1914.py
Created October 8, 2018 22:22
08102018_1914
#View para post e get do formset
class QuestionsDetailWiew(TemplateView):
template_name = 'queryes.html'
def get_formset(self, clear=False):
QuestionsFormSet = modelformset_factory(
Pesquisa, fields=('response',), can_delete=False, extra=0
)
if clear:
formset = QuestionsFormSet(
@CoutinhoElias
CoutinhoElias / create_data.py
Last active December 8, 2018 02:08
Populando modelo Person
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dccrecibo.settings")
django.setup()
#from django.utils.text import slugfy
from dccrecibo.core.models import Person
@CoutinhoElias
CoutinhoElias / models.py
Last active January 23, 2019 01:54
Adicionar em massa com unique_together
from django.db import models
from django.urls import reverse
class Question(models.Model):
LEVEL_CHOICES = (
('0', 'Dependencia'),
('1', 'Confianca'),
('2', 'Comprometimento'),
('3', 'Preditiva'),