diff --git a/cfgov/jinja2/v1/_includes/macros/time.html b/cfgov/jinja2/v1/_includes/macros/time.html index 34fb6461183..496562ca89e 100644 --- a/cfgov/jinja2/v1/_includes/macros/time.html +++ b/cfgov/jinja2/v1/_includes/macros/time.html @@ -20,9 +20,9 @@ {% macro render(datetime, show_value_for={'date':true, 'time':true, 'timezone':true}) %} - {% if show_value_for.date == true %} + {% if show_value_for.date == true %} {% endif %} @@ -41,3 +41,20 @@ {% endif %} {% endmacro %} + +{% macro render_date_no_markup(datetime, + show_value_for={'date':true, 'time':true, 'timezone':true}) %} + {# TODO: Replace this with a custom Jinja method that uses + https://dateutil.readthedocs.io/ #} + {# Displays the date in the format: MMM. DD, YYYY #} + {% set format_month = '{dt:%b}'.format(dt = datetime) %} + {% if format_month == 'May' %} + {# May doesn't have a period. #} + {{ '{dt:%b} {dt.day}, {dt.year}'.format(dt = datetime) }} + {% elif format_month == 'Sep' %} + {# September is four letters. #} + {{ 'Sept. {dt.day}, {dt.year}'.format(dt = datetime) }} + {% else %} + {{ '{dt:%b}. {dt.day}, {dt.year}'.format(dt = datetime) }} + {% endif %} +{% endmacro %} diff --git a/cfgov/jinja2/v1/_includes/organisms/bureau-structure.html b/cfgov/jinja2/v1/_includes/organisms/bureau-structure.html index b1d0d88a5ba..dbdfebd23e4 100644 --- a/cfgov/jinja2/v1/_includes/organisms/bureau-structure.html +++ b/cfgov/jinja2/v1/_includes/organisms/bureau-structure.html @@ -322,7 +322,8 @@

Bureau Structure

Last updated: {# Displays the date in the format: MMM. DD, YYYY #} - {{'{dt:%b}. {dt.day}, {dt.year}'.format(dt = value.last_updated_date)}} + {% import 'macros/time.html' as time %} + {{ time.render_date_no_markup(value.last_updated_date) }}

{% endif %}
diff --git a/cfgov/jinja2/v1/_includes/organisms/post-preview.html b/cfgov/jinja2/v1/_includes/organisms/post-preview.html index 80500620e73..2b2923c6e82 100644 --- a/cfgov/jinja2/v1/_includes/organisms/post-preview.html +++ b/cfgov/jinja2/v1/_includes/organisms/post-preview.html @@ -103,7 +103,9 @@ data-month="{{ event.start_dt | date('%b') }}" data-day="{{ event.start_dt | date('%-d') }}" datetime="{{ event.start_dt | date('%c') }}"> - {{ event.start_dt| date('%b %-d, %Y') }} + + {{ time.render_date_no_markup(event.start_dt) }} + {% if event.live_stream_link %} {% if last_edited %} - + {% endif %}

{{ page.question | striptags }}

@@ -97,7 +101,6 @@

{{ ask_search_bar.render( 'left' ) }} - {% endblock %} {% block content_sidebar_modifiers -%} diff --git a/cfgov/jobmanager/models/blocks.py b/cfgov/jobmanager/models/blocks.py index bb7f25f1c9d..52a1161bb77 100644 --- a/cfgov/jobmanager/models/blocks.py +++ b/cfgov/jobmanager/models/blocks.py @@ -77,4 +77,11 @@ def make_grades_value(self, instance, value): return ', '.join(sorted(g.grade.grade for g in value.all())) def make_close_date_value(self, instance, value): - return value.strftime('%b %d, %Y').upper() + formatted_month = value.strftime('%b') + if formatted_month != 'May' and formatted_month != 'Sep': + formatted_month = formatted_month + '.' + elif formatted_month == 'Sep': + formatted_month = 'Sept.' + formatted_day = value.strftime('%d').lstrip('0') + formatted_year = value.strftime('%Y') + return formatted_month + ' ' + formatted_day + ', ' + formatted_year diff --git a/cfgov/jobmanager/tests/models/test_blocks.py b/cfgov/jobmanager/tests/models/test_blocks.py index 886511beddb..80682f5a529 100644 --- a/cfgov/jobmanager/tests/models/test_blocks.py +++ b/cfgov/jobmanager/tests/models/test_blocks.py @@ -91,12 +91,12 @@ def test_html_formatting(self): '
  • ' 'Assistant' '

    CLOSING' - '.*APR 21, 2099.*

    ' + '.*Apr. 21, 2099.*

    ' '
  • ' '
  • ' 'Manager' '

    CLOSING.' - '*AUG 05, 2099.*

    ' + '*Aug. 5, 2099.*

    ' '
  • ' )) @@ -206,13 +206,13 @@ def test_html_formatting(self): '' 'Assistant' '12' - 'APR 21, 2099' + 'Apr. 21, 2099' 'Silicon Valley' '' '' 'Manager' '1, 2, 3' - 'AUG 05, 2099' + 'Aug. 5, 2099' 'Silicon Valley' '' )) @@ -230,7 +230,43 @@ def test_html_formatting_no_grade(self): '' 'CEO' '' - 'DEC 01, 2099' + 'Dec. 1, 2099' + 'Silicon Valley' + '' + )) + + def test_html_formatting_no_grade_may_date(self): + make_job_listing_page( + title='CEO', + close_date=date(2099, 5, 1) + ) + + table = JobListingTable() + html = table.render(table.to_python({})) + + self.assertHtmlRegexpMatches(html, ( + '' + 'CEO' + '' + 'May 1, 2099' + 'Silicon Valley' + '' + )) + + def test_html_formatting_no_grade_sept_date(self): + make_job_listing_page( + title='CEO', + close_date=date(2099, 9, 1) + ) + + table = JobListingTable() + html = table.render(table.to_python({})) + + self.assertHtmlRegexpMatches(html, ( + '' + 'CEO' + '' + 'Sept. 1, 2099' 'Silicon Valley' '' )) diff --git a/cfgov/unprocessed/css/calendar-icon.less b/cfgov/unprocessed/css/calendar-icon.less index 46d116f21cc..3fa1fa1f9cc 100755 --- a/cfgov/unprocessed/css/calendar-icon.less +++ b/cfgov/unprocessed/css/calendar-icon.less @@ -12,7 +12,7 @@ - name: Calendar Icon markup: | denotes: - | diff --git a/cfgov/unprocessed/css/organisms/item-introduction.less b/cfgov/unprocessed/css/organisms/item-introduction.less index d5bea89c330..1b9777ae5b9 100644 --- a/cfgov/unprocessed/css/organisms/item-introduction.less +++ b/cfgov/unprocessed/css/organisms/item-introduction.less @@ -10,7 +10,7 @@

    By AuthorA - - +

    [social media molecule] diff --git a/cfgov/unprocessed/css/organisms/post-preview.less b/cfgov/unprocessed/css/organisms/post-preview.less index 9baafcfc458..1c16c3a2149 100644 --- a/cfgov/unprocessed/css/organisms/post-preview.less +++ b/cfgov/unprocessed/css/organisms/post-preview.less @@ -10,7 +10,7 @@ Published