Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (32 sloc) 1.154 kb
from django.forms import ModelForm
from django.contrib.auth.models import User
from django.forms import ModelChoiceField, ChoiceField
from .lib.choices import (
DynamicTemplateChoices,
DynamicChoice,
)
from .models import (
CProductTypesPlugin,
CProductsPlugin,
TEMPLATE_BASE_PATH,
PRODUCT_TYPE_TEMPLATE_PATH,
PRODUCT_LIST_TEMPLATE_PATH,
)
class CProductTypesAdminForm(ModelForm):
class Meta:
model = CProductTypesPlugin
def __init__(self, *args, **kwargs):
super(CProductTypesAdminForm, self).__init__(*args, **kwargs)
self.fields['template'].choices = DynamicTemplateChoices(
path = PRODUCT_TYPE_TEMPLATE_PATH,
include = '.html',
exclude = 'base')
class CProductsAdminForm(ModelForm):
class Meta:
model = CProductsPlugin
def __init__(self, *args, **kwargs):
super(CProductsAdminForm, self).__init__(*args, **kwargs)
self.fields['template'].choices = DynamicTemplateChoices(
path = PRODUCT_LIST_TEMPLATE_PATH,
include = '.html',
exclude = 'base')
Jump to Line
Something went wrong with that request. Please try again.