Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

migrate changes

  • Loading branch information...
commit 455e240b7a57db82f982ddd1924dffcf6877b95d 1 parent dae41d9
Zenobius Jiricek authored
View
2  README.md
@@ -1,7 +1,7 @@
## djangoCMS/Shop Configurable Products Extension
This simple extension provides some plugins to display things about your
-django-shop configurable products.
+[django-shop configurable products](https://bitbucket.org/zeus/django-shop-configurableproduct).
## Requirements
View
2  cmsplugin_configurableproduct/cms_plugins.py
@@ -7,7 +7,7 @@
from configurableproduct.models import CProduct as Product
from configurableproduct.models.producttypes import ProductType
-from models import (
+from .models import (
CProductTypesPlugin,
CProductsPlugin,
)
View
0  cmsplugin_configurableproduct/lib/__init__.py
No changes.
View
25 cmsplugin_configurableproduct/lib/choices.py
@@ -0,0 +1,25 @@
+class DynamicChoice(object):
+ """
+ Trivial example of creating a dynamic choice
+ """
+
+ def __iter__(self, *args, **kwargs):
+ for choice in self.generate():
+ if hasattr(choice,'__iter__'):
+ yield (choice[0], choice[1])
+ else:
+ yield choice, choice
+
+ def __init__(self, *args, **kwargs):
+ """
+ If you do it here it is only initialized once. Then just return generated.
+ """
+ import random
+ self.generated = [random.randint(1,100) for i in range(10)]
+
+ def generate(self, *args, **kwargs):
+ """
+ If you do it here it is initialized every time the iterator is used.
+ """
+ import random
+ return [random.randint(1,100) for i in range(10)]
View
101 cmsplugin_configurableproduct/models.py
@@ -1,40 +1,3 @@
-"""
- Configurable Product DjangoCMS plugin Models
-
- ## Templates
-
- Templates are stored in :
-
- cms/plugins/configurable_product/
- /product-types/
- /base.html
- /*.html
- /product-list/
- /base.html
- /*.html
-
- ### base.html
-
- base.html in each plugin subdir is used to load the selected template
- chosen in the administration interface.
-
- template choices are generated by scanning for the relative directory
- path above. So if any of your apps have that path contained therein
- which also contain html files, then they will be used.
-
-
- ## Product Types
-
- If you want to filter/exclude based on a field name, the provide that
- name in the verb list separated by colons.
-
- The presence of any such fields whose name matches either of the listed
- words will be actioned upon.
-
- To determine what action to take, select Show or Hide from the
- filter_action dropdown.
-
-"""
import os
from os.path import join, getsize
@@ -44,53 +7,58 @@
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
-from base.lib.choice_generator import DynamicChoice
-
from cms.models.pluginmodel import CMSPlugin
+from .lib.choices import DynamicChoice
+
class DynamicTemplateChoices(DynamicChoice):
+ path = None
+ exclude = None
+ inlude = None
+
+ def __init__(self, path=None, include=None,
+ exclude=None, *args, **kwargs):
- def __init__(self, path=None, *args, **kwargs):
super(DynamicTemplateChoices, self).__init__(self, *args, **kwargs)
self.path = path
+ self.include = include
+ self.exlude = exclude
- def generate(self,*args, **kwargs):
+ def generate(self,*args, **kwargs):
choices = list()
for template_dir in app_template_dirs:
- results = walkdir(os.path.join(template_dir, self.path),
- self.path, ".html", "base")
+ results = self.walkdir(os.path.join(template_dir, self.path))
if results:
choices += results
return choices
-def walkdir(path, relative_path=None, include_filter=None, exlude_filter=None):
- output = list()
+ def walkdir(self, path=None):
+ output = list()
- if not os.path.exists(path):
- return None
+ if not os.path.exists(path):
+ return None
- for root, dirs, files in os.walk(path):
+ for root, dirs, files in os.walk(path):
- if include_filter:
- files = filter(lambda x: include_filter in x, files)
+ if self.include:
+ files = filter(lambda x: self.include in x, files)
- if exlude_filter:
- files = filter(lambda x: not exlude_filter in x, files)
+ if self.exlude:
+ files = filter(lambda x: not self.exlude in x, files)
- for item in files :
- output += ( (
- os.path.join(relative_path, item),
- os.path.splitext(item)[0],
- ),)
+ for item in files :
+ output += ( (
+ os.path.join(self.path, item),
+ os.path.splitext(item)[0],
+ ),)
- for item in dirs :
- output += walkdir(os.path.join(root, item),
- relative_path, include_filter, exlude_filter)
- return output
+ for item in dirs :
+ output += self.walkdir(os.path.join(root, item))
+ return output
class CProductTypesPlugin(CMSPlugin):
@@ -99,7 +67,10 @@ class CProductTypesPlugin(CMSPlugin):
TEMPLATE_PATH = os.path.join("shop", "plugins",
"configurable_product", "product-types")
- TEMPLATE_CHOICES = DynamicTemplateChoices(path=TEMPLATE_PATH)
+ TEMPLATE_CHOICES = DynamicTemplateChoices(
+ path=TEMPLATE_PATH,
+ include='.html',
+ exclude='base')
categories = models.ManyToManyField('configurableproduct.ProductType',
blank=True, null=True,
@@ -130,7 +101,11 @@ class CProductsPlugin(CMSPlugin):
)
TEMPLATE_PATH = os.path.join("shop", "plugins",
"configurable_product", "product-list")
- TEMPLATE_CHOICES = DynamicTemplateChoices(path=TEMPLATE_PATH)
+ TEMPLATE_CHOICES = DynamicTemplateChoices(
+ path=TEMPLATE_PATH,
+ include='.html',
+ exclude='base')
+
categories = models.ManyToManyField('configurableproduct.ProductType',
help_text="""Restrict the output list to these selected categories.
View
37 setup.py
@@ -0,0 +1,37 @@
+import os
+
+from setuptools import (
+ setup,
+ find_packages,
+)
+
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+ name='djangocms-plugin-configurableproduct',
+ version='0.0.1',
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Internet :: WWW/HTTP',
+ ],
+ packages=find_packages(),
+ install_requires=[
+ 'sorl-thumbnail',
+ 'django-shop',
+ ],
+ author='Pavel Zhukov',
+ author_email='airtonix@gmail.com',
+ description='DjangoCMS plugin for Configurable product for django-shop',
+ long_description = read('README.md'),
+ license='BSD',
+ keywords='djangocms, django-shop, product',
+ url='git://github.com/airtonix/djangocms-plugin-configurableproduct.git',
+ include_package_data=True,
+ zip_safe = False,
+)
Please sign in to comment.
Something went wrong with that request. Please try again.