Skip to content

Commit 48c5f98

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1ea24f3 commit 48c5f98

5 files changed

Lines changed: 11 additions & 15 deletions

File tree

othello/apps/auth/views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
from django.shortcuts import get_object_or_404, render
99

1010
from ..games.forms import MatchForm
11-
from ..games.models import Submission, RatingHistory
12-
11+
from ..games.models import RatingHistory, Submission
1312

1413
logger = logging.getLogger("othello")
1514

15+
1616
def index(request: HttpRequest) -> HttpResponse:
1717
return render(request, "auth/index.html")
1818

@@ -70,7 +70,9 @@ def rankings(request: HttpRequest) -> HttpResponse:
7070
page_number = request.GET.get("page")
7171
page_obj = paginator.get_page(page_number)
7272
form = MatchForm(request.user)
73-
users_with_submissions = set(Submission.objects.values_list('user__username', flat=True).distinct()) - {request.user.username, "Yourself"}
73+
users_with_submissions = set(
74+
Submission.objects.values_list("user__username", flat=True).distinct()
75+
) - {request.user.username, "Yourself"}
7476
return render(
7577
request,
7678
"auth/rankings.html",

othello/apps/games/forms.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,15 @@ def __init__(self, user, *args, initial_opponent_user=None, **kwargs):
9191
super().__init__(*args, **kwargs)
9292

9393
opponents = (
94-
Submission.objects.latest()
95-
.exclude(user=user)
96-
.exclude(user__username="Yourself")
94+
Submission.objects.latest().exclude(user=user).exclude(user__username="Yourself")
9795
)
9896
self.fields["opponent"].queryset = opponents
9997
self.fields["opponent"].label_from_instance = Submission.get_game_name
10098

10199
if initial_opponent_user:
102100
try:
103-
opponent_submission = (
104-
Submission.objects
105-
.filter(user=initial_opponent_user)
106-
.latest(onesub=True)
101+
opponent_submission = Submission.objects.filter(user=initial_opponent_user).latest(
102+
onesub=True
107103
)
108104
self.fields["opponent"].initial = opponent_submission
109105
except Submission.DoesNotExist:

othello/apps/games/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def calculate_results(self) -> None:
207207
rating2=rating2,
208208
player1_wins=player1_wins,
209209
player2_wins=player2_wins,
210-
ties=ties
210+
ties=ties,
211211
)
212212

213213
user1.rating = rating1 + change1

othello/apps/games/views.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ def request_match(request: HttpRequest) -> HttpResponse:
160160
opponent_username = request.GET.get("opponent")
161161
if opponent_username:
162162
try:
163-
initial_opponent_user = get_user_model().objects.get(
164-
username=opponent_username
165-
)
163+
initial_opponent_user = get_user_model().objects.get(username=opponent_username)
166164
except get_user_model().DoesNotExist:
167165
pass
168166

othello/templates/auth/rankings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h5 class="modal-title" id="requestMatchModalLabel">Request a Match</h5>
7777
action = action.split('?')[0];
7878
}
7979
form.attr('action', action + '?opponent=' + encodeURIComponent(username));
80-
80+
8181
var select = form.find('select[name="opponent"]');
8282
select.find('option').each(function() {
8383
if ($(this).text().indexOf('(' + username + ')') !== -1) {

0 commit comments

Comments
 (0)