| 123456789101112131415161718192021222324252627 |
- from django.core import exceptions
-
- from oscar.apps.offer.models import Range, Condition
-
-
- def _class_path(klass):
- return '%s.%s' % (klass.__module__, klass.__name__)
-
-
- def create_range(range_class):
- """
- Create a custom range instance
- """
- if not hasattr(range_class, 'name'):
- raise exceptions.ValidationError(
- "A custom range must have a name attribute")
- return Range.objects.create(
- name=range_class.name,
- proxy_class=_class_path(range_class))
-
-
- def create_condition(condition_class):
- """
- Create a custom condition instance
- """
- return Condition.objects.create(
- proxy_class=_class_path(condition_class))
|