2015-01-09 12:11:04 +01:00
|
|
|
# combo - content management system
|
|
|
|
# Copyright (C) 2014-2015 Entr'ouvert
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Affero General Public License as published
|
|
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
|
2015-01-27 22:46:28 +01:00
|
|
|
from .models import WcsFormCell, WcsCategoryCell, WcsFormsOfCategoryCell
|
2015-01-27 15:34:01 +01:00
|
|
|
from .utils import get_wcs_options
|
2015-01-09 12:11:04 +01:00
|
|
|
|
|
|
|
class WcsFormCellForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = WcsFormCell
|
|
|
|
fields = ('formdef_reference',)
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(WcsFormCellForm, self).__init__(*args, **kwargs)
|
2015-01-27 15:34:01 +01:00
|
|
|
formdef_references = get_wcs_options('json')
|
2015-01-09 12:11:04 +01:00
|
|
|
self.fields['formdef_reference'].widget = forms.Select(choices=formdef_references)
|
2015-01-27 15:34:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
class WcsCategoryCellForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = WcsCategoryCell
|
2015-05-29 18:11:50 +02:00
|
|
|
fields = ('category_reference',)
|
2015-01-27 15:34:01 +01:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(WcsCategoryCellForm, self).__init__(*args, **kwargs)
|
|
|
|
references = get_wcs_options('categories')
|
|
|
|
self.fields['category_reference'].widget = forms.Select(choices=references)
|
2015-01-27 22:46:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
class WcsFormsOfCategoryCellForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = WcsFormsOfCategoryCell
|
|
|
|
fields = ('category_reference', 'ordering', 'limit')
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(WcsFormsOfCategoryCellForm, self).__init__(*args, **kwargs)
|
|
|
|
references = get_wcs_options('categories')
|
|
|
|
self.fields['category_reference'].widget = forms.Select(choices=references)
|