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
import random, string | |
from django.contrib.contenttypes.models import ContentType | |
def get_path(instance, filename): | |
ctype = ContentType.objects.get_for_model(instance) | |
model = ctype.model | |
app = ctype.app_label | |
extension = filename.split('.')[-1] | |
dir = "site" | |
if model == "job": |
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 cachebuster.detectors import git | |
from django.template.loader import add_to_builtins | |
add_to_builtins('cachebuster.templatetags.cachebuster') | |
CACHEBUSTER_UNIQUE_STRING = git.unique_string(__file__) | |
CACHEBUSTER_PREPEND_STATIC = True |
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 WeekDependentManager(models.Manager): | |
def get_filters(self, prefix=None): | |
if prefix is not None and prefix != '': | |
prefix = '%s__' % prefix | |
else: | |
prefix = '' | |
# All participating | |
filters = { | |
'%sweek__id' % prefix: settings.WEEK_ID, |
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
import json | |
from django.core.cache import get_cache | |
from django.utils import unittest | |
class CacheTestCase(unittest.TestCase): | |
def setUp(self): | |
self.cache = get_cache('default') |
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 FBObjectView(JSONResponseMixin, View): | |
BASE_URL = 'https://graph.facebook.com' | |
def dispatch(self, *args, **kwargs): | |
request = args[0] | |
self.profile = request.user.get_profile() | |
return super(FBObjectView, self).dispatch(*args, **kwargs) | |
def get(self, *args, **kwargs): | |
self.object = kwargs['id'] |
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
import requests | |
import json | |
from django.http import HttpResponse | |
from django.views.generic import View | |
from disco_utils.views import JSONResponseMixin | |
class GetAlbumsView(JSONResponseMixin, View): | |
def dispatch(self, *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
import djcelery | |
djcelery.setup_loader() | |
import redis | |
import tweepy | |
from twitpop.tasks import score_tweet | |
db = redis.Redis(host='localhost', port=6379, db=0) |
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
import os | |
import sublime | |
import sublime_plugin | |
class Pep8CheckCommand(sublime_plugin.EventListener): | |
def on_post_save(self, view): | |
if view.file_name().endswith('.py'): | |
folder_name, file_name = os.path.split(view.file_name()) | |
view.window().run_command('exec', {'cmd': ['flake8', |
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 RingtoneDetailView(SingleObjectTemplateResponseMixin, ChooseTemplateMixin, SingleObjectMixin, FormMixin, TemplateResponseMixin, ProcessFormView): | |
model = Ringtone | |
form_class = RingtoneForm | |
def dispatch(self, *args, **kwargs): | |
request = args[0] | |
device_info = choose_site(request) | |
self.site_type = device_info['site_type'] | |
self.device = device_info['device'] | |
return super(RingtoneDetailView, self).dispatch(*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
from django.conf.urls.defaults import * | |
from views import ApprovedStoryList, CreateStory | |
urlpatterns = patterns( | |
'', | |
(r'^$', ApprovedStoryList.as_view()), | |
(r'^share/$', CreateStory.as_view()), | |
) |