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
AUTHENTICATION_BACKENDS = ( | |
'social_auth.backends.google.GoogleOAuth2Backend', | |
'django.contrib.auth.backends.ModelBackend', | |
) | |
LOGIN_REDIRECT_URL = '/' | |
GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID'] | |
GOOGLE_OAUTH2_CLIENT_SECRET = os.environ['GOOGLE_OAUTH2_CLIENT_SECRET'] | |
GOOGLE_WHITE_LISTED_DOMAINS = ['incuna.com'] | |
SOCIAL_AUTH_USER_MODEL = 'auth.User' |
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 django.core.urlresolvers import reverse as r | |
# ... | |
class SubscribeViewTest(TestCase): | |
def setUp(self): | |
self.resp = self.client.get(r('subscriptions:subscribe')) | |
def test_get(self): | |
'Ao visitar /inscricao/ a página de inscrição é exibida' |
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 tastypie.api import Api | |
from basic.api.resources import NoteResource, UserResource | |
api = Api(api_name='v1') | |
api.register(NoteResource(), canonical=True) | |
api.register(UserResource(), canonical=True) |
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: utf8 -*- | |
from django import forms | |
from .models import Foo, Bar, FooBar | |
class FooModelForm(forms.ModelForm): | |
# Essa classe vai usar a instrospecção para gerar o formulário | |
# baseado nos atributos da classe Foo | |
class Meta: |
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: utf8 -*- | |
import time, datetime | |
from datetime import date | |
from django import forms | |
from django.contrib.auth.models import User | |
from django.conf import settings | |
from bootstrap_toolkit.widgets import BootstrapDateInput |
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
import requests | |
from lxml.html import fromstring | |
import os | |
def connect(url): | |
return requests.get(url) | |
def parser(page): |
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
# Orignal version taken from http://www.djangosnippets.org/snippets/186/ | |
# Original author: udfalkso | |
# Modified by: Shwagroo Team and Gun.io | |
import sys | |
import os | |
import re | |
import hotshot, hotshot.stats | |
import tempfile | |
import StringIO |
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 django.core.exceptions import ImproperlyConfigured | |
from django.contrib import messages | |
class SuccessMessageMixin(object): | |
success_message = None | |
def get_success_message(self): | |
if self.success_message: |
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 django.views.generic import ListView | |
from django.views.generic.edit import FormMixin | |
from django.db.models import Q | |
class SearchView(FormMixin, ListView): | |
template_name_suffix = '_search' | |
filter_operator = 'contains' | |
allow_or_operator = False | |
def get_filter_operator(self): |
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 -*- | |
''' | |
This module represents the recommender system for recommending | |
new friends based on 'mutual friends'. | |
''' | |
__author__ = 'Marcel Caraciolo <[email protected]>' |