Skip to content

Commit

Permalink
add djhtml, lint templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeriox committed Jul 30, 2024
1 parent 324c882 commit 47666e6
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 356 deletions.
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3.12
repos:
- repo: https://github.com/myint/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand All @@ -16,9 +16,15 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/rtts/djhtml
rev: '3.0.6'
hooks:
- id: djhtml
- id: djcss
- id: djjs
- repo: local
hooks:
- id: prettier-eslint
Expand Down
2 changes: 1 addition & 1 deletion myhpi/core/templates/core/minutes.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1 class="side-panel-title">{% translate "Labels" %}</h1>
</div>
</div>
</div>
{% endwith %}
{% endwith %}
</div>
{% endblock %}

Expand Down
86 changes: 0 additions & 86 deletions myhpi/core/templates/core/minutes_list.html
Original file line number Diff line number Diff line change
@@ -1,86 +0,0 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% load i18n %}

{% block content %}
<h1 class="page-title">
<span class="underline">
{{ page.title }} {{ selected_year }}
</span>
</h1>
{% if minutes %}
<table class="table table-striped">
{% for minute in minutes %}
<tr>
<td><a href="{{ minute.get_valid_url }}">{{ minute.date|date:"d.m.Y" }}</a></td>
<td>
{% if minute.has_unpublished_changes %}
<span title='{% translate "Page has unpublished changes!" %}' aria-hidden="true">⚠️</span>
{% endif %}
</td>
<td>
{% include "core/label.html" with minutes=minute %}
</td>
<td><a href="{{ minute.get_valid_url }}">{{ minute.title }}</a></td>
<td>
{% if minute.attachments.count > 0 %}
<span class="text-gray" data-toggle="tooltip" data-placement="left" data-container="body" title="{{ minute.attachments.all|join:', ' }}">
📦
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>
{% translate "No minutes available for this year." %}
</p>
{% endif %}
{% if all_years|length > 1 %}
<nav aria-label="Page navigation" class="d-inline-block">
<ul class="pagination">
<li class="page-item {% if selected_year == all_years|first %} disabled {% endif %}">
<a class="page-link" href="{{ minute_list.get_valid_url }}?year={{ all_years|first }}" aria-label="First">
<span aria-hidden="true">&laquo;</span>
</a>
</li>

{% if all_years|first != year_range|first %}
<li class="page-item disabled">
<a class="page-link" aria-label="More">
<span aria-hidden="true">...</span>
</a>
</li>
{% endif %}

{% for paginated_year in year_range %}
<li
{% if selected_year == paginated_year %}
class="page-item active" aria-current="true"
{% else %}
class="page-item"
{% endif %}>
<a class="page-link" href="{{ minute_list.get_valid_url }}?year={{ paginated_year }}">
{{ paginated_year }}
</a>
</li>
{% endfor %}

{% if all_years|last != year_range|last %}
<li class="page-item disabled">
<a class="page-link" aria-label="More">
<span aria-hidden="true">...</span>
</a>
</li>
{% endif %}

