-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 10f53f8
Showing
7 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Django Shop BulkForm plugin | ||
============================ | ||
|
||
All this plugin does is give you access to a "bulk" order form that | ||
lists all the products in your site with quantity boxes and adds | ||
them to the cart on submission. Not rocket science. | ||
|
||
It also may not work for every shop. If you have more than 25 or so | ||
items, a page that lists them all could get unwieldy. But if you | ||
only have a small number of items and want an easy view to let | ||
people add multiple products at the same time, this is your plugin. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='django-shop-bulkform', | ||
version=__import__('shop_bulkform').__version__, | ||
license="BSD", | ||
|
||
install_requires = [], | ||
|
||
description='A bulk order form for a django-shop site.', | ||
long_description=open('README').read(), | ||
|
||
author='Colin Powell', | ||
author_email='colin@onecardinal.com', | ||
|
||
url='http://github.com/powellc/django-shop-bulkform', | ||
download_url='http://github.com/powellc/django-shop-bulkform/downloads', | ||
|
||
include_package_data=True, | ||
|
||
packages=['shop_bulkform'], | ||
|
||
zip_safe=True, | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: BSD License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Framework :: Django', | ||
] | ||
) |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Stub of models.py | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#-*- coding: utf-8 -*- | ||
from django.conf.urls.defaults import patterns, url | ||
from shop_bulkorder.views import CartBulkView | ||
|
||
urlpatterns = patterns('', | ||
url(r'^order-form/$', CartBulkView.as_view(), name='shop_order_form'), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.core.urlresolvers import reverse | ||
from django.http import HttpResponse, HttpResponseRedirect | ||
from shop.models.productmodel import Product | ||
from shop.util.cart import get_or_create_cart | ||
from django.views.generic import ListView | ||
from datetime import date | ||
|
||
class CartBulkView(ListView): | ||
''' An addon view for django-shop to allow bulk adding to the cart. ''' | ||
|
||
model = Product | ||
template_name='shop/order_bulk_form.html' | ||
action=None | ||
|
||
def post(self, *args, **kwargs): | ||
""" | ||
This is to *add* items in bulk to the cart. Optionally, you can pass it | ||
quantity parameters to specify how many you wish to add at once (defaults | ||
to 0) | ||
""" | ||
qty_field_prefix = 'add_item_quantity-' | ||
qty_fields = [k for k in self.request.POST.keys() | ||
if k.startswith(qty_field_prefix)] | ||
cart_object = get_or_create_cart(self.request) | ||
|
||
for key in qty_fields: | ||
id = key[len(qty_field_prefix):] | ||
product = Product.objects.get(pk=id) | ||
if int(self.request.POST[key]) > 0: | ||
cart_item = cart_object.add_product(product, int(self.request.POST[key])) | ||
cart_object.save() | ||
return HttpResponseRedirect(reverse('cart')) |