Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Jan 26, 2024
1 parent f6fc9fd commit e814a20
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 51 deletions.
6 changes: 3 additions & 3 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
repos:
- repo: https://github.com/myint/autoflake
rev: v2.1.1
rev: v2.2.1
hooks:
- id: autoflake
args:
Expand All @@ -12,11 +12,11 @@ repos:
- --ignore-init-module-imports
- --expand-star-imports
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 24.1.0
hooks:
- id: black
- repo: https://github.com/rtts/djhtml
Expand Down
8 changes: 5 additions & 3 deletions ephios/extra/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

def calculate_luminance(rgb: tuple):
r, g, b = map(
lambda channel: channel / 255 / 12.92
if channel / 255 <= 0.03928
else ((channel / 255 + 0.055) / 1.055) ** 2.4,
lambda channel: (
channel / 255 / 12.92
if channel / 255 <= 0.03928
else ((channel / 255 + 0.055) / 1.055) ** 2.4
),
rgb,
)
return 0.2126 * r + 0.7152 * g + 0.0722 * b
Expand Down
26 changes: 14 additions & 12 deletions ephios/plugins/basesignup/signup/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,20 @@ class ConfigurationForm(super().configuration_form_class):
widget=Select2MultipleWidget,
required=False,
initial=[],
help_text=_(
"Participants also need to have the qualifications <b>{qualifications}</b> to participate in {eventtype}"
).format(
qualifications=",".join(
self.event.type.preferences.get("general_required_qualifications")
.all()
.values_list("title", flat=True)
),
eventtype=self.event.type,
)
if self.event.type.preferences.get("general_required_qualifications").exists()
else None,
help_text=(
_(
"Participants also need to have the qualifications <b>{qualifications}</b> to participate in {eventtype}"
).format(
qualifications=",".join(
self.event.type.preferences.get("general_required_qualifications")
.all()
.values_list("title", flat=True)
),
eventtype=self.event.type,
)
if self.event.type.preferences.get("general_required_qualifications").exists()
else None
),
)

@staticmethod
Expand Down
15 changes: 0 additions & 15 deletions ephios/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
"""ephios URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.contrib import admin
from django.urls import include, path
Expand Down
5 changes: 2 additions & 3 deletions tests/core/test_signup_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def test_partially_conflicting_shift_results_in_invalid_signup_form(
user=volunteer,
).form.submit(name="signup_choice", value="sign_up")
assert "You are already confirmed for other shifts at this time" in response
response.form[
"individual_start_time_1"
] = "19:42" # move start to after the conflicting event ended
# move start to after the conflicting event ended
response.form["individual_start_time_1"] = "19:42"
assert (
"successfully requested a participation"
in response.form.submit(name="signup_choice", value="sign_up").follow()
Expand Down
30 changes: 15 additions & 15 deletions tests/plugins/qualification_management/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@

def test_repo_fetch():
preferences = global_preferences_registry.manager()
preferences[
"general__qualification_management_repos"
] = "https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/test.json"
preferences["general__qualification_management_repos"] = (
"https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/test.json"
)
assert list(fetch_deserialized_qualifications_from_repo())


def test_not_a_list_repo():
preferences = global_preferences_registry.manager()
preferences[
"general__qualification_management_repos"
] = "https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/not-a-list.json"
preferences["general__qualification_management_repos"] = (
"https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/not-a-list.json"
)
with pytest.raises(RepoError):
list(fetch_deserialized_qualifications_from_repo())


def test_missing_key_repo():
preferences = global_preferences_registry.manager()
preferences[
"general__qualification_management_repos"
] = "https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/key-missing.json"
preferences["general__qualification_management_repos"] = (
"https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/key-missing.json"
)
with pytest.raises(RepoError):
list(fetch_deserialized_qualifications_from_repo())


def test_import_view(django_app, superuser):
preferences = global_preferences_registry.manager()
preferences[
"general__qualification_management_repos"
] = "https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/test.json"
preferences["general__qualification_management_repos"] = (
"https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/test.json"
)
form = django_app.get(
reverse("qualification_management:settings_qualification_import"),
user=superuser,
Expand All @@ -73,9 +73,9 @@ def test_import_view(django_app, superuser):

def test_import_view_with_broken_repo(django_app, superuser):
preferences = global_preferences_registry.manager()
preferences[
"general__qualification_management_repos"
] = "https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/key-missing.json"
preferences["general__qualification_management_repos"] = (
"https://github.com/ephios-dev/ephios-qualification-fixtures/raw/main/test/key-missing.json"
)
request = django_app.get(
reverse("qualification_management:settings_qualification_import"),
user=superuser,
Expand Down

0 comments on commit e814a20

Please sign in to comment.