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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挌 Use pre-commit in ci #756

Draft
wants to merge 2 commits into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .djlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore": "T002,T003,H005,H006,H023,H029,H030,H031"
}
15 changes: 3 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@ jobs:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[lint]
yarn install
- name: Run flake8
run: flake8 froide --statistics
- name: Run black
run: black --check froide
- name: Run isort
run: isort --check froide
- name: Run eslint
run: yarn lint
run: yarn install

- uses: pre-commit/action@v3.0.0

test:
runs-on: ubuntu-latest
Expand Down
49 changes: 25 additions & 24 deletions froide/account/templates/account/admin_send_mail.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@
<label>
{% trans "Subject" %}:
<input type="text" name="subject" value="" />
</p>
<textarea name="body" rows="8" style="width: 100%">{% include "emails/footer.txt" %}</textarea>
<br />
<small>{% trans "You can use the following placeholders:" %} <code>{name}, {first_name}, {last_name}, {url}</code></small>
<input type="hidden" name="action" value="send_mail" />
<p>
<input type="submit"
value="{% blocktrans count count=queryset.count %}Send mail to one user{% plural %}Send mail to {{ count }} users{% endblocktrans %}" />
</p>
</div>
<input type="hidden" name="action" value="{{ action_name }}" />
{% if select_across %}
<input type="hidden" name="select_across" value="1" />
{# set invalid selected, so confirmation action path is chosen in admin #}
<input type="hidden" name="{{ action_checkbox_name }}" value="_" />
{% else %}
{% for obj in queryset %}
<input type="hidden"
name="{{ action_checkbox_name }}"
value="{{ obj.pk|unlocalize }}" />
{% endfor %}
{% endif %}
</form>
{% endblock %}
</label>
</p>
<textarea name="body" rows="8" style="width: 100%">{% include "emails/footer.txt" %}</textarea>
<br />
<small>{% trans "You can use the following placeholders:" %} <code>{name}, {first_name}, {last_name}, {url}</code></small>
<input type="hidden" name="action" value="send_mail" />
<p>
<input type="submit"
value="{% blocktrans count count=queryset.count %}Send mail to one user{% plural %}Send mail to {{ count }} users{% endblocktrans %}" />
</p>
</div>
<input type="hidden" name="action" value="{{ action_name }}" />
{% if select_across %}
<input type="hidden" name="select_across" value="1" />
{# set invalid selected, so confirmation action path is chosen in admin #}
<input type="hidden" name="{{ action_checkbox_name }}" value="_" />
{% else %}
{% for obj in queryset %}
<input type="hidden"
name="{{ action_checkbox_name }}"
value="{{ obj.pk|unlocalize }}" />
{% endfor %}
{% endif %}
</form>
{% endblock %}
2 changes: 2 additions & 0 deletions froide/account/templates/account/includes/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<nav class="container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
{# djlint:off D018 #}
<a href="/">
{#djlint:on #}
<i class="fa fa-home"></i>
<span class="sr-only">{% trans "Home Page" %}</span>
</a>
Expand Down
15 changes: 8 additions & 7 deletions froide/account/templates/account/includes/impostor.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load i18n %}
{# style inline so it works everywhere #}
{# djlint:off H021 #}
<div style="background-color: red;
color: #fff;
text-align: center;
Expand All @@ -9,15 +10,15 @@
left:0;
top: 0;
z-index: 99999999">
{% blocktrans with user=request.user.get_full_name impostor=request.session.impostor %}
{% blocktrans with user=request.user.get_full_name impostor=request.session.impostor %}
WARNING! {{ impostor}}, you are an impostor! You pretend to be <strong>{{ user }}</strong>!
{% endblocktrans %}
<form action="{% url 'account-logout' %}"
method="post"
class="d-inline float-end">
{% csrf_token %}
<button type="submit" class="btn-warning">{% blocktrans %}Eject{% endblocktrans %}</button>
</form>
<form action="{% url 'account-logout' %}"
method="post"
class="d-inline float-end">
{% csrf_token %}
<button type="submit" class="btn-warning">{% blocktrans %}Eject{% endblocktrans %}</button>
</form>
</div>
<div style="border: 2px red dashed;
top:0;
Expand Down
17 changes: 9 additions & 8 deletions froide/account/templates/account/reauth.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ <h5>{% translate "Use your password" %}</h5>
</form>
</li>
{% endif %}
</div>
</ul>
</div>
</div>
</div>
{% endblock body %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'account/cbor.js' %}"></script>
<script src="{% static 'mfa/fido2.js' %}"></script>
<script async src="{% static 'account/mfa.js' %}"></script>
{% endblock %}
</div>
{% endblock body %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'account/cbor.js' %}"></script>
<script src="{% static 'mfa/fido2.js' %}"></script>
<script async src="{% static 'account/mfa.js' %}"></script>
{% endblock %}
5 changes: 1 addition & 4 deletions froide/account/templates/account/widgets/confirmation.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% load i18n %}
{% include "django/forms/widgets/input.html" %}
<p style="-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none">
<p class="user-select-none">
{% blocktrans with phrase=widget.phrase %}Please type this phrase to confirm: {{ phrase }}{% endblocktrans %}
</p>
1 change: 1 addition & 0 deletions froide/account/templates/account/widgets/pininput.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{# djlint:off H021 #}
<div class="d-flex flex-row justify-content-center">
<input class="form-control rounded"
data-pininput="{{ digits | length }}"
Expand Down
2 changes: 2 additions & 0 deletions froide/account/templates/admin/account/user/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<form method="post"
action="{% url 'admin:admin-account_user-become_user' pk=original.pk %}">
{% csrf_token %}
{# djlint:off H021 #}
<button type="submit" style="text-align:left">{% blocktrans %}Become user{% endblocktrans %}</button>
{# djlint:on #}
</form>
{% endif %}
{% endblock %}
14 changes: 7 additions & 7 deletions froide/comments/templates/froide_comments/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<a href="#more-commenttext-{{ comment.id }}"
class="hideparent"
data-bs-toggle="collapse">{% trans "Read all" %}</a></span>
<span id="more-commenttext-{{ comment.id }}" class="collapse">{{ comment.comment|urlizetrunc:40|linebreaksbr }}</span>
{% else %}
{{ comment.comment|urlizetrunc:40|linebreaksbr }}
{% endif %}
<span id="more-commenttext-{{ comment.id }}" class="collapse">{{ comment.comment|urlizetrunc:40|linebreaksbr }}</span>
{% else %}
{{ comment.comment|urlizetrunc:40|linebreaksbr }}
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<textarea rows="8" class="form-control mb-3" name="description">{{ object.description }}</textarea>
{% endblock %}
{% block saveurl %}
{% url 'document-set_description' pk=object.pk %}{% endblock %}
{% block autofocus %}[name='description']{% endblock %}
{% url 'document-set_description' pk=object.pk %}
{% endblock %}
{% block autofocus %}[name='description']{% endblock %}
7 changes: 4 additions & 3 deletions froide/document/templates/filingcabinet/_set_title_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
value="{{ object.title }}">
{% endblock %}
{% block fromclasses %}{{ block.super }} d-flex{% endblock %}
{% block saveurl %}
{% url 'document-set_title' pk=object.pk %}{% endblock %}
{% block autofocus %}[name='title']{% endblock %}
{% block saveurl %}
{% url 'document-set_title' pk=object.pk %}
{% endblock %}
{% block autofocus %}[name='title']{% endblock %}
2 changes: 2 additions & 0 deletions froide/foirequest/templates/foirequest/attachment/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ <h2>{% trans "Manage attachments" %}</h2>
<document-uploader id="document-uploader" :message="{{ message_json }}" :config="{{ config_json }}">
<div class="text-center">
<h4>{% trans "Attachments are loading..." %}</h4>
{# djlint:off H021 #}
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
{# djlint:on #}
<span class="visually-hidden">{% trans "Loading..." %}</span>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions froide/foirequest/templates/foirequest/attachment/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ <h2>{% blocktrans with name=attachment.name %}Attachment 鈥渰{ name }}鈥漿% endb
{% if attachment.can_embed %}
{% if attachment.is_pdf %}
<div class="container-sm-full d-none d-md-block">
{# djlint:off H021 #}
<iframe src="{{ attachment_url }}"
frameborder="0"
style="width: 100%;
height: 90vh;
border: 0"
loading="lazy">
</iframe>
{# djlint:on #}
</div>
<div class="container d-block d-md-none text-center">
<a class="btn btn-outline-secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endblock foirequest_messages %}
{% block after_foirequest_messages %}
{% if object|can_write_foirequest:request and object.awaits_classification %}
<div class="position-sticky d-print-none" style="bottom: 0">
<div class="position-sticky d-print-none bottom-0">
<div class="bg-warning-subtle text-center p-2">
<a href="#set-status" data-scrollto="set-status">{% translate "Please set the status of this request!" %}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
{% endif %}
{% if attachment.approved %}
{% if attachment.is_mail_decoration %}
{# djlint:off H008 #}
<span data-bs-toggle="tooltip" data-bs-html="true" title="
<h6>{{ attachment.name }}</h6>
<img src='{{ attachment.get_authorized_absolute_domain_file_url }}'
alt='{{ attachment.name }}'/>
">
{# djlint:on #}
<i class="fa fa-picture-o" aria-hidden="true"></i>
</span>
{% endif %}
Expand All @@ -71,11 +73,13 @@ <h6>{{ attachment.name }}</h6>
{% if attachment.pending %}
<span class="me-1 badge text-bg-info">{% blocktrans %}PDF Pending{% endblocktrans %}</span>
{% elif attachment.is_mail_decoration and object|can_read_foirequest_authenticated:request %}
{# djlint:off H008 #}
<span data-bs-toggle="tooltip" data-bs-html="true" title="
<h6>{{ attachment.name }}</h6>
<img src='{{ attachment.get_authorized_absolute_domain_file_url }}'
alt='{{ attachment.name }}'/>
">
{# djlint:on #}
<i class="fa fa-picture-o" aria-hidden="true"></i>
</span>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% include "foirequest/body/message/attachments/item.html" with attachment=wrapped_attachments|first %}
{# else wrap all remaining items#}
{% elif wrapped_attachments|length > 1 %}
<div style="display: none;">
<div class="d-none">
{% for attachment in wrapped_attachments %}
{% include "foirequest/body/message/attachments/item.html" %}
{% endfor %}
Expand Down