You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.3 KiB

from django import forms
from django.forms import ModelForm, HiddenInput, Form, Select
from django.forms.models import inlineformset_factory
from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage
# RealtyFormSet = inlineformset_factory(Project, Realty)
class ProjectForm(ModelForm):
class Meta:
model = Project
fields = (
'budget',
'budget_by_agreement',
'created',
'cro',
'currency',
'customer',
'name',
'price_and_term_required',
'realty',
'secure_deal',
'specialization',
'term',
'term_type',
'text',
'work_type',
# TODO: Add "files"
)
class ProjectsForm(Form):
name = forms.CharField(max_length=255)
class RealtyForm(ModelForm):
class Meta:
model = Realty
fields = (
# 'city',
'building_classification',
'construction_type',
'country',
'name',
)
class Realty1Form(Form):
pass
class PortfolioForm(ModelForm):
class Meta:
model = Portfolio
fields = '__all__'
class AnswerForm(ModelForm):
def __init__(self, *args, **kwargs):
# import code; code.interact(local=dict(globals(), **locals()))
self.project_id = kwargs.pop('project_id')
super().__init__(*args, **kwargs)
self.fields["project"].initial = self.project_id
class Meta:
model = Answer
fields = (
# 'cost',
# 'cost_type',
# 'term',
# 'term_type',
# 'text',
)
# widgets = {
# # 'project': HiddenInput(),
# 'cost_type': Select(attrs={'class':'selectpicker'}),
# 'term_type': Select(attrs={'class':'selectpicker'}),
# }
class StageForm(ModelForm):
class Meta:
model = Stage
fields = (
# 'cost',
# 'cost_type',
# 'name',
# 'result',
# 'term',
# 'term_type',
)
from django.forms.models import inlineformset_factory
PortfolioPhotoFormSet = inlineformset_factory(Portfolio, PortfolioPhoto, fields=('img',))