Skip to content

Commit

Permalink
Installed a bunch of pre-commit hooks and ran them. Also fixed all fl…
Browse files Browse the repository at this point in the history
…ake8 issues. (#1010)
  • Loading branch information
valberg authored May 15, 2022
1 parent b63485f commit fa1a569
Show file tree
Hide file tree
Showing 288 changed files with 12,880 additions and 11,971 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[flake8]
max-line-length = 88
ignore = E501 W503 E231

1 change: 0 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88

83 changes: 67 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,73 @@
default_language_version:
python: python3
exclude: ^.*\b(migrations)\b.*$
repos:
- repo: "https://github.com/ambv/black"
rev: "21.4b2"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: "black"
language_version: "python3"
- repo: "https://gitlab.com/pycqa/flake8"
rev: "3.9.1"
- id: check-ast
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-private-key
- id: check-added-large-files
- id: check-json
- id: check-symlinks
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
args: [--fix=lf]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
hooks:
- id: "flake8"
- repo: "https://github.com/pre-commit/mirrors-isort"
rev: "v5.8.0"
- id: reorder-python-imports
args:
- --py3-plus
- --application-directories=.:src
exclude: migrations/
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: rst-backticks
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: "isort"
- repo: "https://github.com/myint/autoflake"
rev: "v1.4"
- id: pyupgrade
args:
- --py39-plus
exclude: migrations/
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.4.0
hooks:
- id: "autoflake"
- id: django-upgrade
args:
- "--in-place"
- "--remove-all-unused-imports"
- "--ignore-init-module-imports"
- --target-version=4.0
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.2.1
hooks:
- id: add-trailing-comma
- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
hooks:
- id: pycln
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
args: [--max-line-length=120]
1 change: 0 additions & 1 deletion scripts/schemagif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ for MIGRATION in $MIGRATIONS; do
cd ..
cd ..
done

16 changes: 11 additions & 5 deletions src/backoffice/forms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from django import forms

from program.models import Event, Speaker
from program.models import Event
from program.models import Speaker


class AddRecordingForm(forms.ModelForm):
recording_url = forms.URLField(
label="Recording URL", help_text="Add a URL to the recording.", required=False
label="Recording URL",
help_text="Add a URL to the recording.",
required=False,
)

class Meta:
Expand Down Expand Up @@ -63,12 +66,14 @@ class Meta:
"event_conflicts",
]

def __init__(self, camp, matrix={}, *args, **kwargs):
def __init__(self, camp, matrix=None, *args, **kwargs):
"""
initialise the form and add availability fields to form
"""
super().__init__(*args, **kwargs)

matrix = matrix or {}

# do we have a matrix to work with?
if not matrix:
return
Expand All @@ -85,14 +90,15 @@ def __init__(self, camp, matrix={}, *args, **kwargs):
continue
# add the field
self.fields[matrix[date][daychunk]["fieldname"]] = forms.BooleanField(
required=False
required=False,
)
# add it to Meta.fields too
self.Meta.fields.append(matrix[date][daychunk]["fieldname"])

# only show events from this camp
self.fields["event_conflicts"].queryset = Event.objects.filter(
track__camp=camp, event_type__support_speaker_event_conflicts=True
track__camp=camp,
event_type__support_speaker_event_conflicts=True,
)


Expand Down
6 changes: 4 additions & 2 deletions src/backoffice/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class PosViewMixin(CampViewMixin, UserPassesTestMixin):
def setup(self, *args, **kwargs):
super().setup(*args, **kwargs)
self.pos = get_object_or_404(
Pos, team__camp=self.camp, slug=self.kwargs["pos_slug"]
Pos,
team__camp=self.camp,
slug=self.kwargs["pos_slug"],
)

def test_func(self):
Expand All @@ -64,7 +66,7 @@ def test_func(self):
raise PermissionDenied("User has no backoffice permission")

if not self.request.user.has_perm(
"camps.orgateam_permission"
"camps.orgateam_permission",
) and not self.request.user.has_perm("camps." + self.pos.team.permission_set):
raise PermissionDenied("User has no permission for this Pos")
return True
Expand Down
1 change: 0 additions & 1 deletion src/backoffice/templates/add_recording.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/approve_feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/approve_public_credit_names.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ <h2>Approve Public Credit Names</h2>
</table>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/autoschedule_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ <h4 class="list-group-item-heading">
</div>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/badge_handout.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ <h2>Hand Out Badges</h2>
</table>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/camp_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ <h4 class="list-group-item-heading">{{ camp.title }}</h4>
</div>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/credebtor_detail_backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ <h3>{{ revenues.count }} Revenues for Credebtor {{ credebtor.name }}</h3>
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/event_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ <h2 class="panel-title">Really Delete Event?</h2>
</div>
</div>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ <h3 class="panel-title">Approve or Reject {{ form.instance.event_type.name }} Pr
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/event_schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ <h3 class="panel-title">Select EventSlot for <i>{{ event.title }}</i></h3>
</div>
</div>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ <h4 class="list-group-item-heading">
</div>
</div>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ <h4 class="list-group-item-heading">
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/event_session_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ <h2 class="panel-title">Delete EventSession?</h2>
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/event_session_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ <h4 class="panel-title">We have {{ sessions.count }} existing EventSessions for
</div>
{% endif %}
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/event_slot_unschedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ <h3 class="panel-title">Unschedule Event <i>{{ event_slot.event.title }}</i>?</h
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/expense_detail_backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ <h3>Manage Expense</h3>
<a href="{% url 'backoffice:expense_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Back to Expense List</a>

