diff --git a/projects/forms.py b/projects/forms.py index 9a7819e..30b5a8c 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -8,13 +8,14 @@ from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage class ProjectForm(ModelForm): class Meta: model = Project + fields = ( 'name', 'price', + 'secure_transaction', 'specialization', 'text', 'type_work', - 'secure_transaction', ) @@ -25,12 +26,13 @@ class ProjectsForm(Form): class RealtyForm(ModelForm): class Meta: model = Realty + fields = ( - 'name', + # 'city', 'building_classification', 'construction_type', 'country', - # 'city', + 'name', ) class Realty1Form(Form): @@ -44,21 +46,23 @@ class PortfolioForm(ModelForm): 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 + 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', - 'text', 'term', 'term_type', + 'text', ) + widgets = { # 'project': HiddenInput(), 'cost_type': Select(attrs={'class':'selectpicker'}), @@ -68,11 +72,12 @@ class AnswerForm(ModelForm): class StageForm(ModelForm): class Meta: model = Stage + fields = ( - 'name', - 'result', 'cost', 'cost_type', + 'name', + 'result', 'term', 'term_type', ) diff --git a/projects/migrations/0024_auto_20160609_1808.py b/projects/migrations/0024_auto_20160609_1808.py new file mode 100644 index 0000000..b06db2a --- /dev/null +++ b/projects/migrations/0024_auto_20160609_1808.py @@ -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'), + ), + ] diff --git a/projects/models.py b/projects/models.py index e6a9c92..84bdf0a 100644 --- a/projects/models.py +++ b/projects/models.py @@ -12,9 +12,10 @@ CURRENCIES = ( ) TERMS = ( - ('hour', 'Hour'), - ('day', 'day'), - ('month', 'month'), + ('project', 'За проект'), + ('hour', 'За час'), + ('day', 'За день'), + ('month', 'За месяц'), ) class BuildingClassfication(models.Model): @@ -84,22 +85,21 @@ class Project(models.Model): ('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) - 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) - price_and_term_required = models.BooleanField(default=False, blank=True) - #---------------------- created = models.DateTimeField(default=timezone.now) 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') 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): return self.name