-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FIX #516 - Add `operation_type` field to `Project` * FIX #514 * Change sector field to primary_sector * Add secondary_sectors field * Update Tests * Update Project Endpoints * Add flake8 config * Add PYTHONUNBUFFERED=1 to force server stdin, stdout and stderr to be totally unbuffered.
- Loading branch information
Showing
10 changed files
with
121 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
ignore = C901, W504 | ||
max-line-length = 120 | ||
exclude = .git,__pycache__,old,build,dist | ||
max-complexity = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django import forms | ||
|
||
from .models import Project, Sectors | ||
|
||
|
||
class ProjectForm(forms.ModelForm): | ||
""" | ||
Custom Form For Project | ||
- secondary_sectors: Array EnumField | ||
""" | ||
secondary_sectors = forms.MultipleChoiceField(choices=Sectors.choices, required=False) | ||
|
||
class Meta: | ||
model = Project | ||
fields = '__all__' | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.secondary_sectors = {str(s.value): s for s in Sectors} | ||
self.initial['secondary_sectors'] = [s.value for s in self.initial.get('secondary_sectors', [])] | ||
|
||
def clean_secondary_sectors(self): | ||
primary_sector = str(self.cleaned_data['primary_sector'].value) | ||
return [ | ||
self.secondary_sectors[v] | ||
for v in self.cleaned_data['secondary_sectors'] | ||
if ( | ||
v in self.secondary_sectors and | ||
v != primary_sector | ||
) | ||
] | ||
|
||
def save(self, commit=True): | ||
return super().save(commit=commit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 2.0.12 on 2019-10-04 06:46 | ||
|
||
import deployments.models | ||
import django.contrib.postgres.fields | ||
from django.db import migrations | ||
import enumfields.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('deployments', '0013_auto_20190722_1410'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='project', | ||
old_name='sector', | ||
new_name='primary_sector', | ||
), | ||
migrations.AddField( | ||
model_name='project', | ||
name='operation_type', | ||
field=enumfields.fields.EnumIntegerField(default=0, enum=deployments.models.OperationTypes), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='project', | ||
name='secondary_sectors', | ||
field=django.contrib.postgres.fields.ArrayField(base_field=enumfields.fields.EnumIntegerField(enum=deployments.models.Sectors), blank=True, default=list, size=None), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters