mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-27 04:58:42 +02:00
formatted code for readability
This commit is contained in:
parent
1cd6fdda15
commit
d469041a8e
2 changed files with 19 additions and 20 deletions
|
@ -246,13 +246,7 @@ def is_members_subpage(path):
|
||||||
"""Checks if the given page is a subpage of members.
|
"""Checks if the given page is a subpage of members.
|
||||||
Takes a path name, like '/organization/'."""
|
Takes a path name, like '/organization/'."""
|
||||||
# Since our pages aren't unified under a common path, we need this approach for now.
|
# Since our pages aren't unified under a common path, we need this approach for now.
|
||||||
url_names = [
|
url_names = ["members", "member", "member-permissions", "invitedmember", "invitedmember-permissions"]
|
||||||
"members",
|
|
||||||
"member",
|
|
||||||
"member-permissions",
|
|
||||||
"invitedmember",
|
|
||||||
"invitedmember-permissions"
|
|
||||||
]
|
|
||||||
return get_url_name(path) in url_names
|
return get_url_name(path) in url_names
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ def get_portfolio_members_json(request):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def initial_permissions_search(portfolio):
|
def initial_permissions_search(portfolio):
|
||||||
"""Perform initial search for permissions before applying any filters."""
|
"""Perform initial search for permissions before applying any filters."""
|
||||||
permissions = UserPortfolioPermission.objects.filter(portfolio=portfolio)
|
permissions = UserPortfolioPermission.objects.filter(portfolio=portfolio)
|
||||||
|
@ -65,16 +66,17 @@ def initial_permissions_search(portfolio):
|
||||||
# If email is present and not blank, use email
|
# If email is present and not blank, use email
|
||||||
When(Q(user__email__isnull=False) & ~Q(user__email=""), then=F("user__email")),
|
When(Q(user__email__isnull=False) & ~Q(user__email=""), then=F("user__email")),
|
||||||
# If first name or last name is present, use concatenation of first_name + " " + last_name
|
# If first name or last name is present, use concatenation of first_name + " " + last_name
|
||||||
When(Q(user__first_name__isnull=False) | Q(user__last_name__isnull=False),
|
When(
|
||||||
|
Q(user__first_name__isnull=False) | Q(user__last_name__isnull=False),
|
||||||
then=Concat(
|
then=Concat(
|
||||||
Coalesce(F("user__first_name"), Value("")),
|
Coalesce(F("user__first_name"), Value("")),
|
||||||
Value(" "),
|
Value(" "),
|
||||||
Coalesce(F("user__last_name"), Value(""))
|
Coalesce(F("user__last_name"), Value("")),
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
# If neither, use an empty string
|
# If neither, use an empty string
|
||||||
default=Value(""),
|
default=Value(""),
|
||||||
output_field=CharField()
|
output_field=CharField(),
|
||||||
),
|
),
|
||||||
source=Value("permission", output_field=CharField()),
|
source=Value("permission", output_field=CharField()),
|
||||||
)
|
)
|
||||||
|
@ -92,6 +94,7 @@ def initial_permissions_search(portfolio):
|
||||||
)
|
)
|
||||||
return permissions
|
return permissions
|
||||||
|
|
||||||
|
|
||||||
def initial_invitations_search(portfolio):
|
def initial_invitations_search(portfolio):
|
||||||
"""Perform initial invitations search before applying any filters."""
|
"""Perform initial invitations search before applying any filters."""
|
||||||
invitations = PortfolioInvitation.objects.filter(portfolio=portfolio)
|
invitations = PortfolioInvitation.objects.filter(portfolio=portfolio)
|
||||||
|
@ -129,6 +132,7 @@ def apply_search_term(queryset, request):
|
||||||
)
|
)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
def apply_sorting(queryset, request):
|
def apply_sorting(queryset, request):
|
||||||
"""Apply sorting to the queryset."""
|
"""Apply sorting to the queryset."""
|
||||||
sort_by = request.GET.get("sort_by", "id") # Default to 'id'
|
sort_by = request.GET.get("sort_by", "id") # Default to 'id'
|
||||||
|
@ -142,6 +146,7 @@ def apply_sorting(queryset, request):
|
||||||
queryset = queryset.order_by(sort_by)
|
queryset = queryset.order_by(sort_by)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
def serialize_members(request, portfolio, item, user):
|
def serialize_members(request, portfolio, item, user):
|
||||||
# Check if the user can edit other users
|
# Check if the user can edit other users
|
||||||
user_can_edit_other_users = any(
|
user_can_edit_other_users = any(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue