Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/221 billnumber format #238

Merged
merged 3 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions server_py/flatgov/bills/migrations/0001_auto_20210310_1850.py

This file was deleted.

17 changes: 0 additions & 17 deletions server_py/flatgov/bills/migrations/0002_add_statement_field.py

This file was deleted.

Empty file.
46 changes: 46 additions & 0 deletions server_py/flatgov/bills/templatetags/bill_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django import template
from django.template.defaultfilters import stringfilter
from datetime import date, timedelta
from common import constants


# BILL_NUMBER_REGEX = r'(?P<congress>[1-9][0-9]*)(?P<stage>[a-z]+)(?P<number>[0-9]+)(?P<version>[a-z]+)?$'

stagesFormat = {
'S': 'S.',
'HR': 'H.R.',
'HRES': 'H.Res.',
'HJRES': 'H.J.Res.',
'HCONRES': 'H.Con.Res.',
'SJRES': 'S.J.Res.',
'SCONRES': 'S.Con.Res.',
'SRES': 'S.Res.'
}

register = template.Library()


@register.filter
@stringfilter
def billnumber_display(billnumber: str):
billMatch = constants.BILL_NUMBER_REGEX_COMPILED.match(billnumber)
if billMatch and billMatch.groupdict():
billMatchGroups = billMatch.groupdict()
congress = billMatchGroups.get('congress', '')
stage = billMatchGroups.get('stage', '')
number = billMatchGroups.get('number', '')
stage_fmt = stagesFormat.get(stage.upper(), stage)
if congress != constants.CURRENT_CONGRESS:
billnumber_fmt = f' {stage_fmt} {number} ({congress})'
else:
billnumber_fmt = f' {stage_fmt} {number}'
return billnumber_fmt

else:
return billnumber

@register.filter
def billnumbers_display(billnumbers: list):
if isinstance(billnumbers, str):
billnumbers = billnumbers.split(', ')
return [billnumber_display(billnumber) for billnumber in list(billnumbers)]
23 changes: 6 additions & 17 deletions server_py/flatgov/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
box-shadow: 7px 6px 11px 0px rgba(194,194,194,1);
}

.pre-wrapper pre {
white-space: pre-wrap;
word-break: keep-all;
font-family: 'Public Sans', sans-serif;
}

.table {
font-size: small;
}
Expand All @@ -29,10 +35,6 @@
border: none !important;
}

.table tbody>tr>td {

}

.dataTables_paginate a {
border-radius: 100% !important;
width: 40px;
Expand Down Expand Up @@ -89,9 +91,6 @@
background-color: 1px solid #d4d4d4 !important;
}

.title, .search {
}

#bill-search .tt-menu {
max-height: 150px;
overflow-y: auto;
Expand Down Expand Up @@ -245,9 +244,6 @@ label textarea{
vertical-align: middle;
}

#bill-text-div {
}

footer {
color: white;
background: rgb(120, 26, 54);
Expand Down Expand Up @@ -280,18 +276,11 @@ footer {
width: 43%;
}

.cbo-score {}

.left-understanding-context-body {
width: 50%;
margin-right: 3%;
}

.right-understanding-context-body {}

.timeline-detail {
}

/* Circle */
.circle{
background: #9d2146;
Expand Down
22 changes: 10 additions & 12 deletions server_py/flatgov/templates/bills/detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load bill_filters %}
{% load static %}

{% block extra_css %}
Expand Down Expand Up @@ -26,22 +27,19 @@ <h1>
<div class="bill light-gray-body p-4">
<h4 class="pb-2 text-center"><b>Overview</b></h4>
<h5><b>Bill Summary:</b></h5>
<!-- {% if bill.summary_short %}
<p>{{bill.summary_short}}</p>
{% if bill.summary_short %}
<div class="pre-wrapper"><pre>{{bill.summary_short}}</pre><div>

{% else %}
<p>
To require the Director of the Government Publishing Office to establish and maintain an online portal accessible to the public that allows the public to obtain electronic copies of all congressionally mandated reports in one place, and for other purposes.
</p>
{% endif %} -->
<p>{{ bill.summary }}</p>
<div class="pre-wrapper"><pre>{{ bill.summary |truncatewords_html:100 }}</pre></div>
{% endif %}

<h5><b>Bill Stage:</b></h5>
<p>Bill Stage will appear here</p>

{% if bill.get_related_bill_numbers %}
<h5><b>Related Bills:</b></h5>
{{bill.get_related_bill_numbers|join:", "}}
{{bill.get_related_bill_numbers|billnumbers_display|join:", "}}
{% endif %}

<h5><b>Recent Actions (in focus):</b></h5>
Expand Down Expand Up @@ -179,7 +177,7 @@ <h4>Bills Related to {{ bill.get_type_abbrev }} {{ bill.number }}</h4>
<tr>
<td>
<a href="{% url 'bill-detail' slug=bill.bill_congress_type_number %}">
{{ bill.bill_congress_type_number }}
{{ bill.bill_congress_type_number |billnumber_display }}
</a>
</td>
<td>{% if bill.reason %}{{ bill.reason }}{% endif %}</td>
Expand Down Expand Up @@ -256,10 +254,10 @@ <h4>Analyze Similar Bills</h4>
<td>
{% if bill.in_db %}
<a href="{% url 'bill-detail' slug=bill.bill_congress_type_number %}">
{{ bill.bill_congress_type_number }}
{{ bill.bill_congress_type_number|billnumber_display }}
</a>
{% else %}
{{ bill.bill_congress_type_number }}
{{ bill.bill_congress_type_number|billnumber_display }}
{% endif %}
</td>
<td>
Expand Down Expand Up @@ -355,7 +353,7 @@ <h6 class="pt-3">
{% for cosponsor in cosponsors %}
<tr>
<td>{{ cosponsor.name }}</td>
<td>{{ cosponsor.bills }}</td>
<td>{{ cosponsor.bills|billnumbers_display|join:", "}}</td>
<td></td>
<td></td>
<td></td>
Expand Down