<li class="page-item {% if selected_year == all_years|last %} disabled {% endif %}">
<a class="page-link" href="{{ minute_list.get_valid_url }}?year={{ all_years|last }}" aria-label="Last">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
{% endif %}
{% endblock %}
8 changes: 4 additions & 4 deletions myhpi/core/templates/core/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ <h1 class="side-panel-title">{% translate "Visibility" %}</h1>
This duplication is a workaround and should be removed after the upgrade -->
<div class="d-none d-lg-block side-panel-container">
{%if parsed_md.1|hasTocContent %}
<aside class="side-panel border-accent sidebar-container d-print-none">
<h1 class="side-panel-title">{% translate "Table of contents" %}</h1>
{{ parsed_md.1 }}
</aside>
<aside class="side-panel border-accent sidebar-container d-print-none">
<h1 class="side-panel-title">{% translate "Table of contents" %}</h1>
{{ parsed_md.1 }}
</aside>
{% endif %}
{% if page.attachments.all %}
<aside class="side-panel border-accent sidebar-container d-print-none">
Expand Down
2 changes: 1 addition & 1 deletion myhpi/core/templates/core/toc_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{%if toc|hasTocContent %}
<div id="sidebar-toggle" class="d-grid d-lg-none d-print-none">
<button type="button" data-bs-toggle="offcanvas" data-bs-target="#sidebar-offcanvas"
aria-controls="sidebar-offcanvas" class="btn btn-light mb-3" aria-label="{% translate 'Table of contents' %}">
aria-controls="sidebar-offcanvas" class="btn btn-light mb-3" aria-label="{% translate 'Table of contents' %}">
{% bs_icon 'list-ol' size='1.3rem' %}
{% translate "Table of contents" %}
</button>
Expand Down
2 changes: 1 addition & 1 deletion myhpi/polls/templates/polls/majority_vote_poll.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% csrf_token %}
{% for choice in page.choices.all %}
<input type={% if page.max_allowed_answers > 1 %} "checkbox" {% else %} "radio"
{% endif %} name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
{% endif %} name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
<label for="choice{{ forloop.counter }}">{{ choice.text }}</label><br/>
{% endfor %}
<input type="submit" value="Vote"/>
Expand Down
18 changes: 9 additions & 9 deletions myhpi/polls/templates/polls/poll_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ <h1 class="page-title">
<th>{% translate "Title" %}</th>
<th>{% translate "Voting period" %}</th>
</tr>
<tbody>
{% for poll in poll_list %}
<tr>
<td><a href="{% pageurl poll %}">{{ poll.title }}</a></td>
<td>{{ poll.start_date }} - {{ poll.end_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<tbody>
{% for poll in poll_list %}
<tr>
<td><a href="{% pageurl poll %}">{{ poll.title }}</a></td>
<td>{{ poll.start_date }} - {{ poll.end_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
24 changes: 12 additions & 12 deletions myhpi/polls/templates/polls/ranked_choice_poll.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
{% block results %}
<table class="table">
<thead>
<tr>
<th scope="col"> {% translate "Rank" %}</th>
<th scope="col"> {% translate "Choice" %}</th>
<th scope="col"> {% translate "Final Votes" %}</th>
</tr>
</thead>
<tbody>
{% for choice in page.calculate_ranking %}
<tr>
<th scope="row"> {{ choice.0 }} </th>
<td> {{ choice.1 }} </td>
<td> {{ choice.2 }} </td>
<th scope="col"> {% translate "Rank" %}</th>
<th scope="col"> {% translate "Choice" %}</th>
<th scope="col"> {% translate "Final Votes" %}</th>
</tr>
{% endfor %}
</thead>
<tbody>
{% for choice in page.calculate_ranking %}
<tr>
<th scope="row"> {{ choice.0 }} </th>
<td> {{ choice.1 }} </td>
<td> {{ choice.2 }} </td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
138 changes: 69 additions & 69 deletions myhpi/search/templates/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,79 @@
{% block title %}{% translate "Search" %}{% endblock %}

{% block content %}
<h1 class="page-title">
<span class="underline">
{% translate "Search" %}
</span>
</h1>
<h1 class="page-title">
<span class="underline">
{% translate "Search" %}
</span>
</h1>

{% include "search/search_field.html" %}
{% include "search/search_field.html" %}

{% if search_results_page %}
{% if search_results_page %}

<i class="d-block mb-3 ps-1">
{% if search_results_page.paginator.count == 1 %}
{% translate "One result found." %}
{% else %}
{{ search_results_page.paginator.count }}{% blocktrans %} results found.{% endblocktrans %}
{% endif %}
</i>
<i class="d-block mb-3 ps-1">
{% if search_results_page.paginator.count == 1 %}
{% translate "One result found." %}
{% else %}
{{ search_results_page.paginator.count }}{% blocktrans %} results found.{% endblocktrans %}
{% endif %}
</i>

<ul class="search-result-list d-block pb-3">
{% for result in search_results_page %}
{% include "search/search_result.html" %}
{% endfor %}
</ul>
<ul class="search-result-list d-block pb-3">
{% for result in search_results_page %}
{% include "search/search_result.html" %}
{% endfor %}
</ul>

<nav aria-label="Page navigation" class="d-inline-block">
<ul class="pagination">
{% if search_results_page.has_previous %}
<li class="page-item">
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results_page.previous_page_number }}"
aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% for page_index in search_results_page.paginator.page_range %}
<li
{% if page_index == search_results_page.number %}
class="page-item active" aria-current="page"
{% else %}
class="page-item"
{% endif %}>
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ page_index }}">
{{ page_index }}
</a>
</li>
{% endfor %}
{% if search_results_page.has_next %}
<li class="page-item">
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results_page.next_page_number }}"
aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>
<nav aria-label="Page navigation" class="d-inline-block">
<ul class="pagination">
{% if search_results_page.has_previous %}
<li class="page-item">
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results_page.previous_page_number }}"
aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% for page_index in search_results_page.paginator.page_range %}
<li
{% if page_index == search_results_page.number %}
class="page-item active" aria-current="page"
{% else %}
class="page-item"
{% endif %}>
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ page_index }}">
{{ page_index }}
</a>
</li>
{% endfor %}
{% if search_results_page.has_next %}
<li class="page-item">
<a class="page-link"
href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results_page.next_page_number }}"
aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>

{% elif search_query %}
<i class="d-block pb-3 ps-1">{% translate "No results found." %}</i>
{% endif %}
{% elif search_query %}
<i class="d-block pb-3 ps-1">{% translate "No results found." %}</i>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion myhpi/search/templates/search/search_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<div class="input-group">
<input type="search" class="form-control" name="query" placeholder="{% translate 'Search...' %}" {% if search_query %} value="{{ search_query }}" {% endif %}>
<button type="submit"
class="btn btn-primary" aria-label="{% translate 'Search' %}">{% bs_icon "search" extra_classes="text-light" %}</button>
class="btn btn-primary" aria-label="{% translate 'Search' %}">{% bs_icon "search" extra_classes="text-light" %}</button>
</div>
</form>
6 changes: 3 additions & 3 deletions myhpi/templates/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ <h1>{% translate "Access denied" %}</h1>
<p>{% translate "Unfortunately you are not allowed to view this page. This might have one of the following reasons:" %}</p>

<ul class="pb-3">
<li>{% translate "You are not logged in and are not accessing the page from the university network." %}</li>
<li>{% translate "You are not logged in and the page is only available for logged in users." %}</li>
<li>{% translate "You are logged in but don't have the required permissions to access this page." %}</li>
<li>{% translate "You are not logged in and are not accessing the page from the university network." %}</li>
<li>{% translate "You are not logged in and the page is only available for logged in users." %}</li>
<li>{% translate "You are logged in but don't have the required permissions to access this page." %}</li>
</ul>
{% endblock %}
Loading

0 comments on commit 47666e6

Please sign in to comment.