diff --git a/work_sell/forms.py b/work_sell/forms.py index 1e8afd4..1132cf3 100644 --- a/work_sell/forms.py +++ b/work_sell/forms.py @@ -18,28 +18,6 @@ class ContractorWorkSellTrashForm(forms.Form): 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: model = WorkSell @@ -58,34 +36,29 @@ class WorkSellForm(forms.ModelForm): 'name', 'term', '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): # print("CLEAN", self.cleaned_data) - # data = self.cleaned_data.get('specialization') + # data = self.cleaned_data.get('specializations') # print("before data = ", data) # # print('spec = ', data.split(',')) # # self.cleaned_data['specialization'] = data.split(',') # super().clean() - # def clean_specialization(self): - # data = self.cleaned_data['specialization'] + # def clean_specializations(self): + # data = self.cleaned_data['specializations'] # print("before data = ", data) - # data = data.split(',') + # # data = data.split(',') # print("after data = ", data) # return data def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') super().__init__(*args, **kwargs) - + self.fields['specializations'].required = True + self.fields['description'].required = True # self.fields['photos'].queryset = self.instance.photos.all() diff --git a/work_sell/migrations/0023_worksellphoto_description.py b/work_sell/migrations/0023_worksellphoto_description.py new file mode 100644 index 0000000..437c588 --- /dev/null +++ b/work_sell/migrations/0023_worksellphoto_description.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-12-07 16:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('work_sell', '0022_auto_20161207_1213'), + ] + + operations = [ + migrations.AddField( + model_name='worksellphoto', + name='description', + field=models.TextField(blank=True), + ), + ] diff --git a/work_sell/models.py b/work_sell/models.py index f9c6af0..7509169 100644 --- a/work_sell/models.py +++ b/work_sell/models.py @@ -60,6 +60,7 @@ class WorkSell(models.Model): class WorkSellPhoto(models.Model): img = ImageField(upload_to='worksell/worksell/') worksell = models.ForeignKey(WorkSell, related_name='photos') + description = models.TextField(blank=True) class Meta: verbose_name = 'Изображение Готовая работа' diff --git a/work_sell/templates/worksell_create.html b/work_sell/templates/worksell_create.html index 7f7390b..1865196 100644 --- a/work_sell/templates/worksell_create.html +++ b/work_sell/templates/worksell_create.html @@ -59,7 +59,9 @@ @@ -108,7 +110,8 @@ Обязательно - +