{% endblock content %}

3 changes: 1 addition & 2 deletions src/backoffice/templates/facility_detail_backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h3 class="panel-title">{{ facility.name }} | Facilities | BackOffice</h3>
</tr>
</thead>
<tbody>
{% for feedback in facility.feedbacks.all %}
{% for feedback in facility.feedbacks.all %}
<tr>
<td>{{ feedback.user|default:"N/A" }}</td>
<td>{{ feedback.created }}</td>
Expand Down Expand Up @@ -134,4 +134,3 @@ <h3 class="panel-title">{{ facility.name }} | Facilities | BackOffice</h3>
<script src="{% static 'js/kfmap.js' %}" type="text/javascript"></script>

{% endblock %}

1 change: 0 additions & 1 deletion src/backoffice/templates/facilityfeedback_backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ <h4 class="panel-title">Feedback for {{ feedback.facility.name }} by {{ feedback
</div>
</div>
{% endblock %}

Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@
{% endfor %}
</tbody>
</table>

Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@
{% endfor %}
</tbody>
</table>

1 change: 0 additions & 1 deletion src/backoffice/templates/includes/invoice_list_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
{% else %}
<h4>No invoices found.</h4>
{% endif %}

1 change: 0 additions & 1 deletion src/backoffice/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,3 @@ <h4 class="list-group-item-heading">Token Stats</h4>
</div>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/info_desk/scan.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@ <h3>Order #{{ order.id }}</h3>
<script src="{% static 'js/ticket_scan.js' %}"></script>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/outgoing_email_mass_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ <h4 class="panel-title">From {{ form.instance.sender }}: {{ form.instance.subjec
</div>
</div>
{% endblock %}

1 change: 0 additions & 1 deletion src/backoffice/templates/product_handout.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ <h2>Hand Out Products</h2>
</table>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/reimbursement_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ <h3 class="panel-title">The following approved expenses will be covered by this
<a href="{% url 'backoffice:reimbursement_create_userselect' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
</form>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ <h4 class="list-group-item-heading">{{ user.username }}</h4>
</div>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/reimbursement_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ <h3>Delete Reimbursement for User {{ reimbursement_user }}</h3>
<a href="{% url 'backoffice:reimbursement_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
</form>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ <h3>Reimbursement Details</h3>
<a class="btn btn-primary" href="{% url "backoffice:reimbursement_list" camp_slug=camp.slug %}"><i class="fas fa-undo"></i> Back to reimbursement list</a>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/reimbursement_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ <h3>Update Reimbursement for User {{ reimbursement_user }}</h3>
<a href="{% url 'backoffice:reimbursement_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
</form>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/revenue_detail_backoffice.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ <h3>Manage Revenue</h3>
<a href="{% url 'backoffice:revenue_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Back to Revenue List</a>

{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/speaker_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ <h2 class="panel-title">Delete Speaker {{ object.name }}?</h2>
</div>
</div>
{% endblock content %}

Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ <h3 class="panel-title">Approve or Reject SpeakerProposal: {{ speaker_proposal.n
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/speaker_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ <h3 class="panel-title">Update Speaker: {{ speaker.name }}</h3>
</div>
</div>
{% endblock content %}

1 change: 0 additions & 1 deletion src/backoffice/templates/ticket_checkin.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ <h2>Ticket Check-In</h2>
</table>
</div>
{% endblock content %}

2 changes: 1 addition & 1 deletion src/backoffice/templates/zettle_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<p>We currently have <b>{{ receipts }} receipts</b> and <b>{{ balances }} balances</b> registered in the system.</p>

{% if balance %}
<p>The latest Zettle balance is from <b>{{ balance.statement_time }}</b> and at that time our balance in Zettle was <b>{{ balance.balance }}&nbsp;DKK</b>.
<p>The latest Zettle balance is from <b>{{ balance.statement_time }}</b> and at that time our balance in Zettle was <b>{{ balance.balance }}&nbsp;DKK</b>.

Use the links below to see details or to import new data.</p>
{% endif %}
Expand Down
Loading

0 comments on commit fa1a569

Please sign in to comment.