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
| find -type f -name "*.pyc" -delete |
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 -*- | |
| """A ghetto stupid dead simple approach for model translation.""" | |
| from django.utils.translation import get_language | |
| class LanguageFieldProxy(object): | |
| """ | |
| Thanks to ojii for providing this snippet. | |
| Usage: |
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
| # add this soewhere where it gets loaded very early, i.e. | |
| # your shop's models.py | |
| from django.contrib.auth import login | |
| from django.contrib.auth.signals import user_logged_in | |
| from django.dispatch import receiver | |
| from registration.signals import user_activated | |
| from shop.models.defaults.cart import Cart | |
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
| /* | |
| Base64.encode(str): | |
| Returns a string that is guaranteed to be a valid ID and can be decoded into its | |
| original form. No two inputs generate the same output. | |
| Base64.decode(str): | |
| Returns the original string from the output of Base64.encode. | |
| */ | |
| var Base64 = { | |
| characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.", | |
| 'encode': function(data) { |
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 -*- | |
| import re | |
| import distutils.sysconfig as sysconfig | |
| import os | |
| __doc__ = '''set-me-up. | |
| Usage: | |
| set-me-up <projectdir> | |
| ''' |
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 -*- | |
| """Shipping backend that skips the whole shipping process.""" | |
| from django.conf.urls.defaults import patterns, url | |
| class SkipShippingBackend(object): | |
| backend_name = "Skip Shipping Backend" | |
| url_namespace = "skip-shipping" |
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
| # modified version of http://tomforb.es/using-python-metaclasses-to-make-awesome-django-model-field-choices | |
| # that preserves order of definition | |
| import inspect, itertools | |
| class Option(object): | |
| _counter = itertools.count() | |
| def __init__(self, value, verbose_name=None): | |
| self._count = Option._counter.next() |
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 project.utils import classmaker | |
| class Category(TranslatableModel, MPTTModel): | |
| # https://github.com/ojii/django-nani/issues/39 | |
| __metaclass__ = classmaker() | |
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 django.utils.translation import get_language, activate, deactivate_all, deactivate | |
| class LanguageFieldProxy(object): | |
| def contribute_to_class(self, cls, name): | |
| self.name = name | |
| setattr(cls, self.name, self) | |
| def __get__(self, instance, instance_type=None): |
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
| function getCSRFToken() { | |
| var cookieValue = null; | |
| if (document.cookie && document.cookie != '') { | |
| var cookies = document.cookie.split(';'); | |
| for (var i = 0; i < cookies.length; i++) { | |
| var cookie = jQuery.trim(cookies[i]); | |
| if (cookie.substring(0, 10) == ('csrftoken' + '=')) { | |
| cookieValue = decodeURIComponent(cookie.substring(10)); | |
| break; | |
| } |