|
|
|
@ -18,28 +18,6 @@ class ContractorWorkSellTrashForm(forms.Form): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkSellForm(forms.ModelForm): |
|
|
|
class WorkSellForm(forms.ModelForm): |
|
|
|
# Define a form field manually for a reverse model vield: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# photos = forms.ModelMultipleChoiceField( |
|
|
|
|
|
|
|
# queryset=WorkSellPhoto.objects.none(), |
|
|
|
|
|
|
|
# widget=forms.CheckboxSelectMultiple, |
|
|
|
|
|
|
|
# required=False, |
|
|
|
|
|
|
|
# ) |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# live_images = forms.ModelMultipleChoiceField( |
|
|
|
|
|
|
|
# queryset=LiveImageUpload.objects.all(), |
|
|
|
|
|
|
|
# widget=forms.CheckboxSelectMultiple, |
|
|
|
|
|
|
|
# required=False, |
|
|
|
|
|
|
|
# ) |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# building_classification = TreeNodeChoiceField( |
|
|
|
|
|
|
|
# BuildingClassfication.objects.exclude(name='_root'), |
|
|
|
|
|
|
|
# widget=forms.Select(attrs={ |
|
|
|
|
|
|
|
# 'class': 'selectpicker' |
|
|
|
|
|
|
|
# }), |
|
|
|
|
|
|
|
# required=False, |
|
|
|
|
|
|
|
# level_indicator=' ', |
|
|
|
|
|
|
|
# ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta: |
|
|
|
class Meta: |
|
|
|
model = WorkSell |
|
|
|
model = WorkSell |
|
|
|
@ -58,34 +36,29 @@ class WorkSellForm(forms.ModelForm): |
|
|
|
'name', |
|
|
|
'name', |
|
|
|
'term', |
|
|
|
'term', |
|
|
|
'term_type', |
|
|
|
'term_type', |
|
|
|
|
|
|
|
# 'photos' |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# widgets = { |
|
|
|
|
|
|
|
# 'construction_type': forms.Select(attrs={'class': 'selectpicker'}), |
|
|
|
|
|
|
|
# 'currency': forms.Select(attrs={'class': 'selectpicker'}), |
|
|
|
|
|
|
|
# 'term_type': forms.Select(attrs={'class': 'selectpicker'}), |
|
|
|
|
|
|
|
# 'work_type': forms.Select(attrs={'class': 'selectpicker -project-work-type-select-field'}), |
|
|
|
|
|
|
|
# } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def clean(self): |
|
|
|
# def clean(self): |
|
|
|
# print("CLEAN", self.cleaned_data) |
|
|
|
# print("CLEAN", self.cleaned_data) |
|
|
|
# data = self.cleaned_data.get('specialization') |
|
|
|
# data = self.cleaned_data.get('specializations') |
|
|
|
# print("before data = ", data) |
|
|
|
# print("before data = ", data) |
|
|
|
# # print('spec = ', data.split(',')) |
|
|
|
# # print('spec = ', data.split(',')) |
|
|
|
# # self.cleaned_data['specialization'] = data.split(',') |
|
|
|
# # self.cleaned_data['specialization'] = data.split(',') |
|
|
|
# super().clean() |
|
|
|
# super().clean() |
|
|
|
|
|
|
|
|
|
|
|
# def clean_specialization(self): |
|
|
|
# def clean_specializations(self): |
|
|
|
# data = self.cleaned_data['specialization'] |
|
|
|
# data = self.cleaned_data['specializations'] |
|
|
|
# print("before data = ", data) |
|
|
|
# print("before data = ", data) |
|
|
|
# data = data.split(',') |
|
|
|
# # data = data.split(',') |
|
|
|
# print("after data = ", data) |
|
|
|
# print("after data = ", data) |
|
|
|
# return data |
|
|
|
# return data |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
self.request = kwargs.pop('request') |
|
|
|
self.request = kwargs.pop('request') |
|
|
|
super().__init__(*args, **kwargs) |
|
|
|
super().__init__(*args, **kwargs) |
|
|
|
|
|
|
|
self.fields['specializations'].required = True |
|
|
|
|
|
|
|
self.fields['description'].required = True |
|
|
|
# self.fields['photos'].queryset = self.instance.photos.all() |
|
|
|
# self.fields['photos'].queryset = self.instance.photos.all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|