Skip to content

Commit

Permalink
#43 リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Sep 8, 2024
1 parent a9df51a commit 5c4a5f5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from django.db.models import Q
from django.shortcuts import render

from custom_auth.models import UserGroup
from service.models import Service


@login_required
def index(request):
user_groups = UserGroup.objects.filter(user=request.user)
group_ids = list(request.user.groups.values_list("id", flat=True))
q = Q()
for user_group in user_groups:
q.add(Q(group=user_group.group), Q.OR)
for group_id in group_ids:
q.add(Q(group=group_id), Q.OR)
services = Service.objects.filter(is_active=True).filter(q).order_by("id")
per_page = int(request.GET.get("per_page", "20"))
page = int(request.GET.get("page", "1"))
Expand Down

0 comments on commit 5c4a5f5

Please sign in to comment.