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

[DRAFT] Links and metadata for single doc pages #5922

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions fec/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ def display_date(self):
@property
def extension(self):
# Return the file extension of file_url
return self.file_url.rsplit('.', 1)[1].upper()
if self.file_url:
return self.file_url.rsplit('.', 1)[1].upper()


class DocumentFeedPage(ContentPage):
Expand Down Expand Up @@ -1372,7 +1373,7 @@ class ReportingDatesTable(Page):
('html', blocks.RawHTMLBlock()),
('internal_button', InternalButtonBlock()),
('external_button', ExternalButtonBlock()),
('dates_table', ReportingTableBlock(blank=True, required=False,form_classname='title')),
('dates_table', ReportingTableBlock(blank=True, required=False, form_classname='title')),
], blank=True, null=True, use_json_field=True, collapsed=False)

footnotes = StreamField([
Expand Down
34 changes: 31 additions & 3 deletions fec/home/templates/home/document_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,41 @@
{% load static %}
{% block body_class %}template-{{ self.get_verbose_name | slugify }}{% endblock %}



{% block content %}

<!--{% if "reports-about-fec" in request.path and page.content_type.model == "documentpage" and self.file_url %}
<meta http-equiv="refresh" content="0; url={% include_block self.file_url %}">
{% endif %} -->




{% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style='secondary' %}

<article class="main">
<div class="container">
<header class="heading--main heading--with-date">
<ul class="tags">
<li class="tag tag--secondary t-upper">
{{ self.category }}
<a href="{{self.get_parent.url}}?category={{ self.category | cms_query_syntax }}">{{ self.category }}</a>
</li>
</ul>
<div class="row">
{% spaceless %}{# for inline blocks #}
<h1 class="heading__left">{% formatted_title self %}</h1>
<h1 class="heading__left">{% if self.file_url %}<a href="{{ self.file_url }}">{% formatted_title self %}</a>
{% else %}
{% formatted_title self %}
{% endif %}</h1>
<div class="heading__right">
<span class="t-sans">{{ self.display_date }}</span>
<span class="t-sans">{{ self.display_date }} |
{% if self.file_url %} <a href="{{ self.file_url }}">{{ self.extension }}</a>
{% else %}
{{ self.extension }}
{% endif %}
{% if self.size %} | ({{ self.size }}){% endif %}</span>

</div>
{% endspaceless %}
</div>
Expand All @@ -31,5 +49,15 @@ <h1 class="heading__left">{% formatted_title self %}</h1>
</article>

{% include 'partials/disclaimer.html' %}
<script>
// document.getElementsByClassName('main')[0].insertAdjacentHTML("beforebegin", "<p>You will be directed</p>")
// setTimeout(() => {
// var meta = document.createElement('meta');
// meta.httpEquiv = "refresh" ;
// meta.content = "3; url={% include_block self.file_url %}";
// document.getElementsByTagName('head')[0].appendChild(meta);
// }, "0");

</script>

{% endblock %}
2 changes: 1 addition & 1 deletion fec/home/templates/partials/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ <h3>
</h3>
{% endif %}
<div class="post__meta">
<a class="tag tag--secondary" href="">{{ document.category }}</a>
<a class="tag tag--secondary" href="{{self.get_parent.url}}?category={{ document.category | cms_query_syntax }}">{{ document.category }}</a>
</div>
</article>
7 changes: 7 additions & 0 deletions fec/home/templatetags/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,10 @@ def get_file_type(value):
file_type = "EXCEL" if xl else file_extension

return file_type


@register.filter(name='cms_query_syntax')
def cms_query_syntax(string):
query = string.replace(' ', '+').lower()

return query