forked from mirrors/bookwyrm
lint Group views file
This commit is contained in:
parent
cc8db1c353
commit
b1bb43d143
1 changed files with 10 additions and 13 deletions
|
@ -3,7 +3,7 @@ from django.apps import apps
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from django.core.paginator import Paginator
|
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.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
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 import forms, models
|
||||||
from bookwyrm.suggested_users import suggested_users
|
from bookwyrm.suggested_users import suggested_users
|
||||||
from .helpers import privacy_filter
|
|
||||||
from .helpers import get_user_from_username
|
from .helpers import get_user_from_username
|
||||||
from bookwyrm.settings import DOMAIN
|
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
class Group(View):
|
class Group(View):
|
||||||
"""group page"""
|
"""group page"""
|
||||||
|
|
||||||
|
@ -94,7 +92,14 @@ class FindUsers(View):
|
||||||
def get(self, request, group_id):
|
def get(self, request, group_id):
|
||||||
"""basic profile info"""
|
"""basic profile info"""
|
||||||
query = request.GET.get("query")
|
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 = (
|
user_results = (
|
||||||
models.User.viewer_aware_objects(request.user)
|
models.User.viewer_aware_objects(request.user)
|
||||||
.exclude(
|
.exclude(
|
||||||
|
@ -116,14 +121,6 @@ class FindUsers(View):
|
||||||
request.user, local=True
|
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 = {
|
data = {
|
||||||
"suggested_users": user_results,
|
"suggested_users": user_results,
|
||||||
"group": group,
|
"group": group,
|
||||||
|
|
Loading…
Reference in a new issue