299_Performance_tweaks #302
@ -55,10 +55,12 @@ class CheckboxCompensationTableFilter(CheckboxTableFilter):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if not value:
|
if not value:
|
||||||
return queryset.filter(
|
user_teams = self.user.shared_teams
|
||||||
|
result = queryset.filter(
|
||||||
Q(intervention__users__in=[self.user]) | # requesting user has access
|
Q(intervention__users__in=[self.user]) | # requesting user has access
|
||||||
Q(intervention__teams__in=self.user.shared_teams)
|
Q(intervention__teams__in=user_teams)
|
||||||
).distinct()
|
).distinct()
|
||||||
|
return result
|
||||||
else:
|
else:
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ Created on: 18.08.22
|
|||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.formats import number_format
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
value_relative = 0
|
value_relative = 0
|
||||||
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
||||||
|
html += f"{number_format(record.deductable_rest, decimal_pos=2)} m²"
|
||||||
return format_html(html)
|
return format_html(html)
|
||||||
|
|
||||||
def render_r(self, value, record: EcoAccount):
|
def render_r(self, value, record: EcoAccount):
|
||||||
|
@ -204,7 +204,11 @@ def detail_view(request: HttpRequest, id: str):
|
|||||||
"""
|
"""
|
||||||
template = "compensation/detail/compensation/view.html"
|
template = "compensation/detail/compensation/view.html"
|
||||||
comp = get_object_or_404(
|
comp = get_object_or_404(
|
||||||
Compensation,
|
Compensation.objects.select_related(
|
||||||
|
"modified",
|
||||||
|
"created",
|
||||||
|
"geometry"
|
||||||
|
),
|
||||||
id=id,
|
id=id,
|
||||||
deleted=None,
|
deleted=None,
|
||||||
intervention__deleted=None,
|
intervention__deleted=None,
|
||||||
|
@ -142,6 +142,8 @@ def detail_view(request: HttpRequest, id: str):
|
|||||||
"geometry",
|
"geometry",
|
||||||
"legal",
|
"legal",
|
||||||
"responsible",
|
"responsible",
|
||||||
|
).prefetch_related(
|
||||||
|
"legal__revocations",
|
||||||
),
|
),
|
||||||
id=id,
|
id=id,
|
||||||
deleted=None
|
deleted=None
|
||||||
@ -158,7 +160,10 @@ def detail_view(request: HttpRequest, id: str):
|
|||||||
last_checked = intervention.get_last_checked_action()
|
last_checked = intervention.get_last_checked_action()
|
||||||
last_checked_tooltip = ""
|
last_checked_tooltip = ""
|
||||||
if last_checked:
|
if last_checked:
|
||||||
last_checked_tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(last_checked.get_timestamp_str_formatted(), last_checked.user)
|
last_checked_tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(
|
||||||
|
last_checked.get_timestamp_str_formatted(),
|
||||||
|
last_checked.user
|
||||||
|
)
|
||||||
|
|
||||||
has_payment_without_document = intervention.payments.exists() and not intervention.get_documents()[1].exists()
|
has_payment_without_document = intervention.payments.exists() and not intervention.get_documents()[1].exists()
|
||||||
|
|
||||||
|
@ -50,9 +50,11 @@ class ShareableTableFilterMixin(django_filters.FilterSet):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if not value:
|
if not value:
|
||||||
return queryset.filter(
|
user_teams = self.user.shared_teams
|
||||||
|
result = queryset.filter(
|
||||||
Q(users__in=[self.user]) | # requesting user has access
|
Q(users__in=[self.user]) | # requesting user has access
|
||||||
Q(teams__in=self.user.shared_teams)
|
Q(teams__in=user_teams)
|
||||||
).distinct()
|
).distinct()
|
||||||
|
return result
|
||||||
else:
|
else:
|
||||||
return queryset
|
return queryset
|
@ -501,10 +501,13 @@ class ShareableObjectMixin(models.Model):
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
directly_shared = self.shared_users.filter(id=user.id).exists()
|
obj_shared_teams = self.shared_teams
|
||||||
team_shared = self.shared_teams.filter(
|
obj_shared_users = self.shared_users
|
||||||
users__in=[user]
|
user_shared_teams = user.shared_teams
|
||||||
).exists()
|
|
||||||
|
directly_shared = obj_shared_users.filter(id=user.id).exists()
|
||||||
|
team_shared = (obj_shared_teams & user_shared_teams).exists()
|
||||||
|
|
||||||
is_shared = directly_shared or team_shared
|
is_shared = directly_shared or team_shared
|
||||||
return is_shared
|
return is_shared
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ def home_view(request: HttpRequest):
|
|||||||
template = "konova/home.html"
|
template = "konova/home.html"
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
user = request.user
|
user = request.user
|
||||||
|
user_teams = user.shared_teams
|
||||||
|
|
||||||
# Fetch the four newest active and published ServerMessages
|
# Fetch the four newest active and published ServerMessages
|
||||||
msgs = ServerMessage.objects.filter(
|
msgs = ServerMessage.objects.filter(
|
||||||
@ -51,7 +52,7 @@ def home_view(request: HttpRequest):
|
|||||||
)
|
)
|
||||||
# Then fetch only user related ones
|
# Then fetch only user related ones
|
||||||
user_interventions = interventions.filter(
|
user_interventions = interventions.filter(
|
||||||
Q(users__in=[user]) | Q(teams__in=user.shared_teams)
|
Q(users__in=[user]) | Q(teams__in=user_teams)
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
# Repeat for other objects
|
# Repeat for other objects
|
||||||
@ -59,13 +60,13 @@ def home_view(request: HttpRequest):
|
|||||||
deleted=None,
|
deleted=None,
|
||||||
)
|
)
|
||||||
user_comps = comps.filter(
|
user_comps = comps.filter(
|
||||||
Q(intervention__users__in=[user]) | Q(intervention__teams__in=user.shared_teams)
|
Q(intervention__users__in=[user]) | Q(intervention__teams__in=user_teams)
|
||||||
).distinct()
|
).distinct()
|
||||||
eco_accs = EcoAccount.objects.filter(
|
eco_accs = EcoAccount.objects.filter(
|
||||||
deleted=None,
|
deleted=None,
|
||||||
)
|
)
|
||||||
user_ecco_accs = eco_accs.filter(
|
user_ecco_accs = eco_accs.filter(
|
||||||
Q(users__in=[user]) | Q(teams__in=user.shared_teams)
|
Q(users__in=[user]) | Q(teams__in=user_teams)
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
additional_context = {
|
additional_context = {
|
||||||
|
Loading…
Reference in New Issue
Block a user