Skip to content

Instantly share code, notes, and snippets.

class Foo(object):
"""Epic Docstring. What if it has 80 characters. Will gist add a scrollbar?"""
def __init__(self):
self.bar = 'foobar'
@mbrochh
mbrochh / gist:964057
Last active November 10, 2021 19:08
Fast Forward Your Fork
# kudos to https://github.com/drewlesueur
# stolen from here: https://github.com/blog/266-fast-forward-your-fork#comment-11535
git checkout -b upstream-master
git remote add upstream git://github.com/documentcloud/underscore.git
git pull upstream master
git checkout master // [my master branch]
git merge upstream-master
git push origin master
@mbrochh
mbrochh / gist:964100
Created May 10, 2011 08:29
Setting up django-shop
mkvirtualenv -p python2.7 --no-site-packages django-shop-adventures
workon django-shop-adventures
pip install django==1.3
pip install south
pip install django-shop
# this folder structure is not a must
# it helps if you want to host your app at webfaction.com
mkdir $HOME/Projects/django-shop-adventures/src/webapps/django
mkdir $HOME/Projects/django-shop-adventures/src/webapps/static
@mbrochh
mbrochh / gist:979127
Created May 18, 2011 18:03
Product models for django-shop
from django.db import models
from shop.models.productmodel import Product
class Category(models.Model):
"""Master data: Names of categories."""
name = models.CharField(max_length=256)
def __unicode__(self):
return self.name
@mbrochh
mbrochh / gist:979145
Created May 18, 2011 18:09
Admin model for django-shop
from django.contrib import admin
from myshop import models as shop_models
class LEDAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
admin.site.register(shop_models.Category)
admin.site.register(shop_models.Distributor)
@mbrochh
mbrochh / gist:980463
Created May 19, 2011 09:20
settings for django-shop backends
SHOP_SHIPPING_FLAT_RATE = '-30'
SHOP_SHIPPING_BACKENDS = [
'shop.shipping.backends.flat_rate.FlatRateShipping',
]
SHOP_PAYMENT_BACKENDS = [
'shop.payment.backends.pay_on_delivery.PayOnDeliveryBackend'
]
@mbrochh
mbrochh / gist:982495
Created May 20, 2011 07:22
First version of GetClientInfoView
"""View classes for the get_client_info application."""
from shop.views import ShopTemplateView
from shop.views.checkout import SelectShippingView
class GetClientInfoView(SelectShippingView):
"""Displays form for gathering shipping and billing address."""
@mbrochh
mbrochh / gist:1053339
Created June 29, 2011 07:40
Catching shop/cart/ URL for overriding django-shop's view class
from django.conf.urls.defaults import *
from django.contrib import admin
from shop import urls as shop_urls
from shop_simplevariations import urls as simplevariations_urls
admin.autodiscover()
@mbrochh
mbrochh / gist:1053371
Created June 29, 2011 07:58
Providing drop down lists for simplevariations
{% load simplevariation_tags %}
<!-- Your product detail view here -->
<form method="post" action="{% url cart %}">{% csrf_token %}
{% with option_groups=object|get_option_groups %}
{% if option_groups %}
<div>
<h2>Variations:</h2>
{% for option_group in option_groups %}
<label for="add_item_option_group_{{ option_group.id }}">{{ option_group.name }}</label>
{% with options=option_group|get_options %}
@mbrochh
mbrochh / gist:1055432
Created June 30, 2011 01:16
Adding Tax to your cart
""" Cart modifierts for the myshop app of django-shop-adventures."""
import decimal
from django.conf import settings
from shop.cart.cart_modifiers_base import BaseCartModifier
class FixedTaxRate(BaseCartModifier):
"""