Skip to content

Instantly share code, notes, and snippets.

@saidimu
saidimu / gist:1644343
Created January 20, 2012 01:23 — forked from mbrochh/gist:979127
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
@saidimu
saidimu / gist:1644342
Created January 20, 2012 01:22 — forked from mbrochh/gist:979145
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)
@saidimu
saidimu / gist:1644338
Created January 20, 2012 01:22 — forked from mbrochh/gist:980463
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'
]
@saidimu
saidimu / gist:1644333
Created January 20, 2012 01:22 — forked from mbrochh/gist:982495
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."""
@saidimu
saidimu / gist:1644328
Created January 20, 2012 01:21 — forked from mbrochh/gist:1053339
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()
@saidimu
saidimu / gist:1644307
Created January 20, 2012 01:18 — forked from mbrochh/gist:1053339
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()
@saidimu
saidimu / gist:1644296
Created January 20, 2012 01:17 — forked from mbrochh/gist:1055432
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):
"""
@saidimu
saidimu / gist:1644288
Created January 20, 2012 01:17 — forked from mbrochh/gist:1055440
FixedShippingCosts cart modifier
class FixedShippingCosts(BaseCartModifier):
"""
This will add a fixed amount of money for shipping costs.
"""
def add_extra_cart_price_field(self, cart):
cart.extra_price_fields.append(
('Shipping costs', decimal.Decimal(
settings.SHOP_SHIPPING_FLAT_RATE)))
return cart
@saidimu
saidimu / gist:1644272
Created January 20, 2012 01:17 — forked from mbrochh/gist:1055445
SHOP_CART_MODIFIER setting
SHOP_CART_MODIFIERS = [
'shop_simplevariations.cart_modifier.ProductOptionsModifier',
'myshop.modifiers.FixedShippingCosts',
'myshop.modifiers.FixedTaxRate',
]
@saidimu
saidimu / gist:1644263
Created January 20, 2012 01:16 — forked from mbrochh/gist:1055458
Hiding billing_shipping_form from seletion.html template
<html>
<body>
<h1>Shipping and Billing</h1>
<form method="POST">
{% csrf_token %}
<h3>Your shipping address</h3>
{{ shipping_address.as_p }}
<h3>Your billing address</h3>
{{ billing_address.as_p }}
<input type=hidden name="shipping_method" value="skip-shipping" />