From b1bb43d1432de50c79f5f41d19b37e9bd21901c0 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 5 Oct 2021 18:04:47 +1100 Subject: [PATCH] lint Group views file --- bookwyrm/views/group.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py index b1f4a67a..4a6a8095 100644 --- a/bookwyrm/views/group.py +++ b/bookwyrm/views/group.py @@ -3,7 +3,7 @@ from django.apps import apps from django.contrib.auth.decorators import login_required from django.db import IntegrityError from django.core.paginator import Paginator -from django.http import HttpResponseNotFound, HttpResponseBadRequest +from django.http import HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator @@ -14,11 +14,9 @@ from django.db.models.functions import Greatest from bookwyrm import forms, models from bookwyrm.suggested_users import suggested_users -from .helpers import privacy_filter from .helpers import get_user_from_username -from bookwyrm.settings import DOMAIN - +# pylint: disable=no-self-use class Group(View): """group page""" @@ -94,7 +92,14 @@ class FindUsers(View): def get(self, request, group_id): """basic profile info""" query = request.GET.get("query") - group = models.Group.objects.get(id=group_id) + group = get_object_or_404(models.Group, id=group_id) + + if not group: + return HttpResponseBadRequest() + + if not group.user == request.user: + return HttpResponseBadRequest() + user_results = ( models.User.viewer_aware_objects(request.user) .exclude( @@ -116,14 +121,6 @@ class FindUsers(View): request.user, local=True ) - group = get_object_or_404(models.Group, id=group_id) - - if not group: - return HttpResponseBadRequest() - - if not group.user == request.user: - return HttpResponseBadRequest() - data = { "suggested_users": user_results, "group": group,