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

Commit

Permalink
Merge pull request #509 from eregs/534-part-link
Browse files Browse the repository at this point in the history
Link to print a whole part
  • Loading branch information
cmc333333 authored Sep 1, 2017
2 parents c2db631 + a0665da commit d69dc01
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends: airbnb
globals:
document: true
localStorage: true
location: true
sessionStorage: true
window: true
XMLHttpRequest: true
Expand Down
15 changes: 15 additions & 0 deletions regulations/generator/sidebar/print_part.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from regulations.generator.sidebar.base import SidebarBase
from regulations.views.utils import regulation_meta


class PrintPart(SidebarBase):
shorthand = 'print_part'

def context(self, http_client, request):
meta = regulation_meta(self.cfr_part, self.version)

return {
'cfr_title': meta.get('cfr_title_number'),
'cfr_part': self.cfr_part,
'version': self.version,
}
1 change: 1 addition & 0 deletions regulations/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
SIDEBARS = (
'regulations.generator.sidebar.analyses.Analyses',
'regulations.generator.sidebar.help.Help',
'regulations.generator.sidebar.print_part.PrintPart',
)

ATTACHMENT_BUCKET = os.getenv('S3_BUCKET')
Expand Down
15 changes: 15 additions & 0 deletions regulations/static/config/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion regulations/static/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regulations-site",
"version": "8.1.0",
"version": "8.4.0",
"homepage": "https://eregs.github.io/",
"contributors": [
{
Expand Down Expand Up @@ -86,6 +86,7 @@
"jquery-scrollstop": "^1.2.0",
"prosemirror": "0.4.0",
"query-command-supported": "^1.0.0",
"query-string": "^5.0.0",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"redux": "^3.6.0",
Expand Down
26 changes: 24 additions & 2 deletions regulations/static/regulations/css/scss/partials/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Sidebar.scss
sidebar.scss styles all of the right sidebar content
*/

$icon_size: 18px;

/*
add a margin to sidebar content
this offsets the persistent header & ensures long content is inside the viewport
Expand Down Expand Up @@ -54,7 +56,7 @@ Sidebar Expandables

a {
float: right;
font-size: 0.875em;
font-size: $icon_size;
line-height: 40px;
margin-right: 25px;
}
Expand Down Expand Up @@ -200,7 +202,7 @@ Regs Meta contains the sub-content meta data found in the sidebar

.cf-icon-right {
float: right;
font-size: 0.875em;
font-size: $icon_size;
line-height: 2;
color: $gray_light;
}
Expand Down Expand Up @@ -384,6 +386,22 @@ Styles for the UI help slide down
border-top: 1px solid $gray_light;
}

#print_part {
.group {
background-color: $gray_lightest;
@include border-bottom-light;
}

.cf-icon-print {
float: right;
color: $action_color;
// The print icon is a bit smaller than chevrons; enlarge it
font-size: $icon_size + 3;
line-height: 40px;
margin-right: 15px;
}
}

/*
Small screens
---------------
Expand Down Expand Up @@ -472,4 +490,8 @@ Small screens
}
}
}

#print_part .cf-icon-print {
margin-right: 0;
}
}
7 changes: 7 additions & 0 deletions regulations/static/regulations/js/source/app-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const $ = require('jquery');
const Backbone = require('backbone');
const queryString = require('query-string');
const MainView = require('./views/main/main-view');
const Router = require('./router');
const SidebarView = require('./views/sidebar/sidebar-view');
Expand All @@ -24,6 +25,7 @@ module.exports = {

init: function init() {
const regs = window.regs || {};
const queryParams = queryString.parse(location.search);

Router.start();
this.bindEvents();
Expand All @@ -35,6 +37,11 @@ module.exports = {
new MainView();
new SidebarView();
/* eslint-enable */

if (queryParams.print === 'true') {
window.print();
}

setTimeout(() => {
$('html').addClass('selenium-start');
}, 5000);
Expand Down
10 changes: 10 additions & 0 deletions regulations/templates/regulations/sidebar/print_part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<section id="print_part" class="regs-meta">
<header class="group">
<a href="{% url 'chrome_regulation_view' cfr_part version %}?print=true">
<h4>
Print <strong>{{ cfr_title }} CFR Part {{ cfr_part }}</strong>
<span class="cf-icon cf-icon-print" />
</h4>
</a>
</header>
</section>
15 changes: 15 additions & 0 deletions regulations/tests/sidebar_print_part_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from mock import Mock

from regulations.generator.sidebar import print_part


def test_print_part(monkeypatch):
monkeypatch.setattr(print_part, 'regulation_meta', Mock())
print_part.regulation_meta.return_value = {'cfr_title_number': 12}

sidebar = print_part.PrintPart('333-44', 'vvvv')
assert sidebar.context(Mock(), Mock()) == {
'cfr_title': 12,
'cfr_part': '333',
'version': 'vvvv',
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="regulations",
version="8.3.0",
version="8.4.0",
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down

0 comments on commit d69dc01

Please sign in to comment.