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 save_name(fvalue, row): | |
# save name on auth.User, user row['email'] as key | |
return | |
def save_graduation(fvalue, row): | |
# save graduation on accounts.UserProfile, user row['email'] to get user and than get_profile() | |
return | |
function_dict = {'name': save_name, |
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
{% spaceless %} | |
{# this is included in form.html and is loaded via ajax #} | |
{% load bootstrap_toolkit %} | |
{% if success %} | |
{# msg in form instead in next request #} | |
<div class="alert success alert-success"> | |
<a class="close" data-dismiss="alert">×</a> | |
{{ success|safe }} | |
</div> | |
{% endif %} |
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
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, unicode_literals) | |
def flat_list(l): | |
result = [] | |
for i, e in enumerate(l): | |
if type(e) is list: | |
result += e | |
else: |
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
<!DOCTYPE html>{% load staticfiles %} | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Html5</title> | |
<link rel="stylesheet" href="{% static 'js/jquery-ui/css/smoothness/jquery-ui-1.9.1.css' %}" /> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script> | |
{{ form.media }} | |
{% comment %} |
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 get_cep(cep): | |
# cache = django cache | |
# CepCache = model para cachear os ceps | |
cached = cache.get(cep) | |
if not cached: | |
try: | |
dbcep = CepCache.objects.get(cep=cep) | |
except CepCache.DoesNotExist: | |
from cepbr import Cep | |
dbcep = CepCache.objects.create(**Cep(cep)) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import codecs | |
from django.utils.datastructures import SortedDict | |
linhas = SortedDict() # um sorted dict é uma boa | |
with codecs.open('bacula_log.log', 'rb', 'utf8') as f: |
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 LockedTask(Task): | |
# based on http://celery.readthedocs.org/en/latest/tutorials/task-cookbook.html#ensuring-a-task-is-only-executed-one-at-a-time | |
abstract = True | |
lock_expire = 5 # 5 minutes | |
def __init__(self, *a, **kw): | |
super(LockedTask, self).__init__(*a, **kw) | |
self.logger = self.get_logger() |
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
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, | |
unicode_literals) | |
from django.db import models | |
class Product(models.Model): | |
""" Store products """ | |
name = models.CharField(max_length=50) |
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 sentry.conf.server import * | |
import os.path | |
CONF_ROOT = os.path.dirname(__file__) | |
DATABASES = { | |
'default': { | |
# You can swap out the engine for MySQL easily by changing this value | |
# to ``django.db.backends.mysql`` or to PostgreSQL with | |
# ``django.db.backends.postgresql_psycopg2`` |
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
(0.000) SELECT `sentry_filterkey`.`id`, `sentry_filterkey`.`project_id`, `sentry_filterkey`.`key` FROM `sentry_filterkey` WHERE (`sentry_filterkey`.`project_id` = 1 AND `sentry_filterkey`.`key` = 'logger' ); args=(1, 'logger') | |
Traceback (most recent call last): | |
File "/home/sistemas/virtualenvs/sentry/local/lib/python2.7/site-packages/raven/handlers/logging.py", line 56, in emit | |
return self._emit(record) | |
File "/home/sistemas/virtualenvs/sentry/local/lib/python2.7/site-packages/raven/contrib/django/handlers.py", line 32, in _emit | |
return super(SentryHandler, self)._emit(record, request=request) | |
File "/home/sistemas/virtualenvs/sentry/local/lib/python2.7/site-packages/raven/handlers/logging.py", line 136, in _emit | |
date=date, **kwargs) | |
File "/home/sistemas/virtualenvs/sentry/local/lib/python2.7/site-packages/raven/contrib/django/client.py", line 97, in capture | |
result = super(DjangoClient, self).capture(event_type, **kwargs) |