Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #843 from cfpb/flagged-update-message
Browse files Browse the repository at this point in the history
Toggle reg update messages via settings
  • Loading branch information
niqjohnson authored Feb 6, 2018
2 parents 1d365d1 + a016ed7 commit 92a44c4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 14 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,16 @@ cd static.in/ && git clone https://[GHE]/CFGOV/cfgov-fonts/
where `[GHE]` is our GitHub Enterprise URL.

See the [cfgov-refresh Webfonts documentation](https://cfpb.github.io/cfgov-refresh/installation/#webfonts) for a similar setup.

## Configuration

### Update notices

Define an `EREGS_REGULATION_UPDATES` Django setting in order to temporarily place a notice on the landing page of regulations that are in the process of being updated. For example, to turn on this notice for regulations for part 1003 and part 1005, define:

```py
# in your Django settings file
EREGS_REGULATION_UPDATES = ['1003', '1005']
```

Content for this notice can be found in `regulations/templates/regulations/generic_landing.html`.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ Main Content Area
padding: 10px;
}

.alert_section + .alert_section {
padding-top: 10px;
border-top: 1px solid @gray-40;
margin-top: 10px;
}

@media only screen and ( min-width: 1000px ) {
.alert_effective-date {
float: left;
Expand Down
37 changes: 28 additions & 9 deletions regulations/templates/regulations/generic_landing.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
{% load reg_updates %}

<div id="content-body" class="main-content">
<section id="content-wrapper">
<section data-base-version="{{ current_version.version }}" class="landing" data-page-type="landing-page" data-reg-part="{{reg_part}}">
{% block reg_title %}
{% endblock %}

{% if new_version %}
<div class="alert effective-alert group">
<div class="alert_effective-date">
New amendments effective: <strong>{{new_version.by_date|date:"m/d/Y"}}</strong>
</div>
<div class="alert_view-link">
<a href="{% url 'chrome_section_view' reg_first_section new_version.version %}" class="go">View amended regulation</a></li>
</div>
</div><!--/.alert-->
{% update_in_progress reg_part as reg_update_in_progress %}
{% if new_version or reg_update_in_progress %}
<div class="alert effective-alert group">
{% if new_version %}
<div class="alert_section group">
<div class="alert_effective-date">
New amendments effective: <strong>{{new_version.by_date|date:"m/d/Y"}}</strong>
</div>
<div class="alert_view-link">
<a href="{% url 'chrome_section_view' reg_first_section new_version.version %}" class="go">
View amended regulation
</a>
</div>
</div>
{% endif %}
{% if reg_update_in_progress %}
<div class="alert_section group">
<strong>
We’re working on incorporating amendments to this regulation.
</strong>
In the meantime, please review
<a href="https://www.consumerfinance.gov/policy-compliance/rulemaking/final-rules/" class="standard">
CFPB rules recently published in the Federal Register</a>.
</div>
{% endif %}
</div><!--/.alert-->
{% endif %}

{% block reg_main_content %}
Expand Down
5 changes: 0 additions & 5 deletions regulations/templates/regulations/specific/landing_1026.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ <h2 class="banner-text">Regulation Z protects people when they use consumer cred

{% block reg_main_content %}
<div class="group">

<div class="group important">
<p>The Bureau is currently updating the tool to reflect recent changes.</p>
</div>

<div class="reg-tags">
<h3 class="list-header">Consumer credit includes: </h3>
<ul class="tag-list">
Expand Down
24 changes: 24 additions & 0 deletions regulations/templatetags/reg_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django import template
from django.conf import settings


register = template.Library()


@register.assignment_tag
def update_in_progress(reg_part):
"""Given a regulation, is there an update currently in progress?
This template tag checks for a list in the Django setting
EREGS_REGULATION_UPDATES, and, if that setting exists, checks if the given
regulation part is in that list.
Use it in a template like:
{% update_in_progress reg_part as reg_update_in_progress %}
{% if reg_update_in_progress %}
<p>An update is in progress to this regulation.</p>
{% endif %}
"""
regulation_updates = getattr(settings, 'EREGS_REGULATION_UPDATES', [])
return reg_part in regulation_updates
27 changes: 27 additions & 0 deletions regulations/tests/templatetags_reg_updates_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.conf import settings
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings


class RegUpdatesTemplateTagsTestCase(SimpleTestCase):
def render(self, reg_part):
template = Template(
"{% load reg_updates %}"
"{% update_in_progress reg_part as reg_update %}"
"{{ reg_update }}"
)
context = Context({'reg_part': reg_part})
return template.render(context)

@override_settings()
def test_no_setting_reg_not_being_updated_returns_false(self):
del settings.EREGS_REGULATION_UPDATES
self.assertEqual(self.render('1099'), 'False')

@override_settings(EREGS_REGULATION_UPDATES=['1098', '1099'])
def test_setting_includes_reg_returns_true(self):
self.assertEqual(self.render('1099'), 'True')

@override_settings(EREGS_REGULATION_UPDATES=['1001', '1002'])
def test_setting_doesnt_include_reg_returns_false(self):
self.assertEqual(self.render('1099'), 'False')

0 comments on commit 92a44c4

Please sign in to comment.