Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
textarea field for entering requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
stvnrlly committed Dec 21, 2016
1 parent a9fe566 commit e1b48cd
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
14 changes: 14 additions & 0 deletions projects/admin.py
@@ -1,11 +1,15 @@
from django import forms
from django.contrib import admin
from django.db import models
from django.contrib.auth.models import User
from django.forms import CharField
from django.forms import Textarea
from projects.models import IAA, Project, AgileBPA, ContractingOffice, \
ContractingSpecialist, ContractingOfficer, \
ContractingOfficerRepresentative, Agency, \
AgencyOffice, Micropurchase
from projects.widgets import DurationMultiWidget
from django.contrib.postgres.forms import SimpleArrayField


# Register your models here.
Expand Down Expand Up @@ -44,6 +48,7 @@ class AgileBPAForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AgileBPAForm, self).__init__(*args, **kwargs)

self.fields['requirements'].widget = Textarea(attrs=None)
# Limit the queryset for the technical evaluation panel to team members
# for this project
# TODO: Could this be made more user-friendly with javascript?
Expand All @@ -62,6 +67,12 @@ def __init__(self, *args, **kwargs):
self.fields['acquisition_lead'].queryset = User.objects.none()
self.fields['technical_lead'].queryset = User.objects.none()

requirements = SimpleArrayField(
CharField(),
delimiter='\n',
help_text='Multiple requirements are allowed. Enter each one on its own line.'
)

class Meta:
model = AgileBPA
exclude = ('nda_signed',)
Expand All @@ -75,6 +86,9 @@ class Meta:
class AgileBPAAdmin(admin.ModelAdmin):
form = AgileBPAForm
filter_horizontal = ('technical_evaluation_panel',)
# formfield_overrides = {
# ArrayField: {'widget': SplitArrayWidget}
# }

def get_readonly_fields(self, request, obj=None):
if obj:
Expand Down
36 changes: 36 additions & 0 deletions projects/migrations/0007_auto_20161220_2311.py
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 23:11
from __future__ import unicode_literals

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0006_auto_20161209_0416'),
]

operations = [
migrations.AddField(
model_name='agilebpa',
name='requirements',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=200), default=list, size=None),
),
migrations.AddField(
model_name='micropurchase',
name='requirements',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=200), default=list, size=None),
),
migrations.AddField(
model_name='openmarket',
name='requirements',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=200), default=list, size=None),
),
migrations.AddField(
model_name='software',
name='requirements',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=200), default=list, size=None),
),
]
6 changes: 6 additions & 0 deletions projects/models.py
Expand Up @@ -2,6 +2,7 @@

from datetime import date, timedelta
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django.shortcuts import reverse
from django.core.exceptions import ValidationError
from django.contrib.auth.models import User, Group
Expand Down Expand Up @@ -335,6 +336,11 @@ class Buy(models.Model):
blank=False,
null=True,
)
requirements = ArrayField(
# https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/fields/#arrayfield
models.CharField(max_length=200, blank=True),
default=list,
)
product_owner = models.ForeignKey(
User,
blank=True,
Expand Down
9 changes: 9 additions & 0 deletions projects/widgets.py
@@ -1,5 +1,14 @@
import copy
from datetime import timedelta
from django.forms import widgets
from django import forms
from django.contrib.postgres.validators import (
ArrayMaxLengthValidator, ArrayMinLengthValidator,
)
from django.core.exceptions import ValidationError
from django.utils import six
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _


class DurationMultiWidget(widgets.MultiWidget):
Expand Down

0 comments on commit e1b48cd

Please sign in to comment.