diff --git a/archilance/management/commands/generate_portfolios.py b/archilance/management/commands/generate_portfolios.py index 0cf8efa..d33b3bf 100644 --- a/archilance/management/commands/generate_portfolios.py +++ b/archilance/management/commands/generate_portfolios.py @@ -48,10 +48,7 @@ class Command(BaseCommand): portf.save() - if _.sample((True, False)): - portf.user = User.contractor_objects.order_by('?').first() - else: - portf.team = Team.objects.order_by('?').first() + portf.user = User.contractor_objects.order_by('?').first() portf.building_classification = BuildingClassfication.objects.order_by('?').first() portf.construction_type = ConstructionType.objects.order_by('?').first() diff --git a/projects/forms.py b/projects/forms.py index 2f2bfb0..cfcfed0 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -164,38 +164,19 @@ class PortfolioForm(forms.ModelForm): 'term_type': forms.Select(attrs={'class': 'selectpicker'}), } -class ContractorProjectAnswerForm(forms.ModelForm): + +class ProjectAnswerForm(forms.ModelForm): class Meta: model = Answer - # ('author', 'Relation? True', 'Null? None', 'Blank? None'), - # ('content_type', 'Relation? True', 'Null? False', 'Blank? False'), - # ('portfolios', 'Relation? True', 'Null? False', 'Blank? True'), - # ('project', 'Relation? True', 'Null? False', 'Blank? False'), - # - # ('candidates', 'Relation? True', 'Null? True', 'Blank? None'), - # ('files', 'Relation? True', 'Null? True', 'Blank? None'), - # - # - # ('budget', 'Relation? False', 'Null? False', 'Blank? False'), - # ('created', 'Relation? False', 'Null? False', 'Blank? False'), - # ('currency', 'Relation? False', 'Null? False', 'Blank? False'), - # ('object_id', 'Relation? False', 'Null? False', 'Blank? False'), - # ('term', 'Relation? False', 'Null? False', 'Blank? False'), - # ('term_type', 'Relation? False', 'Null? False', 'Blank? False'), - # ('text', 'Relation? False', 'Null? False', 'Blank? False'), - # ('secure_deal_only', 'Relation? False', 'Null? False', 'Blank? True'), - fields = ( 'budget', 'currency', + 'portfolios', + 'secure_deal_only', 'term', 'term_type', 'text', - 'secure_deal_only', - - 'portfolios', - # 'files', # Doesn't work for some fucked up reason ) widgets = { @@ -205,7 +186,15 @@ class ContractorProjectAnswerForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') + answer_as_team = kwargs.pop('answer_as_team', None) super().__init__(*args, **kwargs) + + if answer_as_team: + self.fields['secure_deal_only'].label = 'Работаем только по безопасной сделке' + self.fields['portfolios'].queryset = Portfolio.objects.all()[:2] # Tmp + else: + self.fields['secure_deal_only'].label = 'Работаю только по безопасной сделке' + self.fields['portfolios'].queryset = self.request.user.portfolios class StageForm(forms.ModelForm): @@ -241,6 +230,7 @@ class ContractorPortfolioTrashForm(forms.Form): def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') super().__init__(*args, **kwargs) + self.fields['pk'].queryset = self.request.user.portfolios.all() diff --git a/projects/migrations/0002_remove_portfolio_team.py b/projects/migrations/0002_remove_portfolio_team.py new file mode 100644 index 0000000..0a6b353 --- /dev/null +++ b/projects/migrations/0002_remove_portfolio_team.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-12 12:49 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0001_squashed_0015_merge'), + ] + + operations = [ + migrations.RemoveField( + model_name='portfolio', + name='team', + ), + ] diff --git a/projects/models.py b/projects/models.py index dd83ce5..8600475 100644 --- a/projects/models.py +++ b/projects/models.py @@ -221,7 +221,6 @@ class Portfolio(models.Model): location = TreeForeignKey('common.Location', related_name='portfolios', null=True, blank=True) name = models.CharField(max_length=255) specialization = TreeForeignKey(Specialization, related_name='portfolios', null=True, blank=True) - team = models.ForeignKey(Team, related_name='portfolios', null=True, blank=True) term = models.IntegerField(default=0, null=True, blank=True) term_type = models.CharField(max_length=20, choices=TERMS, default='hour', null=True, blank=True) user = models.ForeignKey(User, related_name='portfolios', null=True, blank=True) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 7651f06..cb431a2 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -125,9 +125,17 @@