Use function to generate list for performance period instead of hard coding all of the text
This commit is contained in:
parent
5289614140
commit
cfecf3d544
@ -1,6 +1,7 @@
|
||||
import re
|
||||
import datetime
|
||||
from atst.utils.localization import translate
|
||||
from atst.forms.data import translate_duration
|
||||
from flask import current_app as app, render_template
|
||||
from jinja2 import contextfilter
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
@ -125,6 +126,7 @@ def register_filters(app):
|
||||
app.jinja_env.filters["renderAuditEvent"] = renderAuditEvent
|
||||
app.jinja_env.filters["removeHtml"] = removeHtml
|
||||
app.jinja_env.filters["normalizeOrder"] = normalizeOrder
|
||||
app.jinja_env.filters["translateDuration"] = translate_duration
|
||||
|
||||
@contextfilter
|
||||
def translateWithoutCache(context, *kwargs):
|
||||
|
@ -1,6 +1,21 @@
|
||||
import math
|
||||
from gettext import ngettext
|
||||
|
||||
from atst.domain.roles import PORTFOLIO_ROLES as PORTFOLIO_ROLE_DEFINITIONS
|
||||
from atst.utils.localization import translate
|
||||
|
||||
|
||||
def translate_duration(duration_in_months):
|
||||
duration = []
|
||||
years = math.floor(duration_in_months / 12)
|
||||
months = duration_in_months % 12
|
||||
if years > 0:
|
||||
duration.append("{} {}".format(years, ngettext("year", "years", years)))
|
||||
if months > 0:
|
||||
duration.append("{} {}".format(months, ngettext("month", "months", months)))
|
||||
return (", ").join(duration)
|
||||
|
||||
|
||||
SERVICE_BRANCHES = [
|
||||
("", "Select an option"),
|
||||
("Air Force, Department of the", "Air Force, Department of the"),
|
||||
@ -213,28 +228,5 @@ TEAM_EXPERIENCE = [
|
||||
]
|
||||
|
||||
PERIOD_OF_PERFORMANCE_LENGTH = [
|
||||
("1", translate("forms.task_order.performance_length.1")),
|
||||
("2", translate("forms.task_order.performance_length.2")),
|
||||
("3", translate("forms.task_order.performance_length.3")),
|
||||
("4", translate("forms.task_order.performance_length.4")),
|
||||
("5", translate("forms.task_order.performance_length.5")),
|
||||
("6", translate("forms.task_order.performance_length.6")),
|
||||
("7", translate("forms.task_order.performance_length.7")),
|
||||
("8", translate("forms.task_order.performance_length.8")),
|
||||
("9", translate("forms.task_order.performance_length.9")),
|
||||
("10", translate("forms.task_order.performance_length.10")),
|
||||
("11", translate("forms.task_order.performance_length.11")),
|
||||
("12", translate("forms.task_order.performance_length.12")),
|
||||
("13", translate("forms.task_order.performance_length.13")),
|
||||
("14", translate("forms.task_order.performance_length.14")),
|
||||
("15", translate("forms.task_order.performance_length.15")),
|
||||
("16", translate("forms.task_order.performance_length.16")),
|
||||
("17", translate("forms.task_order.performance_length.17")),
|
||||
("18", translate("forms.task_order.performance_length.18")),
|
||||
("19", translate("forms.task_order.performance_length.19")),
|
||||
("20", translate("forms.task_order.performance_length.20")),
|
||||
("21", translate("forms.task_order.performance_length.21")),
|
||||
("22", translate("forms.task_order.performance_length.22")),
|
||||
("23", translate("forms.task_order.performance_length.23")),
|
||||
("24", translate("forms.task_order.performance_length.24")),
|
||||
(str(x + 1), translate_duration(x + 1)) for x in range(24)
|
||||
]
|
||||
|
@ -34,10 +34,6 @@
|
||||
{% set team_experience_description = "forms.task_order.team_experience.{}".format(task_order.team_experience) | translate %}
|
||||
{% endif %}
|
||||
|
||||
{% if task_order.performance_length %}
|
||||
{% set performance_length_description = "forms.task_order.performance_length.{}".format(task_order.performance_length) | translate %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h3 class="subheading">{{ "task_orders.new.review.app_info"| translate }} {{ TOEditLink(screen=1) }}</h3>
|
||||
|
||||
@ -121,7 +117,7 @@
|
||||
<div class="row">
|
||||
<div class="col col--grow">
|
||||
<h4 class='task-order-form__heading'>{{ "task_orders.new.review.performance_period"| translate }}</h4>
|
||||
{{ performance_length_description or RequiredLabel() }}
|
||||
{{ task_order.performance_length | translateDuration or RequiredLabel() }}
|
||||
<p><a href="#" class='icon-link icon-link--left' download>{{ Icon('download') }} {{ "task_orders.new.review.usage_est_link"| translate }}</a></p>
|
||||
</div>
|
||||
|
||||
|
@ -208,30 +208,6 @@ forms:
|
||||
built_many: Built or migrated many applications, or consulted on several such projects
|
||||
performance_length:
|
||||
label: Period of Performance length
|
||||
'1': 1 Month
|
||||
'2': 2 Months
|
||||
'3': 3 Months
|
||||
'4': 4 Months
|
||||
'5': 5 Months
|
||||
'6': 6 Months
|
||||
'7': 7 Months
|
||||
'8': 8 Months
|
||||
'9': 9 Months
|
||||
'10': 10 Months
|
||||
'11': 11 Months
|
||||
'12': 1 Year
|
||||
'13': 1 Year, 1 Month
|
||||
'14': 1 Year, 2 Months
|
||||
'15': 1 Year, 3 Months
|
||||
'16': 1 Year, 4 Months
|
||||
'17': 1 Year, 5 Months
|
||||
'18': 1 Year, 6 Months
|
||||
'19': 1 Year, 7 Months
|
||||
'20': 1 Year, 8 Months
|
||||
'21': 1 Year, 9 Months
|
||||
'22': 1 Year, 10 Months
|
||||
'23': 1 Year, 11 Months
|
||||
'24': 2 Years
|
||||
start_date_label: Start Date
|
||||
end_date_label: End Date
|
||||
pdf_label: Upload a copy of your CSP Cost Estimate Research
|
||||
|
Loading…
x
Reference in New Issue
Block a user