#ARC-12 Model fields

remotes/origin/setup
ArturBaybulatov 10 years ago
parent f6fdfae753
commit b3b87a4673
  1. 27
      projects/forms.py
  2. 105
      projects/migrations/0024_auto_20160609_1808.py
  3. 26
      projects/models.py

@ -8,13 +8,14 @@ from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage
class ProjectForm(ModelForm): class ProjectForm(ModelForm):
class Meta: class Meta:
model = Project model = Project
fields = ( fields = (
'name', 'name',
'price', 'price',
'secure_transaction',
'specialization', 'specialization',
'text', 'text',
'type_work', 'type_work',
'secure_transaction',
) )
@ -25,12 +26,13 @@ class ProjectsForm(Form):
class RealtyForm(ModelForm): class RealtyForm(ModelForm):
class Meta: class Meta:
model = Realty model = Realty
fields = ( fields = (
'name', # 'city',
'building_classification', 'building_classification',
'construction_type', 'construction_type',
'country', 'country',
# 'city', 'name',
) )
class Realty1Form(Form): class Realty1Form(Form):
@ -44,21 +46,23 @@ class PortfolioForm(ModelForm):
class AnswerForm(ModelForm): class AnswerForm(ModelForm):
# def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# # import code; code.interact(local=dict(globals(), **locals())) # import code; code.interact(local=dict(globals(), **locals()))
# self.project_id = kwargs.pop('project_id') self.project_id = kwargs.pop('project_id')
# super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# self.fields["project"].initial = self.project_id self.fields["project"].initial = self.project_id
class Meta: class Meta:
model = Answer model = Answer
fields = ( fields = (
'cost', 'cost',
'cost_type', 'cost_type',
'text',
'term', 'term',
'term_type', 'term_type',
'text',
) )
widgets = { widgets = {
# 'project': HiddenInput(), # 'project': HiddenInput(),
'cost_type': Select(attrs={'class':'selectpicker'}), 'cost_type': Select(attrs={'class':'selectpicker'}),
@ -68,11 +72,12 @@ class AnswerForm(ModelForm):
class StageForm(ModelForm): class StageForm(ModelForm):
class Meta: class Meta:
model = Stage model = Stage
fields = ( fields = (
'name',
'result',
'cost', 'cost',
'cost_type', 'cost_type',
'name',
'result',
'term', 'term',
'term_type', 'term_type',
) )

@ -0,0 +1,105 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-09 15:08
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('projects', '0023_auto_20160608_1609'),
]
operations = [
migrations.CreateModel(
name='ProjectFile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('file', models.FileField(upload_to='projects/project_files')),
],
),
migrations.RenameField(
model_name='project',
old_name='user',
new_name='customer',
),
migrations.RenameField(
model_name='project',
old_name='secure_transaction',
new_name='secure_deal',
),
migrations.RemoveField(
model_name='project',
name='price',
),
migrations.RemoveField(
model_name='project',
name='term_cost',
),
migrations.RemoveField(
model_name='project',
name='type_work',
),
migrations.AddField(
model_name='project',
name='budget_by_agreement',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='project',
name='currency',
field=models.CharField(choices=[('rur', 'RUR'), ('usd', 'USD'), ('eur', 'EUR')], default='rur', max_length=20),
),
migrations.AddField(
model_name='project',
name='price_and_term_required',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='project',
name='term',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='project',
name='term_type',
field=models.CharField(choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=20),
),
migrations.AddField(
model_name='project',
name='work_type',
field=models.IntegerField(choices=[('1', 'Проектирование'), ('2', 'Техническое сопровождение')], default=1),
),
migrations.AlterField(
model_name='answer',
name='cost_type',
field=models.CharField(choices=[('rur', 'RUR'), ('usd', 'USD'), ('eur', 'EUR')], default='rur', max_length=5),
),
migrations.AlterField(
model_name='answer',
name='term_type',
field=models.CharField(choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=10),
),
migrations.AlterField(
model_name='project',
name='budget',
field=models.DecimalField(decimal_places=0, max_digits=10),
),
migrations.AlterField(
model_name='stage',
name='cost_type',
field=models.CharField(choices=[('rur', 'RUR'), ('usd', 'USD'), ('eur', 'EUR')], default='rur', max_length=5),
),
migrations.AlterField(
model_name='stage',
name='term_type',
field=models.CharField(choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=10),
),
migrations.AddField(
model_name='projectfile',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project'),
),
]

@ -12,9 +12,10 @@ CURRENCIES = (
) )
TERMS = ( TERMS = (
('hour', 'Hour'), ('project', 'За проект'),
('day', 'day'), ('hour', 'За час'),
('month', 'month'), ('day', 'За день'),
('month', 'За месяц'),
) )
class BuildingClassfication(models.Model): class BuildingClassfication(models.Model):
@ -84,22 +85,21 @@ class Project(models.Model):
('2', 'Техническое сопровождение') ('2', 'Техническое сопровождение')
) )
name = models.CharField(max_length=255)
text = models.TextField(blank=True)
work_type = models.IntegerField(default=1, choices=WORK_TYPES)
specialization = models.ForeignKey(Specialization, related_name='projects')
budget = models.DecimalField(max_digits=10, decimal_places=0) budget = models.DecimalField(max_digits=10, decimal_places=0)
currency = models.CharField(default='rur', choices=CURRENCIES)
term = models.IntegerField(default=0)
term_type = models.CharField(max_length=10, choices=TERMS, default='hour')
budget_by_agreement = models.BooleanField(default=False) budget_by_agreement = models.BooleanField(default=False)
price_and_term_required = models.BooleanField(default=False, blank=True)
#----------------------
created = models.DateTimeField(default=timezone.now) created = models.DateTimeField(default=timezone.now)
cro = models.BooleanField(default=False) cro = models.BooleanField(default=False)
currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES)
customer = models.ForeignKey(User, related_name='projects')
name = models.CharField(max_length=255)
price_and_term_required = models.BooleanField(default=False, blank=True)
realty = models.ForeignKey(Realty, null=True, related_name='projects') realty = models.ForeignKey(Realty, null=True, related_name='projects')
secure_deal = models.BooleanField(default=False) secure_deal = models.BooleanField(default=False)
user = models.ForeignKey(User, related_name='projects') specialization = models.ForeignKey(Specialization, related_name='projects')
term = models.IntegerField(default=0)
term_type = models.CharField(max_length=20, choices=TERMS, default='hour')
text = models.TextField(blank=True)
work_type = models.IntegerField(default=1, choices=WORK_TYPES)
def __str__(self): def __str__(self):
return self.name return self.name

Loading…
Cancel
Save